pub struct OpenAiClient { /* private fields */ }Expand description
Client for OpenAI Responses API
Implementations§
Source§impl OpenAiClient
impl OpenAiClient
Sourcepub fn new(api_key: String) -> OpenAiClient
pub fn new(api_key: String) -> OpenAiClient
Create a new OpenAI client with the given API key
Sourcepub fn new_with_base_url(api_key: String, base_url: String) -> OpenAiClient
pub fn new_with_base_url(api_key: String, base_url: String) -> OpenAiClient
Create a new OpenAI client with an explicit base URL
Sourcepub fn new_with_optional_api_key_and_base_url(
api_key: Option<String>,
base_url: String,
) -> OpenAiClient
pub fn new_with_optional_api_key_and_base_url( api_key: Option<String>, base_url: String, ) -> OpenAiClient
Create a new OpenAI client with an optional API key and explicit base URL.
Sourcepub fn with_extra_headers(self, headers: Vec<(String, String)>) -> OpenAiClient
pub fn with_extra_headers(self, headers: Vec<(String, String)>) -> OpenAiClient
Install a set of (name, value) headers to include on every request.
ChatGPT-backend callers pass ChatGPT-Account-ID and optionally
X-OpenAI-Fedramp here.
Sourcepub fn with_responses_path(self, path: impl Into<String>) -> OpenAiClient
pub fn with_responses_path(self, path: impl Into<String>) -> OpenAiClient
Set the Responses endpoint path relative to base_url.
Public OpenAI uses /v1/responses; the ChatGPT Codex backend
uses /responses under https://chatgpt.com/backend-api/codex.
pub fn with_chatgpt_backend_wire(self) -> OpenAiClient
Attach a dynamic authorizer. When set, overrides the
Authorization: Bearer <api_key> path on every request with
HttpAuthorizer::authorize. Extra headers (ChatGPT-Account-ID
etc.) still flow through unchanged.
pub fn extra_headers(&self) -> &[(String, String)]
Sourcepub fn with_base_url(self, url: String) -> OpenAiClient
pub fn with_base_url(self, url: String) -> OpenAiClient
Set custom base URL