pub struct Claude { /* private fields */ }Expand description
Claude chat model client for the Anthropic Messages API.
§Example
ⓘ
use aither_claude::Claude;
use aither_core::{LanguageModel, llm::oneshot};
let client = Claude::new(std::env::var("ANTHROPIC_API_KEY")?);
let response = client.respond(oneshot(
"You are a helpful assistant.",
"What is the capital of France?"
)).await?;
println!("{response}");Implementations§
Source§impl Claude
impl Claude
Sourcepub fn new(api_key: impl Into<String>) -> Claude
pub fn new(api_key: impl Into<String>) -> Claude
Create a new client using the provided API key.
Sourcepub fn builder(api_key: impl Into<String>) -> Builder
pub fn builder(api_key: impl Into<String>) -> Builder
Start building a Claude client with custom configuration.
Sourcepub fn with_model(self, model: impl Into<String>) -> Claude
pub fn with_model(self, model: impl Into<String>) -> Claude
Override the default model in-place.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Claude
pub fn with_base_url(self, base_url: impl Into<String>) -> Claude
Override the base URL (useful for proxies or local deployments).
Sourcepub fn with_max_tokens(self, max_tokens: u32) -> Claude
pub fn with_max_tokens(self, max_tokens: u32) -> Claude
Override the default max_tokens.
Sourcepub fn with_idle_timeout(self, idle_timeout: Duration) -> Claude
pub fn with_idle_timeout(self, idle_timeout: Duration) -> Claude
Override how long a response stream may stay silent before it ends with
a FailureKind::Network
error. Defaults to 90 seconds.
Trait Implementations§
Source§impl From<Claude> for CloudProvider
impl From<Claude> for CloudProvider
Source§impl LanguageModel for Claude
impl LanguageModel for Claude
Source§type Error = ClaudeError
type Error = ClaudeError
The error type returned by this language model.
Source§fn respond(
&self,
request: LLMRequest,
) -> impl Stream<Item = Result<Event, <Claude as LanguageModel>::Error>> + Send
fn respond( &self, request: LLMRequest, ) -> impl Stream<Item = Result<Event, <Claude as LanguageModel>::Error>> + Send
Generates a streaming response to a conversation. Read more
Source§fn complete(
&self,
prefix: &str,
) -> impl Stream<Item = Result<Event, <Claude as LanguageModel>::Error>> + Send
fn complete( &self, prefix: &str, ) -> impl Stream<Item = Result<Event, <Claude as LanguageModel>::Error>> + Send
Completes given text prefix.
Source§fn profile(
&self,
) -> impl Future<Output = Result<Profile, <Claude as LanguageModel>::Error>> + Send
fn profile( &self, ) -> impl Future<Output = Result<Profile, <Claude as LanguageModel>::Error>> + Send
Returns model profile and capabilities. Read more
Source§fn respond_with_tools(
&self,
request: LLMRequestWithTools<'_>,
) -> impl Stream<Item = Result<Event, Self::Error>> + Send
fn respond_with_tools( &self, request: LLMRequestWithTools<'_>, ) -> impl Stream<Item = Result<Event, Self::Error>> + Send
Generates a streaming response with a mutable tool registry. Read more
Source§fn generate<T>(
&self,
request: LLMRequest,
) -> impl Future<Output = Result<T, GenerateError<Self::Error>>> + Sendwhere
T: JsonSchema + DeserializeOwned + 'static,
fn generate<T>(
&self,
request: LLMRequest,
) -> impl Future<Output = Result<T, GenerateError<Self::Error>>> + Sendwhere
T: JsonSchema + DeserializeOwned + 'static,
Generates structured output conforming to JSON schema. Read more
Source§fn summarize(
&self,
text: &str,
) -> impl Stream<Item = Result<Event, Self::Error>> + Send
fn summarize( &self, text: &str, ) -> impl Stream<Item = Result<Event, Self::Error>> + Send
Summarizes text. Read more
Source§fn categorize<T>(
&self,
text: &str,
) -> impl Future<Output = Result<T, GenerateError<Self::Error>>> + Sendwhere
T: JsonSchema + DeserializeOwned + 'static,
fn categorize<T>(
&self,
text: &str,
) -> impl Future<Output = Result<T, GenerateError<Self::Error>>> + Sendwhere
T: JsonSchema + DeserializeOwned + 'static,
Categorizes text. Read more
Source§fn retry_policy(&self) -> RetryPolicy
fn retry_policy(&self) -> RetryPolicy
How a request to this model that failed with a retryable failure is
sent again. Read more
Auto Trait Implementations§
impl Forget for Claude
impl Freeze for Claude
impl RefUnwindSafe for Claude
impl Send for Claude
impl Sync for Claude
impl Unpin for Claude
impl UnsafeUnpin for Claude
impl UnwindSafe for Claude
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