anthropic
Package
Section titled “Package”@ai-sdk/anthropic
Factories
Section titled “Factories”AIProviders.anthropic
Capabilities
Section titled “Capabilities”- Language
- Evaluation
- Decision
- Files
- Skills
Haiku 5.5, decisions, and stream metadata
Section titled “Haiku 5.5, decisions, and stream metadata”Haiku 5.5 supports adaptive thinking, xhigh effort and a 128k maximum output. Budget thinking is converted to adaptive with a compatibility warning; sampling is rejected. Explicit disabled thinking remains valid at supported effort levels. Unsupported models no longer warn for an explicit strict: false tool.
Streaming consumers can inspect .custom(kind: "anthropic.message_start", ...) for initial provider usage and response identity. Replaying anthropic.fallback adds the required server-side fallback beta. decisionModel(...) uses the native structured-output adapter; see Decision.
Set ProviderSettings.batchResultDownloads to bound downloaded JSONL rows. Unicode custom header values remain on Anthropic AWS/Bedrock requests but are excluded from canonical signed headers.
Batch providerOptions.anthropic.anthropicBeta must be an array of strings. Omit it when no beta is needed; explicit null, a single string, or mixed-type arrays fail before network I/O. Cache control shares its four-breakpoint limit across prompt blocks and tool definitions. A part’s cache marker takes precedence over a message marker on the same block and counts only once.
Citations and tool transcripts
Section titled “Citations and tool transcripts”Generated text and streamed text-end parts expose normalized AICitation values for document pages, character ranges, content blocks, web-search results, and search-result locations. Read TextGenerationResult.citations for all cited text blocks. The complete original citation objects remain in the text part’s provider metadata; document offsets describe the source document and do not become generated-text offsets. Batch results use available citation titles and file IDs with a plain-text document fallback because original prompt documents are unavailable.
Retrieved web-search results remain standalone sources. Citations do not add duplicate sources when search results are present; citation-only responses still expose fallback sources, emitted before the stream finishes.
toolChoice: ["type": "none"] keeps tool definitions in the request. Manual thinking: enabled changes required or named tool choices to automatic with a warning; a named choice retains only its selected tool. Adaptive or disabled thinking retains supported forced choices. Tool transcripts can replay provider-referenced files in tool results and JSON/error-JSON tool-search failures.
Incomplete streams and the native response boundary
Section titled “Incomplete streams and the native response boundary”Nonempty text, reasoning or tool input that ends before the provider’s
message_stop finishes as interrupted; partial content remains available.
An explicit stop retains its mapped finish reason. The native API ends one
logical response and cancels its HTTP body at the first message_stop, even
if the server leaves the body open. Unlike the JavaScript codec, it does not
consume additional Messages responses from the same body. A multi-message
session would require a separate explicit lifecycle contract.
Anthropic mirrors upstream 4.0.88 across Messages, files, and skills: thinking, citations, cache control, hosted/provider-defined tools, streamed code-execution input subtypes, fallbacks: default beta routing, caller metadata replay for client/server tools and web-search results across generated and streamed responses, Claude Opus 5 and forward-compatible Claude capabilities, structured-output tool safeguards, reasoning-token usage details, and provider metadata. Advisor tools map per-inference maxTokens and replay stopReason; stream parsing rejects spliced message IDs while tolerating duplicate starts for the active message; code-execution transcripts retain their complete prompt-cache-compatible wire shape. Generic adaptive reasoning requests include display: summarized. Generated response blocks retain upstream order across reasoning, text, citations, sources, tool calls/results, and compaction; signed/redacted thinking and text citation metadata are preserved. Mid-conversation system-message toolChanges map to tool-addition/removal content blocks with automatic beta headers, while initial-system changes warn and are ignored; toolChanges-only empty text does not consume an invisible cache breakpoint. thinking: disabled is forwarded and incompatible xhigh/max effort is lowered with a warning. Files and skills clients add the required Anthropic beta headers. The language wrapper also implements durable Batch V4 start/status/result streaming with strict response validation, redirect-safe JSONL retrieval, per-item terminal failures, and programmatic deferred-result replay without leaking the internal discriminator. Current Batch parity forwards the full request setting/content surface, preserves native counts and raw status, isolates invalid or unknown result items, safely encodes returned skill identifiers, and warns because completion webhooks are unsupported. The 4.0.49 delta adds Fable 5.1 and Vertex Claude 4 recognition, mid-conversation clearAt and effort, updated adaptive display and binding-only thinking behavior, plus the context-management, structured-outputs, interleaved-thinking, and web-search beta headers. Streaming multipart file bodies remain JS-specific because the Swift file client accepts buffered Data. The 2026-09-20 pass adds the 20260318 web tools and deferred lifecycle, normalizes implicit code execution, preserves custom aliases, and exposes a Messages-backed Evaluation V4 adapter. The 2026-09-27 pass adds Claude Opus 5.5 and Fable 5.1 recognition, computerToolset_20260801, current structured-output safeguards, and compaction, toolset, and effort behavior. The 2026-10-04 pass adds Sonnet 5.5 between_tools thinking, replayable native fallback markers, historical missing-caller normalization, and lossless toolset action replay. The 2026-10-11 pass: Claude Haiku 5.5 adaptive thinking, sampling, structured output and effort behavior is recognized; message_start provider metadata is retained. Batch downloads accept a positive maxLineBytes limit, defaulting to 64 MiB. The 2026-10-18 pass: Text blocks and stream endings expose normalized citations while retaining complete raw provider citation metadata. Retrieved web results remain independent sources with citation fallback only when retrieval is absent. Manual thinking downgrades forced tools; none preserves tool definitions. Tool-result file references and tool-search error/cache replay follow the current Messages protocol. The 2026-10-23 pass: Compatible Messages configuration supports provider-specific media/cache/sampling behavior; batch beta options reject explicit null. The 2026-10-25 pass: Nonempty unfinished Messages output reports interrupted; explicit provider stops/errors retain their mapped semantics and metadata.
Factory argument requirements are defined by the public Swift factory signatures. Use Public symbols when you need the exact initializer or factory declaration.
Return to the provider matrix.