Claude to an Agent.
Installation
Authentication
Set theANTHROPIC_API_KEY environment variable. Create a key in the Claude Console.
Example
agent.py
agent.py, then run:
Model Selection
Claude defaults to claude-sonnet-4-5-20250929 in Agno v2.7.2. Pass another model ID with Claude(id=...) when a different capability or latency profile fits the use case.
See Anthropic’s current model comparison and model lifecycle table before deploying a pinned model.
Claude 4.5 model IDs use dated snapshots. Shorter names such as
claude-sonnet-4-5 are aliases. Starting with Claude 4.6, dateless IDs such
as claude-sonnet-4-6 are canonical pinned versions, not rolling aliases.Supported Input
Agno sends image URLs to Anthropic as base64 data after downloading them. Anthropic’s request-size, image-size, page-count, and model limits still apply. See the vision limits and PDF limits.
Request Limits
The Messages API requiresmax_tokens. Agno sends 8192 unless max_tokens is set on Claude. Anthropic also accepts 0 for prompt-cache pre-warming, but Agno v2.7.2 omits that falsy value; use a positive value with this adapter. See the Messages API reference.
Anthropic also applies organization and workspace rate limits. See the rate-limit documentation.
Beta Features
Pass exact Anthropic beta names withbetas. Features that add request fields also need their matching Agno parameters. This context-editing configuration sends both the required beta and request body:
Prompt Caching
Setcache_system_prompt=True to add a prompt-cache breakpoint to the agent’s system prompt:
Structured Outputs
Pass a Pydantic model asoutput_schema to use Claude’s native structured outputs. Anthropic supports structured outputs on Claude Opus 4.1, the Claude 4.5 families, and later models. Claude 3.x, Claude Sonnet 4, and Claude Opus 4 do not support the feature.
Agno v2.7.2 uses Anthropic’s legacy
output_format beta request for this
feature. Anthropic’s generally available request shape is
output_config.format. The legacy shape remains available during the
transition period.Params
Claude is a subclass of the Model class and supports the inherited model parameters.