pub struct OpenAIChatClient { /* private fields */ }Expand description
An OpenAI Responses API chat client (POST /v1/responses).
Implementations§
Source§impl OpenAIChatClient
impl OpenAIChatClient
Sourcepub fn new(
api_key: impl Into<String>,
model: impl Into<String>,
) -> OpenAIChatClient
pub fn new( api_key: impl Into<String>, model: impl Into<String>, ) -> OpenAIChatClient
Create a client for the given API key and default model.
Sourcepub fn from_env(model: impl Into<String>) -> Result<OpenAIChatClient, Error>
pub fn from_env(model: impl Into<String>) -> Result<OpenAIChatClient, Error>
Build a client from the OPENAI_API_KEY (and optional
OPENAI_BASE_URL) environment variables.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> OpenAIChatClient
pub fn with_base_url(self, base_url: impl Into<String>) -> OpenAIChatClient
Override the base URL (for Azure OpenAI or compatible servers).
Sourcepub fn with_organization(self, org: impl Into<String>) -> OpenAIChatClient
pub fn with_organization(self, org: impl Into<String>) -> OpenAIChatClient
Set the organization header.
Trait Implementations§
Source§impl ChatClient for OpenAIChatClient
impl ChatClient for OpenAIChatClient
Source§fn get_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
OpenAIChatClient: 'async_trait,
fn get_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
OpenAIChatClient: 'async_trait,
Get a complete (non-streaming) response.
Source§fn get_streaming_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<ChatResponseUpdate, Error>> + Send>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
OpenAIChatClient: 'async_trait,
fn get_streaming_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<ChatResponseUpdate, Error>> + Send>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
OpenAIChatClient: 'async_trait,
Get a streaming response as a sequence of updates.
Source§impl Clone for OpenAIChatClient
impl Clone for OpenAIChatClient
Source§fn clone(&self) -> OpenAIChatClient
fn clone(&self) -> OpenAIChatClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for OpenAIChatClient
impl !UnwindSafe for OpenAIChatClient
impl Freeze for OpenAIChatClient
impl Send for OpenAIChatClient
impl Sync for OpenAIChatClient
impl Unpin for OpenAIChatClient
impl UnsafeUnpin for OpenAIChatClient
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