pub struct AnthropicProvider { /* private fields */ }Expand description
Anthropic Claude provider implementing Provider.
Supports the Anthropic Messages API with tool calling, extended thinking, and streaming.
§Example
use llm_stack_anthropic::{AnthropicConfig, AnthropicProvider};
use llm_stack_core::{ChatParams, ChatMessage, Provider};
let provider = AnthropicProvider::new(AnthropicConfig {
api_key: std::env::var("ANTHROPIC_API_KEY").unwrap(),
..Default::default()
});
let response = provider.generate(&ChatParams {
messages: vec![ChatMessage::user("Hello!")],
..Default::default()
}).await?;Implementations§
Source§impl AnthropicProvider
impl AnthropicProvider
Sourcepub fn new(config: AnthropicConfig) -> Self
pub fn new(config: AnthropicConfig) -> Self
Create a new Anthropic provider from configuration.
If config.client is Some, that client is reused for connection
pooling. Otherwise a new client is built with the configured timeout.
Trait Implementations§
Source§impl Debug for AnthropicProvider
impl Debug for AnthropicProvider
Source§impl Provider for AnthropicProvider
impl Provider for AnthropicProvider
Source§async fn generate(&self, params: &ChatParams) -> Result<ChatResponse, LlmError>
async fn generate(&self, params: &ChatParams) -> Result<ChatResponse, LlmError>
Sends a chat completion request and returns the full response.
Source§async fn stream(&self, params: &ChatParams) -> Result<ChatStream, LlmError>
async fn stream(&self, params: &ChatParams) -> Result<ChatStream, LlmError>
Sends a chat completion request and returns a stream of events. Read more
Source§fn metadata(&self) -> ProviderMetadata
fn metadata(&self) -> ProviderMetadata
Returns static metadata describing this provider instance.
Auto Trait Implementations§
impl Freeze for AnthropicProvider
impl !RefUnwindSafe for AnthropicProvider
impl Send for AnthropicProvider
impl Sync for AnthropicProvider
impl Unpin for AnthropicProvider
impl !UnwindSafe 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
Source§impl<T> DynProvider for Twhere
T: Provider,
impl<T> DynProvider for Twhere
T: Provider,
Source§fn generate_boxed<'a>(
&'a self,
params: &'a ChatParams,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'a>>
fn generate_boxed<'a>( &'a self, params: &'a ChatParams, ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'a>>
Boxed-future version of
Provider::generate.Source§fn stream_boxed<'a>(
&'a self,
params: &'a ChatParams,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamEvent, LlmError>> + Send>>, LlmError>> + Send + 'a>>
fn stream_boxed<'a>( &'a self, params: &'a ChatParams, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamEvent, LlmError>> + Send>>, LlmError>> + Send + 'a>>
Boxed-future version of
Provider::stream.Source§fn metadata(&self) -> ProviderMetadata
fn metadata(&self) -> ProviderMetadata
Returns static metadata describing this provider instance.