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>) -> Self
pub fn new(api_key: impl Into<String>, model: impl Into<String>) -> Self
Create a client for the given API key and default model.
Sourcepub fn from_env(model: impl Into<String>) -> Result<Self>
pub fn from_env(model: impl Into<String>) -> Result<Self>
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>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Override the base URL (for Azure OpenAI or compatible servers).
Sourcepub fn with_organization(self, org: impl Into<String>) -> Self
pub fn with_organization(self, org: impl Into<String>) -> Self
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>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_streaming_response<'life0, 'async_trait>(
&'life0 self,
messages: Vec<Message>,
options: ChatOptions,
) -> Pin<Box<dyn Future<Output = Result<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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