pub struct Client { /* private fields */ }Implementations§
Source§impl Client
impl Client
Sourcepub fn new(
api_key: &str,
base_url: &str,
betas: Option<Vec<&str>>,
version: &str,
) -> Self
pub fn new( api_key: &str, base_url: &str, betas: Option<Vec<&str>>, version: &str, ) -> Self
Create a new Anthropic client with the given API key, base URL, betas, and version.
Note, you probably want to use the ClientBuilder instead.
Panics:
- If the API key or version cannot be parsed as a Json value from a String.
- This should really never happen.
- If the reqwest client cannot be built (if the TLS backend cannot be initialized).
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Create a new Anthropic client from the ANTHROPIC_API_KEY environment variable.
Panics if the environment variable is not set.
pub fn post(&self, path: &str) -> RequestBuilder
pub fn completion_model(&self, model: &str) -> CompletionModel
Sourcepub fn agent(&self, model: &str) -> AgentBuilder<CompletionModel>
pub fn agent(&self, model: &str) -> AgentBuilder<CompletionModel>
Create an agent builder with the given completion model.
§Example
use rig::providers::anthropic::{ClientBuilder, self};
// Initialize the Anthropic client
let anthropic = ClientBuilder::new("your-claude-api-key").build();
let agent = anthropic.agent(anthropic::CLAUDE_3_5_SONNET)
.preamble("You are comedian AI with a mission to make people laugh.")
.temperature(0.0)
.build();pub fn extractor<T: JsonSchema + for<'a> Deserialize<'a> + Serialize + Send + Sync>( &self, model: &str, ) -> ExtractorBuilder<T, CompletionModel>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin 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