Skip to content
providerkit
GitHub

StreamOptions

Defined in: core/src/types.ts:404

optional effort?: "low" | "medium" | "high" | "none" | "max";

Defined in: core/src/types.ts:417


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


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.


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).


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.


optional model?: string;

Defined in: core/src/types.ts:406

Override the provider’s bound model for this call.


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.

void


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.

Parameter Type
reading RateLimitReading

void


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.


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.


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.


optional signal?: AbortSignal;

Defined in: core/src/types.ts:438


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.


optional temperature?: number;

Defined in: core/src/types.ts:423

Not sent to Gemini, which fixes its own sampling. Same for topP.


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.