Skip to content
6 min read · 1,241 words

Interface: AnthropicMessagesAdapterOptions ​

Defined in: src/batteries/llm/anthropic_messages/types.ts:359

Configuration options for the Anthropic Messages adapter.

Properties ​

PropertyTypeDefault valueDescriptionDefined in
apiKey?stringundefinedAPI key used by the Anthropic SDK. Omit only when another SDK credential source is intended.src/batteries/llm/anthropic_messages/types.ts:361
autoAck?booleanundefinedWhether the executor acks automatically on a tool-call-free terminal answer.src/batteries/llm/anthropic_messages/types.ts:437
baseURL?stringundefinedEndpoint base URL. Defaults to the Anthropic SDK default unless overridden.src/batteries/llm/anthropic_messages/types.ts:363
bucketOrder?ChatCompletionsBucketOrderundefinedDetermines order of system-prompt content buckets in history assembly.src/batteries/llm/anthropic_messages/types.ts:421
cacheBreakpoints?AnthropicCacheBreakpointsundefinedPrompt-cache breakpoint placement mode.src/batteries/llm/anthropic_messages/types.ts:455
cacheTtl?AnthropicCacheTtlundefinedOptional TTL applied to emitted prompt-cache breakpoints.src/batteries/llm/anthropic_messages/types.ts:457
container?string | nullundefinedAnthropic container identifier for container-capable tools.src/batteries/llm/anthropic_messages/types.ts:463
contextWindow?numberundefinedSize of the model's token context window for the ADK guard.src/batteries/llm/anthropic_messages/types.ts:423
dangerouslyAllowBrowser?booleanundefinedAllows Anthropic SDK use in browser-like runtimes despite API-key exposure risk.src/batteries/llm/anthropic_messages/types.ts:453
fetch?{ (input: URL | RequestInfo, init?: RequestInit): Promise<Response>; (input: string | URL | Request, init?: RequestInit): Promise<Response>; }undefinedCustom fetch implementation, used for tests, proxies, or custom transports.src/batteries/llm/anthropic_messages/types.ts:367
headers?Record<string, string>undefinedCustom HTTP headers sent with every request.src/batteries/llm/anthropic_messages/types.ts:365
helpers?Partial<AnthropicMessagesHelpers>undefinedOptional overrides for Anthropic translation helpers.src/batteries/llm/anthropic_messages/types.ts:433
inferenceGeo?string | nullundefinedAnthropic inference geography selector.src/batteries/llm/anthropic_messages/types.ts:465
localToolCallParser?| ToolCallParserName | ToolCallParserFnundefinedOptional fallback parser for non-structural local tool-call text.src/batteries/llm/anthropic_messages/types.ts:494
maxTokensnumberundefinedRequired maximum number of output tokens to request from Anthropic.src/batteries/llm/anthropic_messages/types.ts:443
metadata?MetadataundefinedAnthropic request metadata.src/batteries/llm/anthropic_messages/types.ts:459
modelModelundefinedRequired Anthropic model identifier.src/batteries/llm/anthropic_messages/types.ts:441
onPromptAssembled?PromptAssembledObserverFnundefinedObserve the fully assembled Anthropic request before dispatch.src/batteries/llm/anthropic_messages/types.ts:492
onRawGeneration?RawGenerationObserverFnundefinedObserve the model's raw response for each completed generation.src/batteries/llm/anthropic_messages/types.ts:490
outputConfig?OutputConfigundefinedStructured-output and effort configuration sent to Anthropic.src/batteries/llm/anthropic_messages/types.ts:449
replayCompatibility?readonly string[]undefinedList of replay labels supported by this adapter.src/batteries/llm/anthropic_messages/types.ts:431
requestTimeoutMs?numberundefinedRequest timeout in milliseconds for API calls.src/batteries/llm/anthropic_messages/types.ts:373
resolveErrorStatus?AnthropicMessagesErrorStatusResolverundefined — no recovery; a statusless APIError stays fatal, preserving the behaviour of adapters built before this hook existed.Recovers an HTTP status the Anthropic SDK could not observe, so retry classification can see it. Remarks Unlike the Ollama and OpenAI batteries — which read response.status off a raw fetch and therefore always see the real code — this battery classifies from the SDK's APIError. When a gateway terminates the HTTP request itself and reports the upstream failure inside the response body, err.status is absent, is coerced to 0, matches nothing in @nhtio/adk/batteries/llm/chat_common!ChatCompletionsRetryConfig.retriableStatuses, and the error is classified fatal — so a transient upstream 529 overloaded_error fails on first occurrence with retry never consulted. The ADK deliberately ships no body parser: the shape of a gateway's error envelope is the consumer's knowledge, not the ADK's, and guessing it with a built-in regex risks reading a three-digit request id — or a genuine deterministic 4xx — as a retriable status. This hook is the seam for a consumer who does know their gateway. Called only for SDK APIErrors, before retriable/fatal classification and before the context-overflow body-text check. Return an HTTP status to classify against, or undefined to decline — declining leaves sdkStatus in force, so a resolver that does not recognise a body is a no-op rather than a hazard. A returned value outside 100–599 is ignored with a warning. The resolved status is what reaches retriableStatuses, the E_ANTHROPIC_MESSAGES_HTTP_ERROR payload, and the log line — so a recovered 529 is reported as 529, not 0. Must not throw; a throwing resolver is caught, warned about, and treated as declining. Example new AnthropicMessagesAdapter({ model, maxTokens, retry: { maxAttempts: 4 }, // This gateway reports the upstream status in the body and nowhere else. resolveErrorStatus: ({ bodyText, sdkStatus }) => { if (sdkStatus !== 0) return undefined const m = /upstream returned (\d{3})/.exec(bodyText) return m ? Number(m[1]) : undefined }, })src/batteries/llm/anthropic_messages/types.ts:419
retry?ChatCompletionsRetryConfigundefinedConfigures ADK-owned request retry behavior.src/batteries/llm/anthropic_messages/types.ts:375
selfIdentity?stringundefinedUnique identity label for the assistant instance.src/batteries/llm/anthropic_messages/types.ts:425
serviceTier?"auto" | "standard_only"undefinedAnthropic service-tier selector.src/batteries/llm/anthropic_messages/types.ts:461
spoolStore?SpoolStoreundefinedBacking store for string or bytes tool returns.src/batteries/llm/anthropic_messages/types.ts:435
stopSequences?string[]undefinedCustom stop sequences sent as stop_sequences.src/batteries/llm/anthropic_messages/types.ts:445
stream?booleanundefinedWhether to stream the response as Anthropic stream events.src/batteries/llm/anthropic_messages/types.ts:369
streamIdleTimeoutMs?numberundefinedIdle timeout in milliseconds for the stream before aborting.src/batteries/llm/anthropic_messages/types.ts:371
temperature?numberundefinedDeprecated Anthropic temperature sampling parameter. Deprecated Models released after Claude Opus 4.6 reject most values with a 400. The adapter never supplies this unless the caller sets it.src/batteries/llm/anthropic_messages/types.ts:474
thinking?ThinkingConfigParamundefinedExtended or adaptive thinking configuration sent to Anthropic.src/batteries/llm/anthropic_messages/types.ts:447
thoughtSurfacing?"all" | "all-self" | "latest-self"undefinedDetermines which thoughts are surfaced back to the model.src/batteries/llm/anthropic_messages/types.ts:427
tokenEncoding?| TokenEncodingId | nullundefinedTokenizer encoding configuration for token counting.src/batteries/llm/anthropic_messages/types.ts:429
toolCallIdFilter?ToolCallIdFilterFnundefinedOptional ingress hook for adapting provider tool-call ids; absent preserves the vendor id.src/batteries/llm/anthropic_messages/types.ts:496
toolChoice?ToolChoiceundefinedTool-choice directive sent to Anthropic.src/batteries/llm/anthropic_messages/types.ts:451
topK?numberundefinedDeprecated Anthropic top-k sampling parameter. Deprecated Models released after Claude Opus 4.6 reject every value with a 400. The adapter never supplies this unless the caller sets it.src/batteries/llm/anthropic_messages/types.ts:488
topP?numberundefinedDeprecated Anthropic nucleus-sampling parameter. Deprecated Models released after Claude Opus 4.6 reject lower values with a 400. The adapter never supplies this unless the caller sets it.src/batteries/llm/anthropic_messages/types.ts:481
unsupportedMediaPolicy?UnsupportedMediaPolicyundefinedPolicy for media whose modality the Anthropic Messages wire cannot represent.src/batteries/llm/anthropic_messages/types.ts:439
userProfileId?stringundefinedAnthropic user-profile request parameter (SDK maps this header param on the wire).src/batteries/llm/anthropic_messages/types.ts:467