pub struct AnthropicProvider { /* private fields */ }Expand description
Anthropic (Claude) provider over the /v1/messages API.
Implementations§
Source§impl AnthropicProvider
impl AnthropicProvider
Sourcepub fn new(api_key: impl Into<String>) -> AnthropicProvider
pub fn new(api_key: impl Into<String>) -> AnthropicProvider
Construct with an explicit API key.
Sourcepub fn from_env() -> Result<AnthropicProvider, LlmError>
pub fn from_env() -> Result<AnthropicProvider, LlmError>
Construct from the ANTHROPIC_API_KEY environment variable.
Sourcepub fn model(self, model: impl Into<String>) -> AnthropicProvider
pub fn model(self, model: impl Into<String>) -> AnthropicProvider
Set the default model.
Sourcepub fn base_url(self, base_url: impl Into<String>) -> AnthropicProvider
pub fn base_url(self, base_url: impl Into<String>) -> AnthropicProvider
Override the base URL.
Sourcepub fn version(self, version: impl Into<String>) -> AnthropicProvider
pub fn version(self, version: impl Into<String>) -> AnthropicProvider
Override the anthropic-version header.
Sourcepub fn with_client(self, client: Client) -> AnthropicProvider
pub fn with_client(self, client: Client) -> AnthropicProvider
Provide a custom reqwest::Client.
Trait Implementations§
Source§impl Clone for AnthropicProvider
impl Clone for AnthropicProvider
Source§fn clone(&self) -> AnthropicProvider
fn clone(&self) -> AnthropicProvider
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 moreSource§impl LlmProvider for AnthropicProvider
impl LlmProvider for AnthropicProvider
Source§fn chat<'life0, 'async_trait>(
&'life0 self,
req: ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'async_trait>>where
'life0: 'async_trait,
AnthropicProvider: 'async_trait,
fn chat<'life0, 'async_trait>(
&'life0 self,
req: ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'async_trait>>where
'life0: 'async_trait,
AnthropicProvider: 'async_trait,
Single-shot chat completion.
Source§fn chat_stream<'life0, 'async_trait>(
&'life0 self,
req: ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamDelta, LlmError>> + Send>>, LlmError>> + Send + 'async_trait>>where
'life0: 'async_trait,
AnthropicProvider: 'async_trait,
fn chat_stream<'life0, 'async_trait>(
&'life0 self,
req: ChatRequest,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamDelta, LlmError>> + Send>>, LlmError>> + Send + 'async_trait>>where
'life0: 'async_trait,
AnthropicProvider: 'async_trait,
Streaming chat completion.
Source§fn embed<'life0, 'async_trait>(
&'life0 self,
_req: EmbedRequest,
) -> Pin<Box<dyn Future<Output = Result<EmbedResponse, LlmError>> + Send + 'async_trait>>where
'life0: 'async_trait,
AnthropicProvider: 'async_trait,
fn embed<'life0, 'async_trait>(
&'life0 self,
_req: EmbedRequest,
) -> Pin<Box<dyn Future<Output = Result<EmbedResponse, LlmError>> + Send + 'async_trait>>where
'life0: 'async_trait,
AnthropicProvider: 'async_trait,
Generate embeddings.
Source§fn estimate_cost(&self, req: &ChatRequest) -> Option<CostEstimate>
fn estimate_cost(&self, req: &ChatRequest) -> Option<CostEstimate>
Pre-flight cost estimate (no network call).
None if unknown.Auto Trait Implementations§
impl !RefUnwindSafe for AnthropicProvider
impl !UnwindSafe for AnthropicProvider
impl Freeze for AnthropicProvider
impl Send for AnthropicProvider
impl Sync for AnthropicProvider
impl Unpin for AnthropicProvider
impl UnsafeUnpin for AnthropicProvider
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