AnthropicOptions class final

Options for streamAnthropic.

Ported subset of pi's AnthropicOptions (which extends StreamOptions): temperature, maxTokens, apiKey, headers, signal, thinkingEnabled, thinkingBudgetTokens, thinkingLevel, effort, thinkingDisplay, interleavedThinking, cacheRetention, toolChoice, onPayload, onResponse. pi's signal: AbortSignal is cancelToken here. OAuth, metadata, sessionId, timeoutMs, maxRetries, and the pre-built SDK client are not ported yet.

Constructors

AnthropicOptions({double? temperature, int? maxTokens, String? apiKey, Map<String, String?>? headers, CancelToken? cancelToken, bool? thinkingEnabled, int? thinkingBudgetTokens, String? thinkingLevel, String? effort, String? thinkingDisplay, bool? interleavedThinking, String? cacheRetention, Object? toolChoice, FutureOr<Map<String, dynamic>?> onPayload(Map<String, dynamic> payload, Model model)?, FutureOr<void> onResponse(int statusCode, Map<String, String> headers, Model model)?})
const

Properties

apiKey → String?
API key sent as x-api-key: .... Falls back to an authorization, x-api-key, or cf-aig-authorization entry in headers (key then unused), else the stream fails with an error event.
final
cacheRetention → String?
Prompt-cache retention: short (default; ephemeral cache breakpoints), long (1h TTL where supported), or none (no cache_control).
final
cancelToken → CancelToken?
Cancels the in-flight request when triggered. The stream then ends with an ErrorEvent whose reason is StopReason.aborted.
final
effort → String?
Effort level for adaptive-thinking models (low, medium, high, xhigh, max). Accepted for forward compatibility; only sent once adaptive thinking lands (pi gates it on forceAdaptiveThinking).
final
hashCode → int
The hash code for this object.
no setterinherited
headers → Map<String, String?>?
Extra request headers, merged over Model.headers; a null value suppresses the header with the same name (pi's ProviderHeaders).
final
interleavedThinking → bool?
Whether to request the interleaved-thinking beta header. Default: true, per pi (adaptive-thinking models skip it, which is not ported yet).
final
maxTokens → int?
Output-token cap, sent as max_tokens. Defaults to Model.maxTokens.
final
onPayload → FutureOr<Map<String, dynamic>?> Function(Map<String, dynamic> payload, Model model)?
Hook invoked with the fully built request payload right before sending; return a replacement map to override it, or null to send it as-is.
final
onResponse → FutureOr<void> Function(int statusCode, Map<String, String> headers, Model model)?
Hook invoked once the response headers are in, before the SSE body is consumed.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
temperature → double?
Sampling temperature. Ignored when thinkingEnabled is true (extended thinking is incompatible with temperature), per pi.
final
thinkingBudgetTokens → int?
Token budget for budget-based extended thinking. Default: 1024 when thinkingEnabled is true and no budget is provided.
final
thinkingDisplay → String?
How thinking content is returned: summarized (default) or omitted. Sent as thinking.display when thinkingEnabled is true.
final
thinkingEnabled → bool?
Enable extended thinking. Only sent when Model.reasoning is true: true sends thinking: {type: 'enabled', ...}, false sends {type: 'disabled'}, null omits the parameter (provider default).
final
thinkingLevel → String?
Thinking-level rung for the budget ladder: minimal, low, medium, high (pi's ThinkingLevel; xhigh/max fold to high). Drives the budget chosen by adjustMaxTokensForThinking; null means no level requested — with thinkingEnabled true and no explicit thinkingBudgetTokens this rides the minimal rung.
final
toolChoice → Object?
Anthropic tool choice: 'auto', 'any', 'none', or a {type: 'tool', name: ...} map forcing a specific tool.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited