StreamOptions
Defined in: core/src/types.ts:404
Properties
Section titled “Properties”effort?
Section titled “effort?”optional effort?: "low" | "medium" | "high" | "none" | "max";Defined in: core/src/types.ts:417
hostedTools?
Section titled “hostedTools?”optional hostedTools?: readonly HostedTool[];Defined in: core/src/types.ts:503
Tools the model vendor runs inside its own turn: web search, web fetch,
code execution, file search, image generation. Each adapter sends them in
its dialect, or refuses one it can’t send with an invalid error before
any request, unless the tool is optional. toolChoice: "none" sends
none; a forced choice with any is refused.
Import the provider constructor from @providerkit/core/hosted first.
Plain constructors refuse this option before any request, even with
optional or toolChoice: "none"; they include no hosted codecs.
A custom Provider that can’t run them must refuse them the same way
(planHostedTools from @providerkit/core/hosted does it): ignored, they
become an answer that never searched, with nothing to say so.
optional json?: JsonOutput;Defined in: core/src/types.ts:440
jsonWithTools?
Section titled “jsonWithTools?”optional jsonWithTools?: JsonWithTools;Defined in: core/src/types.ts:445
Overrides the provider’s own setting for this call, so probeJsonWithTools
asks the same model both ways. See JsonWithTools.
maxAttempts?
Section titled “maxAttempts?”optional maxAttempts?: number;Defined in: core/src/types.ts:416
Maximum attempts at each SDK recovery layer, including the first. Must
be a positive integer. Omit to keep normal recovery. 1 prevents another
inference request through model, key, host or token fallback, keeping the
original failure and normal cooldown or credential renewal for later calls.
Values above 1 are PER LAYER, not a total HTTP budget across nested pools.
Initial token acquisition and credential refresh are not inference attempts.
App-written outer retries need their own limit (RetryOptions.maxAttempts).
maxTokens?
Section titled “maxTokens?”optional maxTokens?: number;Defined in: core/src/types.ts:421
Output ceiling. On most providers thinking and answer SHARE it, so a task emitting a large artifact must raise it or the tool-call JSON is silently truncated mid-argument.
model?
Section titled “model?”optional model?: string;Defined in: core/src/types.ts:406
Override the provider’s bound model for this call.
onActivity?
Section titled “onActivity?”optional onActivity?: () => void;Defined in: core/src/types.ts:460
Called when the response headers arrive and on every read of the body
after, keep-alives included. withWatchdog sets it: a stream that is only
sending keep-alives is alive, which no chunk an adapter yields can show.
Every adapter here forwards it; a custom Provider that does not still
works, on the watchdog’s progress clock alone.
Returns
Section titled “Returns”void
onRateLimit?
Section titled “onRateLimit?”optional onRateLimit?: (reading) => void;Defined in: core/src/types.ts:472
Called once per response whose headers report how full a subscription
window is, whatever its status: utilization (1 is full), resetAtMs,
and window when the headers name it. A caller sees the window fill
turn by turn, instead of learning about it from the 429 that ends a run.
Every adapter forwards it. Two backends send the headers today: Claude
subscriptions (Anthropic’s unified 5h/7d headers) and the ChatGPT backend
(x-codex-*). A response that reports no window never calls it, which
covers API-key accounts on every vendor and all of Gemini.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
reading |
RateLimitReading |
Returns
Section titled “Returns”void
parallelToolCalls?
Section titled “parallelToolCalls?”optional parallelToolCalls?: boolean;Defined in: core/src/types.ts:479
false asks for at most one tool call per turn, for tools that must run
in order, or a backend lane that refuses parallel calls. Absent or true
is every vendor’s default and sends nothing. Gemini has no such switch,
so it refuses false rather than silently ignore it.
serviceTier?
Section titled “serviceTier?”optional serviceTier?: ServiceTier;Defined in: core/src/types.ts:487
Which service tier to buy this call on: priority is faster and costs
more, flex is slower and costs less. Sent as service_tier on the
OpenAI and Responses shapes. Anthropic and Gemini refuse it with an
invalid error: Anthropic’s own service_tier means something else, and
Gemini has no such switch. Overrides the provider’s own setting.
sessionId?
Section titled “sessionId?”optional sessionId?: string;Defined in: core/src/types.ts:452
Stable id for the conversation or job this call belongs to. Sent in the
sessionHeader of endpoints that name one (OpenCode Go routes and caches
by it), and as prompt_cache_key on the Responses shape. A call without
one sends the provider’s instanceSessionId in that header instead.
signal?
Section titled “signal?”optional signal?: AbortSignal;Defined in: core/src/types.ts:438
stopSequences?
Section titled “stopSequences?”optional stopSequences?: string[];Defined in: core/src/types.ts:437
Strings that end the turn when generated. The only four-shape sampling
field beyond these two; top_k, metadata and the rest are one vendor’s
each and stay off the seam, where a caller reaching for them is asking for
that vendor rather than for a provider.
Not sent on the Responses shape, which has no equivalent.
temperature?
Section titled “temperature?”optional temperature?: number;Defined in: core/src/types.ts:423
Not sent to Gemini, which fixes its own sampling. Same for topP.
toolChoice?
Section titled “toolChoice?”optional toolChoice?: ToolChoice;Defined in: core/src/types.ts:439
optional topP?: number;Defined in: core/src/types.ts:428
Nucleus sampling. Set this or temperature, not both. The vendors all
document them as alternatives and some reject the pair outright.