| Crates.io | api_claude |
| lib.rs | api_claude |
| version | 0.4.0 |
| created_at | 2025-11-06 19:01:54.547748+00 |
| updated_at | 2025-11-29 18:20:17.22979+00 |
| description | Claude API for accessing Anthropic's large language models (LLMs). |
| homepage | https://github.com/Wandalen/api_llm/tree/master/api/claude |
| repository | https://github.com/Wandalen/api_llm/tree/master/api/claude |
| max_upload_size | |
| id | 1920123 |
| size | 1,358,876 |
Comprehensive Rust client for Anthropic's Claude API with enterprise reliability features.
This API crate is designed as a stateless HTTP client with zero persistence requirements. It provides:
This ensures lightweight, containerized deployments and eliminates operational complexity.
Expose all server-side functionality transparently while maintaining zero client-side intelligence or automatic behaviors.
Key principles:
Core Capabilities:
Enterprise Reliability:
Client Enhancements:
Add to your Cargo.toml:
[dependencies]
api_claude = { version = "0.1.0", features = ["full"] }
use api_claude::{ Client, Secret, CreateMessageRequest, Message, Role, Content };
#[ tokio::main ]
async fn main() -> Result< (), Box< dyn std::error::Error > >
{
let secret = Secret::new( "sk-ant-api03-your-key-here".to_string() )?;
let client = Client::new( secret );
let request = CreateMessageRequest::builder()
.model( "claude-sonnet-4-5-20250929".to_string() )
.max_tokens( 1000 )
.messages( vec![
Message
{
role : Role::User,
content : vec![ Content::Text
{
r#type : "text".to_string(),
text : "Hello, Claude!".to_string(),
} ],
cache_control : None,
}
] )
.build();
let response = client.create_message( request ).await?;
println!( "Claude: {:?}", response.content );
Ok( () )
}
use api_claude::{ Client, Secret, CreateMessageRequest, Message, Role, Content };
use futures_util::StreamExt;
#[ tokio::main ]
async fn main() -> Result< (), Box< dyn std::error::Error > >
{
let client = Client::from_workspace()?;
let request = CreateMessageRequest::builder()
.model( "claude-sonnet-4-5-20250929".to_string() )
.max_tokens( 1000 )
.stream( true )
.messages( vec![ Message::user( "Tell me a story" ) ] )
.build();
let mut stream = client.create_message_stream( request ).await?;
while let Some( event ) = stream.next().await
{
let event = event?;
if let Some( text ) = event.delta_text()
{
print!( "{}", text );
}
}
Ok( () )
}
Create secret/-secrets.sh in your workspace root:
#!/bin/bash
export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"
use api_claude::Client;
let client = Client::from_workspace()?;
export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"
use api_claude::Client;
let client = Client::from_env()?;
use api_claude::{ Client, Secret };
let secret = Secret::new( "sk-ant-api03-your-key-here".to_string() )?;
let client = Client::new( secret );
See Secret Loading Guide for complete authentication options.
enabled - Master switch for core functionalitystreaming - SSE streaming supporttools - Function calling and toolsvision - Image understanding capabilitiesretry-logic - Exponential backoff retrycircuit-breaker - Circuit breaker patternrate-limiting - Token bucket rate limitingfailover - Multi-endpoint failoverhealth-checks - Health monitoringsync-api - Synchronous wrapperscurl-diagnostics - Debug utilitiescompression - HTTP compressionenterprise-quota - Usage trackingdynamic-config - Runtime configurationfull - All features enabled| Model | Context Window | Capabilities |
|---|---|---|
| claude-sonnet-4-5-20250929 | 200k tokens | Full capabilities |
| claude-3-5-sonnet-latest | 200k tokens | Fast, cost-effective |
| claude-3-opus-latest | 200k tokens | Highest capability |
| claude-3-haiku-latest | 200k tokens | Fastest |
All dependencies workspace-managed for consistency.
cargo clippy -- -D warningsMIT