anthropic-rs
is an unofficial Rust library to interact with Anthropic REST API, with async support.
Wanna play with Claude in Rust? This is the place to be!
```rust
async fn main() -> Result<(), Box
// Build from configuration.
let cfg = AnthropicConfig::new()?;
let client = Client::try_from(cfg)?;
let complete_request = CompleteRequestBuilder::default().prompt("How many toes do dogs have?").build()?;
// Send a completion request.
let complete_response = client.complete(complete_request).await?;
println!("completion response: {complete_response:?}");
Ok(())
} ```
You can find full working examples in the examples directory.
anthropic-rs uses dotenv
to automatically load environment variables from a .env
file. You can also set these variables manually in your environment. Here is an example of the configuration variables used:
bash
ANTHROPIC_API_KEY="..."
ANTHROPIC_DEFAULT_MODEL="claude-v1"
Replace the "..." with your actual tokens and preferences.
You can also set these variables manually when you crate a new Client
instance, see more details in usage section.
/v1/complete
)Contributions to anthropic-rs
are welcomed! Feel free to submit a pull request or create an issue.
anthropic-rs is licensed under the MIT License.