Claude

Configure the Claude model class, Agno's wrapper for Anthropic's Messages API.

The Claude model provides access to Anthropic's Claude models.

Parameters

ParameterTypeDefaultDescription
idstr"claude-sonnet-4-5-20250929"The id of the Anthropic Claude model to use
namestr"Claude"The name of the model
providerstr"Anthropic"The provider of the model
max_tokensOptional[int]8192Maximum number of tokens to generate in the chat completion
thinkingOptional[Dict[str, Any]]NoneConfiguration for the thinking (reasoning) process
output_configOptional[Dict[str, Any]]NoneOutput configuration sent as the output_config request parameter
temperatureOptional[float]NoneControls randomness in the model's output
stop_sequencesOptional[List[str]]NoneA list of strings that the model should stop generating text at
top_pOptional[float]NoneControls diversity via nucleus sampling
top_kOptional[int]NoneControls diversity via top-k sampling
cache_system_promptOptional[bool]FalseWhether to cache the system prompt for improved performance
extended_cache_timeOptional[bool]FalseWhether to use extended cache time (1 hour instead of default)
cache_toolsboolFalseTag the last tool definition with cache control so tool definitions are cached
system_prompt_blocksOptional[Union[List[SystemPromptBlock], Callable[[], List[SystemPromptBlock]]]]NoneMulti-block system prompt with per-block cache control, appended after the agent-built system message in the Anthropic system array. Callables are evaluated on every request, allowing dynamic per-request content in a cached system prompt
request_paramsOptional[Dict[str, Any]]NoneAdditional parameters to include in the request
betasOptional[List[str]]NoneAnthropic beta flags enabling experimental or newly released features. Betas required for skills and structured outputs are added automatically
context_managementOptional[Dict[str, Any]]NoneContext management configuration sent as the context_management request parameter
mcp_serversOptional[List[MCPServerConfiguration]]NoneList of MCP (Model Context Protocol) server configurations
skillsOptional[List[Dict[str, str]]]NoneClaude Agent Skills to enable, e.g. [{"type": "anthropic", "skill_id": "pptx", "version": "latest"}]. Adds the required beta flags automatically
citationsboolTrueAttach citations to document blocks. Suppressed automatically when structured output is active because Anthropic rejects citations together with output_format
append_trailing_user_messageOptional[bool]NoneAppend a trailing user turn after an assistant message. When None, enabled for models without prefill support and whenever effective thinking is enabled, including a request_params thinking override.
trailing_user_message_contentstr"continue"Content of the appended trailing user message
api_keyOptional[str]NoneThe API key for authenticating with Anthropic (defaults to ANTHROPIC_API_KEY env var)
auth_tokenOptional[str]NoneAuth token for the Anthropic client. Falls back to the ANTHROPIC_AUTH_TOKEN environment variable
default_headersOptional[Dict[str, Any]]NoneDefault headers to include in all requests
timeoutOptional[float]NoneRequest timeout in seconds
http_clientOptional[Union[httpx.Client, httpx.AsyncClient]]NoneCustom httpx client to use for requests
client_paramsOptional[Dict[str, Any]]NoneAdditional parameters for client configuration
clientOptional[AnthropicClient]NoneA pre-configured instance of the Anthropic client
async_clientOptional[AsyncAnthropicClient]NoneA pre-configured instance of the async Anthropic client
model_typeModelTypeModelType.MODELFunctional role of this model (MODEL, OUTPUT_MODEL, or PARSER_MODEL). Set by the agent during initialization
supports_native_structured_outputsboolFalseSet to True automatically for Claude models that support native structured outputs
supports_json_schema_outputsboolFalseTrue if the model requires a JSON schema for structured outputs
system_promptOptional[str]NoneSystem prompt from the model added to the Agent
instructionsOptional[List[str]]NoneInstructions from the model added to the Agent
tool_message_rolestr"tool"Role used for tool messages
assistant_message_rolestr"assistant"Role used for assistant messages
cache_responseboolFalseCache model responses to avoid redundant API calls during development
cache_ttlOptional[int]NoneTime-to-live for cached model responses, in seconds. If None, cache never expires
cache_dirOptional[str]NoneDirectory for cached model responses. If None, uses the default cache location
retriesint0Number of retries to attempt before raising a ModelProviderError
delay_between_retriesint1Delay between retries, in seconds
exponential_backoffboolFalseIf True, the delay between retries is doubled each time
retry_with_guidanceboolTrueRetry the model invocation with a guidance message for known errors avoidable with extra instructions
retry_with_guidance_limitint1Number of times to retry the model invocation with guidance