Expand description
Anthropic Messages API client implementing klieo_core::LlmClient.
Wraps Anthropic’s /v1/messages endpoint. Capability declaration
(tool_calling, streaming, structured_output, embeddings,
max_context_tokens, vision) is computed at construction time from
the configured chat-model name; see capabilities::model_capabilities.
Sibling to klieo-llm-ollama and klieo-llm-openai — the three
crates implement the same LlmClient trait so a Box<dyn LlmClient>
consumer can swap between them without other code changes.
§Differences from OpenAI
- Auth:
x-api-key: <key>header (NOTAuthorization: Bearer), plus requiredanthropic-version: 2023-06-01header. max_tokensis REQUIRED in every request; the client defaults to 4096 if the caller leaves it unset.- Tool input is a JSON object on the wire (not a JSON-encoded string like OpenAI). No string-parse boundary needed.
- Content blocks are an array of typed blocks (text + tool_use +
tool_result), not a flat
content: String+ paralleltool_calls. - Streaming uses TYPED SSE events (
event: message_deltaetc), not OpenAI’s flatdata:lines. - Embeddings are NOT supported by Anthropic;
embed()returnsLlmError::BadRequest.
§Example
use klieo_llm_anthropic::AnthropicClient;
let client = AnthropicClient::new("your-anthropic-api-key", "claude-sonnet-4-6");§Limitations
- Vision input is declared in
Capabilities::visionbut the wire encoding forImagecontent blocks is not implemented in v0.1.0; see the carryovers section of the implementation plan. - Bedrock and Vertex AI deployments are not yet first-class targets;
override the base URL via
AnthropicClient::with_base_urlfor now.
Re-exports§
pub use capabilities::model_capabilities;pub use client::AnthropicClient;
Modules§
- capabilities
- Static lookup of
klieo_core::Capabilitiesby Anthropic model name. - client
AnthropicClient—LlmClientimpl over Anthropic’s Messages API.