agentkit-provider-anthropic 0.9.1

Anthropic Messages API provider adapter for agentkit.
Documentation

agentkit-provider-anthropic

Anthropic Messages API provider for agentkit.

Connects the agent loop to https://api.anthropic.com/v1/messages (or any compatible endpoint). Supports streaming, prompt caching, extended thinking, and server-side tools (web search, web fetch, code execution).

Quick start

use agentkit_loop::{Agent, SessionConfig};
use agentkit_provider_anthropic::{AnthropicAdapter, AnthropicConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = AnthropicConfig::from_env()?;
    let adapter = AnthropicAdapter::new(config)?;

    let agent = Agent::builder().model(adapter).build()?;
    let _driver = agent.start(SessionConfig::new("demo")).await?;
    Ok(())
}

Environment variables

Variable Required Default
ANTHROPIC_API_KEY one of
ANTHROPIC_AUTH_TOKEN one of — (bearer token; takes precedence if set)
ANTHROPIC_MODEL yes
ANTHROPIC_MAX_TOKENS yes — (required per-request by the API)
ANTHROPIC_BASE_URL no https://api.anthropic.com/v1/messages
ANTHROPIC_VERSION no 2023-06-01
ANTHROPIC_BETA no comma-separated list of anthropic-beta tags

Server tools

Known server tools (WebSearchTool, WebFetchTool, CodeExecutionTool, etc.) implement the ServerTool trait. RawServerTool passes through any tool type the crate does not yet cover.