pub struct Client { /* private fields */ }Expand description
Unified LLM client that works with both OpenAI and Anthropic APIs.
Implementations§
Source§impl Client
impl Client
Sourcepub fn openai(api_key: impl Into<String>) -> Self
pub fn openai(api_key: impl Into<String>) -> Self
Create a client for the OpenAI API (https://api.openai.com/v1).
Sourcepub fn openai_with_base_url(
api_key: impl Into<String>,
base_url: impl Into<String>,
) -> Self
pub fn openai_with_base_url( api_key: impl Into<String>, base_url: impl Into<String>, ) -> Self
Create a client for an OpenAI-compatible API with a custom base URL.
Sourcepub fn anthropic(api_key: impl Into<String>) -> Self
pub fn anthropic(api_key: impl Into<String>) -> Self
Create a client for the Anthropic API (https://api.anthropic.com).
Sourcepub fn anthropic_with_base_url(
api_key: impl Into<String>,
base_url: impl Into<String>,
) -> Self
pub fn anthropic_with_base_url( api_key: impl Into<String>, base_url: impl Into<String>, ) -> Self
Create a client for an Anthropic-compatible API with a custom base URL.
Sourcepub fn from_provider(config: &LlmProviderConfig) -> Self
pub fn from_provider(config: &LlmProviderConfig) -> Self
Create a client from a LlmProviderConfig.
Sourcepub async fn chat(&self, request: ChatRequest) -> Result<ChatResponse, Error>
pub async fn chat(&self, request: ChatRequest) -> Result<ChatResponse, Error>
Send a chat completion request and wait for the full response.
Sourcepub async fn chat_stream(
&self,
request: ChatRequest,
) -> Result<Pin<Box<dyn Stream<Item = Result<StreamEvent, Error>> + Send>>, Error>
pub async fn chat_stream( &self, request: ChatRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<StreamEvent, Error>> + Send>>, Error>
Send a chat completion request and receive a stream of incremental events.
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl !UnwindSafe for Client
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