Skip to main content

Crate agent_framework_anthropic

Crate agent_framework_anthropic 

Source
Expand description

§agent-framework-anthropic

Anthropic (Claude) ChatClients for agent-framework-rs.

AnthropicClient talks directly to the Anthropic Messages API (POST /v1/messages), the same way agent-framework-openai talks to Chat Completions: hand-rolled request/response JSON conversion plus a hand-rolled SSE parser, with no dependency on Anthropic’s own SDK.

use agent_framework_anthropic::AnthropicClient;
use agent_framework_core::prelude::*;

let client = AnthropicClient::new("sk-ant-...", "claude-sonnet-4-5-20250929");
let agent = Agent::builder(client)
    .instructions("You are concise.")
    .build();
let reply = agent.run_once("Say hi").await?;
println!("{}", reply.text());

§Multi-cloud transports

Claude models are also available through three managed-cloud offerings, each of which speaks the same Anthropic Messages API wire format AnthropicClient does — only the URL shape, model-selection mechanism, and authentication scheme differ. Each is a thin transport built on convert::build_cloud_request (the direct API’s convert::build_request minus the top-level model field, plus a cloud-specific anthropic_version tag) rather than a reimplementation of the wire format:

Re-exports§

pub use bedrock::AnthropicBedrockClient;
pub use foundry::AnthropicFoundryClient;
pub use vertex::AnthropicVertexClient;
pub use vertex::StaticVertexToken;
pub use vertex::VertexTokenProvider;

Modules§

bedrock
AnthropicBedrockClient: Anthropic (Claude) models hosted on AWS Bedrock, spoken over Bedrock’s InvokeModel API rather than Bedrock’s own model-agnostic Converse API (POST https://bedrock-runtime.{region}.amazonaws.com/model/{model}/invoke).
convert
Conversion between framework types and the Anthropic Messages API wire format.
foundry
AnthropicFoundryClient: Anthropic (Claude) models hosted on Azure AI Foundry, spoken over a Foundry Anthropic deployment’s Messages-shaped endpoint (POST {base_url}{path}, defaulting to {base_url}/v1/messages).
vertex
AnthropicVertexClient: Anthropic (Claude) models hosted on Google Vertex AI, spoken over Vertex’s rawPredict / streamRawPredict publisher-model routes (POST https://{region}-aiplatform.googleapis.com/v1/projects/{project}/locations/{region}/publishers/anthropic/models/{model}:rawPredict).

Structs§

AnthropicClient
An Anthropic (Claude) Messages API chat client.