createAnthropicModelProvider
Purpose and behavior
Section titled “Purpose and behavior”Create a reusable provider for the Anthropic Messages API, with tool calls, thinking replay, streaming and optional prompt caching. createAgent() rejects an agent model without maxOutputTokens or with reasoning minimal. Each request is sent once, with no retry.
Complete example and detailed rules.
Parameters and properties
Section titled “Parameters and properties”optionsRequiredAnthropicModelProviderOptionsAPI key, base URL, request bounds and system-prompt caching. Unknown options fail with code configuration.options.apiKeyRequiredstringExplicit Anthropic API key sent in x-api-key; no CLI account or host credential discovery.options.baseUrlOptionalstring | undefinedMessages API base URL including its version prefix, default https://api.anthropic.com/v1; messages is appended. Credentials, query or fragment fail with code configuration.options.cacheSystemOptionalboolean | undefinedAdds an ephemeral cache breakpoint on the system text, default false. Requests without system instructions then fail with code configuration; a cache hit is not guaranteed.options.timeoutMsOptionalnumber | undefinedRequest deadline in milliseconds, default 120000, at most 2147483647. While streaming it restarts on each received chunk; expiry rejects with code timeout.options.maxResponseBytesOptionalnumber | undefinedMaximum response body in bytes after decompression, default 8388608 (8 MiB); a streamed response counts all its chunks. A larger response fails with code response.