Struct async_openai::Client
source · pub struct Client { /* private fields */ }
Expand description
Client is a container for api key, base url, organization id, and backoff configuration used to make API calls.
Implementations§
source§impl Client
impl Client
sourcepub fn new() -> Self
pub fn new() -> Self
Create client with default API_BASE url and default API key from OPENAI_API_KEY env var
sourcepub fn with_api_key<S: Into<String>>(self, api_key: S) -> Self
pub fn with_api_key<S: Into<String>>(self, api_key: S) -> Self
To use a different API key different from default OPENAI_API_KEY env var
sourcepub fn with_org_id<S: Into<String>>(self, org_id: S) -> Self
pub fn with_org_id<S: Into<String>>(self, org_id: S) -> Self
To use a different organization id other than default
sourcepub fn with_api_base<S: Into<String>>(self, api_base: S) -> Self
pub fn with_api_base<S: Into<String>>(self, api_base: S) -> Self
To use a API base url different from default API_BASE
sourcepub fn with_backoff(self, backoff: ExponentialBackoff) -> Self
pub fn with_backoff(self, backoff: ExponentialBackoff) -> Self
Exponential backoff for retrying rate limited requests. Form submissions are not retried.
pub fn api_base(&self) -> &str
pub fn api_key(&self) -> &str
sourcepub fn completions(&self) -> Completions<'_>
pub fn completions(&self) -> Completions<'_>
To call Completions group related APIs using this client.
sourcepub fn moderations(&self) -> Moderations<'_>
pub fn moderations(&self) -> Moderations<'_>
To call Moderations group related APIs using this client.
sourcepub fn fine_tunes(&self) -> FineTunes<'_>
pub fn fine_tunes(&self) -> FineTunes<'_>
To call FineTunes group related APIs using this client.
sourcepub fn embeddings(&self) -> Embeddings<'_>
pub fn embeddings(&self) -> Embeddings<'_>
To call Embeddings group related APIs using this client.