pub struct ClientConfig {
pub api_key: String,
pub base_url: String,
pub organization: Option<String>,
pub project: Option<String>,
pub timeout_secs: u64,
pub max_retries: u32,
pub default_headers: Option<HeaderMap>,
pub default_query: Option<Vec<(String, String)>>,
/* private fields */
}Expand description
Configuration for the OpenAI client.
Fields§
§api_key: String§base_url: String§organization: Option<String>§project: Option<String>§timeout_secs: u64§max_retries: u32§default_headers: Option<HeaderMap>Default headers sent with every request.
default_query: Option<Vec<(String, String)>>Default query parameters appended to every request URL.
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn from_env() -> Result<Self, OpenAIError>
pub fn from_env() -> Result<Self, OpenAIError>
Create config from the OPENAI_API_KEY environment variable.
pub fn base_url(self, url: impl Into<String>) -> Self
pub fn organization(self, org: impl Into<String>) -> Self
pub fn project(self, project: impl Into<String>) -> Self
pub fn timeout_secs(self, secs: u64) -> Self
pub fn max_retries(self, retries: u32) -> Self
Sourcepub fn default_headers(self, headers: HeaderMap) -> Self
pub fn default_headers(self, headers: HeaderMap) -> Self
Set default headers sent with every request.
Sourcepub fn default_query(self, query: Vec<(String, String)>) -> Self
pub fn default_query(self, query: Vec<(String, String)>) -> Self
Set default query parameters appended to every request URL.
Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§fn clone(&self) -> ClientConfig
fn clone(&self) -> ClientConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Config for ClientConfig
impl Config for ClientConfig
Source§fn build_request(&self, req: RequestBuilder) -> RequestBuilder
fn build_request(&self, req: RequestBuilder) -> RequestBuilder
Hook to modify or add provider-specific headers and auth to a request.
Source§fn organization(&self) -> Option<&str>
fn organization(&self) -> Option<&str>
Returns the organization ID, if any.
Source§fn timeout_secs(&self) -> u64
fn timeout_secs(&self) -> u64
Returns the timeout in seconds.
Source§fn max_retries(&self) -> u32
fn max_retries(&self) -> u32
Returns the maximum number of retries.
Source§fn default_headers(&self) -> Option<&HeaderMap>
fn default_headers(&self) -> Option<&HeaderMap>
Returns default headers to append to all requests.
Source§fn default_query(&self) -> Option<&[(String, String)]>
fn default_query(&self) -> Option<&[(String, String)]>
Returns default query parameters to append to all requests.
Source§fn initial_options(&self) -> RequestOptions
fn initial_options(&self) -> RequestOptions
Build the initial
RequestOptions from config-level defaults.Auto Trait Implementations§
impl Freeze for ClientConfig
impl RefUnwindSafe for ClientConfig
impl Send for ClientConfig
impl Sync for ClientConfig
impl Unpin for ClientConfig
impl UnsafeUnpin for ClientConfig
impl UnwindSafe for ClientConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more