anthropic
A Claude model through the Messages API.
anthropic("claude-sonnet-5") needs no limits: they come from spec/models/anthropic.v1.json, verified against the Anthropic Models API. Pass it as agent({model: anthropic("claude-sonnet-5")}).
Import from @threads/anthropic (TypeScript) or threads.anthropic (Python).
function anthropic(model: string, options?: {
maxInputTokens?: number;
maxOutputTokens?: number;
maxTokens?: number;
params?: JsonObject;
price?: Price;
hostedTools?: readonly JsonObject[];
apiKey?: string | Secret;
baseUrl?: string;
fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
}): ModelParameters
modelstringrequiredThe provider's exact model id. Matched against spec/models/anthropic.v1.json by string equality only; a snapshot id keeps a long-lived thread on one model.
maxInputTokens / max_input_tokensnumberThe most input tokens one request may carry; compaction and the input billing bound use it. Pinned as policy.models[].context_window. Omitted: the catalog entry's value; a model id the catalog doesn't list needs it.
maxOutputTokens / max_output_tokensnumberThe most output tokens the model can produce in one response. Pinned in policy.models. Omitted: the catalog entry's value; a model id the catalog doesn't list needs it.
maxTokens / max_tokensnumberThe per-request output cap, pinned as params.max_tokens (the pinned prompt prefix) and sent as max_tokens. Output-token budgets read it. Omitted: min(8192, max_output_tokens); a long answer continues in a new request. Above max_output_tokens is invalid_config.
paramsJsonObjectOther Messages API request fields (temperature, reasoning and the like), pinned in the system prompt. A field the adapter derives from the render, or the cap, is invalid_config. Omitted: none.
pricePriceNano-currency units per token, pinned in policy.models; a cost budget needs it. Omitted: cost is unknown.
hostedTools / hosted_toolsreadonly JsonObject[]Provider-executed tools, sent as given and pinned in the system prompt: web search and web fetch (web_search_YYYYMMDD, web_fetch_YYYYMMDD) only; any other is hosted_tool_unsupported. Omitted: none.
citationsboolPython only. Enables citations on documents (an adapter setting, pinned in the system prompt). Omitted: off.
apiKey / api_keystring | SecretThe API key: a secret() or a string. Omitted: secret("ANTHROPIC_API_KEY"). Resolved on the host at setup (check() or the first run); unset is missing_secret naming the option and the variable. Never pinned or logged.
baseUrl / base_urlstringThe API base URL. Omitted: the SDK's default endpoint.
fetch(input: string | URL | Request, init?: RequestInit) => Promise<Response>TypeScript only. Seam: the fetch the SDK sends through (a proxy, a test server); the run's fence wraps it either way. Omitted: globalThis.fetch.
Returns
Throws ConfigError with one of these codes: hosted_tool_unsupported, invalid_config, missing_secret.