Overview
The Anthropic provider gives you access to Claude models with advanced reasoning capabilities through adaptive and manual thinking modes.Installation
createAnthropic()
Create an Anthropic provider instance.Options
string
Your Anthropic API key. Defaults to
ANTHROPIC_API_KEY environment
variable.string
Custom base URL for API requests.
number
Default output limit for requests that omit
maxTokens. When unset, each
request uses the model’s output ceiling. See Output
limits.AnthropicChatClient
Provide your own configured Anthropic client instance.
Returns
AnthropicProvider with method chatModel().
Supported models
Claude Fable and Mythos (adaptive thinking)
Claude Fable and Mythos (adaptive thinking)
Claude Fable and Mythos models use adaptive thinking mode.
- claude-fable-5-1 - Current Fable model for demanding reasoning and long-horizon agentic work. Adaptive thinking is always on, and forced tool choice is rejected on every request
- claude-mythos-5-1 - Limited-access model with the same capability handling as Claude Fable 5.1
- claude-fable-5 - Widely available model for demanding reasoning and agentic work
- claude-mythos-5 - Limited-access model with the same capability handling
- claude-mythos-preview - Limited-access preview model
Claude Opus, Sonnet, and Haiku (adaptive thinking)
Claude Opus, Sonnet, and Haiku (adaptive thinking)
Current Opus, Sonnet, and Haiku models use effort-based adaptive thinking.
- claude-opus-5-5 - Current Opus model for long-running agentic coding and knowledge work. Adaptive thinking is always on
- claude-opus-5 - Opus model for complex agentic coding and enterprise work
- claude-sonnet-5-5 - Current Sonnet model for focused coding and knowledge work. Adaptive thinking is on by default, and forced tool choice is rejected on every request
- claude-sonnet-5 - Most agentic Sonnet model with near-Opus performance at lower cost
- claude-haiku-5-5 - Fast model for high-volume, latency-sensitive work. Adaptive thinking accepts max effort, and the API default effort is medium
- claude-opus-4-8 - Opus model for complex reasoning and agentic coding
- claude-opus-4-7 - Opus model with max effort support
- claude-opus-4-6 - Opus model with max effort support
- claude-sonnet-4-6 - Balanced performance and speed with max effort support
Claude 4.5 (manual thinking)
Claude 4.5 (manual thinking)
Models with manual thinking budget control.
- claude-opus-4-5 - High capability
- claude-sonnet-4-5 - Efficient reasoning
- claude-haiku-4-5 - Fast and lightweight
Claude 4 and earlier
Claude 4 and earlier
- claude-opus-4-1 - Enhanced reasoning
- claude-opus-4 - Strong performance
- claude-sonnet-4 - Balanced model
- claude-sonnet-3-7 - Previous generation
Provider support
Model capabilities
UseChatModel.capabilities to inspect the constraints for the selected model,
or call getAnthropicModelCapabilities(modelId) without creating a model:
supportedEffortslists the accepted effort levels. Models with adaptive thinking may also supportmax.modeisalways-onforclaude-opus-5-5,claude-fable-5-1, andclaude-mythos-5-1, because adaptive thinking cannot be disabled. For every other registered Claude model,modeisoptionaland reasoning is enabled by passingreasoning.restrictsSamplingParamsistrue. The exact temperature,topP, andtopKrules are described under Reasoning restrictions.supportedToolChoicesis['auto', 'none']while reasoning is enabled. Onclaude-opus-5-5,claude-sonnet-5-5,claude-fable-5-1, andclaude-mythos-5-1that restriction applies to every request, including requests that omitreasoning.modalities.inputis['text', 'image', 'file']for every Claude model. Image sources accept bothbase64andurl. File parts are PDF-only.modalities.outputis['text'].tools.strictSchemasreports whether the model supports strict tool schemas. Supported models report{ supported: true, maxStrictTools: 20, maxUnionParameters: 16 }.tools.toolDiscoveryis'native'for Claude 4.5 and later models and'emulated'for older ones. See Tool discovery.messages.systemPlacementis'before-reply'from Claude Opus 4.8, Sonnet 5, and Haiku 5.5 on, and'leading'for earlier models. See System messages.
Strict tool schemas
Claude 4.5 and later models support per-toolstrict: true and report
{ supported: true, maxStrictTools: 20, maxUnionParameters: 16 }. Both limits
count only tools that set strict: true; exceeding one throws
ToolSchemaStrictnessError
locally. The Anthropic API enforces both limits, but Anthropic’s documentation
pages do not list them:
- At most 20 strict tools (“The maximum number of strict tools supported is 20”).
- At most 16 union-typed parameters across the request’s strict tools
(“limit: 16 parameters with unions”). Every property whose schema is an
anyOf, aoneOf, or atypearray with more than one entry counts, including nullable keys, in nested objects, array items, andanyOfandoneOfbranches. Unions directly underitems,enums withnull,$defs, and the properties of an object whosetypeis an array do not count.
{ supported: false } and reject explicit strict: true locally.
Unrecognized model IDs resolve optimistically to supported, so future Claude
models work without a registry update.
Only strict tools and structured-output schemas go through Anthropic’s schema
normalization ($schema stripped, additionalProperties: false added,
numeric and length constraints removed, oneOf rewritten to anyOf).
Strict tools and structured output schemas also list nullable and defaulted
keys in required, because
Anthropic allows at most 24 optional parameters across a request’s strict
tools. Anthropic also rejects a single strict schema it finds too complex,
a limit it does not publish and core-ai cannot check.
Non-strict tools are sent with their raw JSON Schema, so declared constraints
reach the model as hints. Strict tool schemas do not change Anthropic’s
structured response format for generateObject() and streamObject(). See
Strict tool schemas for the schema
contract, error reasons, and cross-provider behavior.
Tool discovery
Claude Opus 4.5, Sonnet 4.5, Haiku 4.5, and later models reporttools.toolDiscovery: 'native', and so do unrecognized model IDs. Claude
Opus 4.1, Opus 4, Sonnet 4, Sonnet 3.7, and Claude 3.x models report
'emulated'.
Natively, discovered tools are declared as deferred tools
(defer_loading: true), and each discovery result loads them with
tool_reference blocks. Adding deferred tools keeps the cached prompt prefix,
so a discovery keeps the prompt cache. Declaring the first deferred tool does
change the prefix, so every native request also declares a deferred
placeholder tool, core_ai_deferred_tools_placeholder, which the model never
loads. Deferred loading is then active from the first request on, and the
first discovery keeps the cache too. A result that loads tools holds only
tool_reference blocks. An empty result is sent as text: its note, or that
no tools were found.
Set emulateToolDiscovery: true to declare discovered tools as ordinary tools
instead, for example behind a proxy that does not forward deferred tools or
tool_reference blocks:
System messages
Leading system messages become text blocks in Anthropic’s top-levelsystem
field. Models that report 'before-reply' also accept a system message later
in the conversation, sent in place as a role: 'system' message. It must
directly follow a user or tool message and be the last message or be followed
by an assistant message:
'leading' and
reject later system messages with
UnsupportedSystemMessagePlacementError.
Unrecognized model IDs resolve to 'before-reply'.
System messages that are empty or contain only whitespace are dropped, because
Anthropic rejects empty text blocks. One that sets cacheControl throws
ValidationError, since a cache breakpoint needs a block to attach to.
Examples
Basic chat
Extended thinking
Streaming
Tool calling
Vision and file inputs
Anthropic accepts image parts and PDF file parts. Other file MIME types are
rejected.
Thinking modes
Adaptive thinking
The model automatically determines thinking depth based on the effort level.claude-fable-5-1, claude-mythos-5-1, claude-fable-5,
claude-mythos-5, claude-mythos-preview, claude-opus-5-5,
claude-opus-5, claude-opus-4-8, claude-opus-4-7, claude-opus-4-6,
claude-sonnet-5-5, claude-sonnet-5, claude-sonnet-4-6, and
claude-haiku-5-5 support 'max' effort directly. On claude-opus-5-5,
claude-fable-5-1, and claude-mythos-5-1, thinking cannot be disabled.
Omit reasoning to use the model’s API default effort, or pass
reasoning.effort to send adaptive thinking at that level.
claude-opus-5-5 and claude-haiku-5-5 default to medium.
claude-sonnet-5-5, claude-fable-5-1, and claude-mythos-5-1 default to
high.Manual thinking budget (Claude 4.5 and earlier)
Manual-thinking models take a token budget instead of an effort level. This library maps each effort to a budget.high and max are half and three
quarters of the model’s output ceiling:
The budget is spent out of
maxTokens. If you set maxTokens (or
defaultMaxTokens) at or below the budget, the request throws a
ValidationError. The budget is never reduced to fit. Omit maxTokens to use
the model’s output ceiling, which holds every budget.
claude-opus-4-5 also accepts Anthropic’s effort parameter alongside manual
thinking. To send it, pass it through providerOptions:
Output limits
maxTokens is the total output allowance: thinking and the visible answer
together. When you omit it, the request uses the first of:
defaultMaxTokens, if you set it on the provider- The model’s output ceiling (
model.capabilities.output.maxTokens) - 4,096, for model ids without a known ceiling
Anthropic’s output-token rate limits count only generated tokens, so a high
limit does not use up rate-limit capacity.
generate() and generateObject() stream from the Messages API internally
and return the same result as a non-streaming call. The Anthropic SDK requires
streaming for requests whose output limit could take longer than ten minutes,
which applies to these ceilings. A transient error that arrives mid-stream,
such as overloaded_error, surfaces as the matching core-ai error
(ModelOverloadedError) without an automatic SDK retry.
Reasoning restrictions
When reasoning is enabled, Anthropic enforces additional request constraints:temperaturemust be omittedtopPmust be between0.95and1toolChoicemust be'auto'or'none'providerOptions.anthropic.topKmust be omitted
temperature: 1, topP: 1, and omit topK.
Claude Haiku 5.5 rejects non-default sampling parameters on every request. Set
temperature to 1 or topP to 0.99, and omit topK. A request cannot
include both temperature and topP.
Claude Opus 5.5, Claude Sonnet 5.5, Claude Fable 5.1, and Claude Mythos 5.1
reject toolChoice: 'required' and toolChoice: { type: 'tool', toolName } on
every request. 'auto' and 'none' remain valid. Claude Fable 5, Claude
Mythos 5, and Claude Haiku 5.5 accept forced tool choice when reasoning is
omitted.
Adaptive thinking automatically supports reasoning between tool calls. For
older compatible manual-thinking models, the adapter sends the
interleaved-thinking-2025-05-14 beta as an anthropic-beta header.Reasoning metadata
When reasoning is enabled, Anthropic reasoning parts include provider metadata with signature and redacted data fields. UsegetProviderMetadata to access them in a type-safe way.
AnthropicReasoningMetadata type contains:
signature— cryptographic signature for multi-turn reasoning fidelityredactedData— redacted thinking content, if present
Provider-specific options
Options are namespaced underanthropic in providerOptions:
topK, stopSequences, betas, outputConfig,
cacheControl, and emulateToolDiscovery.
betasare sent through theanthropic-betarequest header.emulateToolDiscoveryrenders tool discovery with ordinary tools on models that support it natively. See Tool discovery.
cacheControl. See
Message cache control.
Prompt caching
UsecacheControl to enable Anthropic prompt caching. This maps to Anthropic’s top-level cache_control request field and uses automatic caching for the reusable prompt prefix.
Message cache control
SetcacheControl on a system, user, tool result, or discovery result message
to place an explicit cache breakpoint at the end of that message. Each breakpoint can use
its own TTL. A common setup for agent loops caches the static system prompt for
an hour and lets request-level caching follow the growing conversation:
- A user message with string content is sent as a single text block that carries the breakpoint.
- A user message with content parts marks its last part.
- A tool result or discovery result message marks its
tool_resultblock. Consecutive tool results share one user turn, and each keeps its own breakpoint.
cacheControl must end with a non-empty part. An empty
message or an empty last text part throws ValidationError, since Anthropic
cannot place a cache breakpoint on an empty text block.
Request-level caching looks back at most 20 blocks for an earlier cache entry.
A run of consecutive tool calls or tool results counts as one block, but an
agent step that adds more blocks than that (interleaved thinking, text and
tool calls, or many images) pushes the previous step’s entry out of reach.
Mark the last message the previous step sent so the next step can read it.
That message can be a user message, a tool result, or a system message. Give
the marker a TTL at least as long as the request-level one; with request-level
ttl: '1h', set ttl: '1h' on the marker too:
- At most 4 breakpoints per request, request-level
cacheControlincluded. - A
1hbreakpoint cannot follow a5mone. Message breakpoints apply in message order, and request-levelcacheControlcomes last. - When the last message sets
cacheControl, request-levelcacheControlmust use the same TTL.
ValidationError. A missing ttl means
5m.
Anthropic reports cache usage in result.usage.inputTokenDetails:
cacheReadTokens: Tokens served from an existing cache entrycacheWriteTokens: Tokens written to the cache for future requests
- 512 tokens for Claude Opus 5.5, Claude Sonnet 5.5, Claude Fable 5.1, and Claude Mythos 5.1
- 1024 tokens for Claude Opus 4.8
- 1024 tokens for Claude Sonnet 4.5, Claude Opus 4.1, Claude Opus 4, Claude Sonnet 4, and Claude Sonnet 3.7
- 2048 tokens for Claude Sonnet 4.6
- 4096 tokens for Claude Opus 4.6, Claude Opus 4.5, and Claude Haiku 4.5
Error handling
Related
OpenAI Provider
GPT models with reasoning capabilities
Google GenAI Provider
Gemini models with multimodal support
Chat Completion Guide
Learn how to use chat completion