Skip to content

StreamOptions

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

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

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


optional json?: JsonOutput;

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


optional jsonWithTools?: JsonWithTools;

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

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:368

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:373

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:358

Override the provider’s bound model for this call.


optional onActivity?: () => void;

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

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:424

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:431

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:439

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:404

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:390


optional stopSequences?: string[];

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

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:375

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


optional toolChoice?: ToolChoice;

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


optional topP?: number;

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

Nucleus sampling. Set this or temperature, not both. The vendors all document them as alternatives and some reject the pair outright.