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< onPayload(Map<String, dynamic> ?>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 anauthorization,x-api-key, orcf-aig-authorizationentry 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), ornone(nocache_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 onforceAdaptiveThinking).final - hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, String?> ? -
Extra request headers, merged over Model.headers; a
nullvalue suppresses the header with the same name (pi'sProviderHeaders).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< Function(Map<String, dynamic> ?>String, dynamic> payload, Model model)? -
Hook invoked with the fully built request payload right before sending;
return a replacement map to override it, or
nullto 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) oromitted. Sent asthinking.displaywhen thinkingEnabled is true.final - thinkingEnabled → bool?
-
Enable extended thinking. Only sent when Model.reasoning is true:
truesendsthinking: {type: 'enabled', ...},falsesends{type: 'disabled'},nullomits the parameter (provider default).final - thinkingLevel → String?
-
Thinking-level rung for the budget ladder:
minimal,low,medium,high(pi'sThinkingLevel;xhigh/maxfold tohigh). Drives the budget chosen by adjustMaxTokensForThinking;nullmeans no level requested — with thinkingEnabled true and no explicit thinkingBudgetTokens this rides theminimalrung.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