pub struct MistralChatClient { /* private fields */ }Expand description
A Mistral AI chat client (POST {base_url}/chat/completions).
Implementations§
Source§impl MistralChatClient
impl MistralChatClient
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 MISTRAL_API_KEY (and optional
MISTRAL_BASE_URL) environment variables.
Unlike Ollama (which runs unauthenticated by default and so has no
API-key environment variable at all), Mistral’s hosted API always
requires a bearer token, so MISTRAL_API_KEY is required here.
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 proxies or private deployments).
Trait Implementations§
Source§impl ChatClient for MistralChatClient
impl ChatClient for MistralChatClient
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 MistralChatClient
impl Clone for MistralChatClient
Source§fn clone(&self) -> MistralChatClient
fn clone(&self) -> MistralChatClient
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 MistralChatClient
impl !UnwindSafe for MistralChatClient
impl Freeze for MistralChatClient
impl Send for MistralChatClient
impl Sync for MistralChatClient
impl Unpin for MistralChatClient
impl UnsafeUnpin for MistralChatClient
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