OpenAIConfig
Defined in: core/src/providers/openai.ts:33
Standard options that any provider config can accept to configure fallbacks inline.
Extends
Section titled “Extends”Properties
Section titled “Properties”apiKey
Section titled “apiKey”apiKey: string;Defined in: core/src/providers/openai.ts:34
baseUrl?
Section titled “baseUrl?”optional baseUrl?: string;Defined in: core/src/providers/openai.ts:37
Any OpenAI-compatible endpoint. Defaults to OpenAI itself.
dataCollection?
Section titled “dataCollection?”optional dataCollection?: "allow" | "deny";Defined in: core/src/providers/openai.ts:121
OpenRouter’s provider.data_collection. "deny" routes only to hosts
that, by OpenRouter’s records, don’t train on the prompt; a model with no
such host answers 404 instead of falling back to one that does. It is not
zero retention: some of those hosts keep prompts for a while, which only
OpenRouter’s separate zdr rules out. Sent on OpenRouter only, with or
without a pin; any other host never sees it. Unset leaves the account’s
own setting in charge.
effort?
Section titled “effort?”optional effort?: "none" | "low" | "medium" | "high" | "max";Defined in: core/src/providers/openai.ts:45
effortDialect?
Section titled “effortDialect?”optional effortDialect?: EffortDialect;Defined in: core/src/providers/openai.ts:51
Which spelling of “think this hard” this endpoint accepts. Inferred from
id; set it when the gateway is not named after its dialect, or to off
for one that rejects the field outright.
fallbackOptions?
Section titled “fallbackOptions?”optional fallbackOptions?: FallbackOptions<Provider>;Defined in: core/src/fallback.ts:94
Custom cooldown or telemetry options for the fallback pool.
Inherited from
Section titled “Inherited from”ProviderFallbackConfig.fallbackOptions
fallbacks?
Section titled “fallbacks?”optional fallbacks?: readonly FallbackCandidate[];Defined in: core/src/fallback.ts:88
Secondary and tertiary providers to try if this provider fails/exhausts:
hand-built Providers, preset-id FallbackSpecs, or both.
Inherited from
Section titled “Inherited from”ProviderFallbackConfig.fallbacks
fetchImpl?
Section titled “fetchImpl?”optional fetchImpl?: (input, init?) => Promise<Response>;Defined in: core/src/providers/openai.ts:86
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
RequestInfo | URL |
init? |
RequestInit |
Returns
Section titled “Returns”Promise<Response>
headers?
Section titled “headers?”optional headers?: Record<string, string>;Defined in: core/src/providers/openai.ts:87
optional id?: string;Defined in: core/src/providers/openai.ts:44
Names the provider in errors and logs (“openrouter”, “deepseek”, …). It
also picks the effort dialect below, unless effortDialect overrides.
initiatorHeader?
Section titled “initiatorHeader?”optional initiatorHeader?: boolean;Defined in: core/src/providers/openai.ts:136
Send X-Initiator: user when the last message is the user’s, else
agent. GitHub Copilot bills a premium request per user turn and lets
the agent’s own follow-ups (tool results) ride free.
instanceSessionId?
Section titled “instanceSessionId?”optional instanceSessionId?: string;Defined in: core/src/providers/openai.ts:132
The id sessionHeader carries when a call has no sessionId. Absent, the
adapter mints one when it is built. Pass one when something rebuilds the
adapter (withKeyPool and withToken build one per attempt): each build
mints a new id, and a gateway that pins a session to one upstream host
then treats every call as a new session, re-routes it and misses its
prompt cache. Ignored without sessionHeader.
jsonMode?
Section titled “jsonMode?”optional jsonMode?: "object" | "schema";Defined in: core/src/providers/openai.ts:57
schema sends a json_schema response format, object plain JSON mode.
Defaults to schema for OpenAI itself and object everywhere else, which
is the only setting every gateway accepts.
jsonWithTools?
Section titled “jsonWithTools?”optional jsonWithTools?: JsonWithTools;Defined in: core/src/providers/openai.ts:84
How a json request rides when the SAME call also carries tools.
response_format (the default) sends both, which is what the shape
documents and what most models honour. prompt drops the response format
from those calls only and sends the schema as prompt instead: the shape the
Anthropic adapter has always used, and the reason this failure cannot
happen there.
It needs a knob because a model that cannot serve both does not say so. Its decoder is pinned to the schema, the tool call has nowhere to go, and the model writes the announcement instead (“let me look that up for you”) and the turn ends looking like a model with no initiative rather than a request that made the call impossible. Nothing is logged, because nothing failed.
Measured 2026-09-07, one request, sampled: z-ai/glm-5.3-flash called its
tool 0/10 under a response format and 8/8 without one, z-ai/glm-5.3 0/5,
deepseek-v4-flash-0731 0/5, gemini-3.8-flash 3/10, while
gemini-3.5-flash-lite, gpt-5.6-luna and qwen3.8-flash were 10/10.
No default is right for everyone, which is why this stays a setting rather
than becoming a rule: the same run put qwen3.8-flash at 1/6 with the
schema in the prompt against 6/6 with the response format. Don’t guess it
from the model card. probeJsonWithTools asks the model itself, in one
call. StreamOptions.jsonWithTools overrides this per call.
maxTokens?
Section titled “maxTokens?”optional maxTokens?: number;Defined in: core/src/providers/openai.ts:85
model: string;Defined in: core/src/providers/openai.ts:35
noSampling?
Section titled “noSampling?”optional noSampling?: boolean;Defined in: core/src/providers/openai.ts:139
Never send temperature or top_p. For an endpoint that fixes its own
sampling and rejects the fields (Gemini’s OpenAI-compatible route).
optional path?: string;Defined in: core/src/providers/openai.ts:41
Path appended to baseUrl. Defaults to /v1/chat/completions. Set /chat/completions when the base already includes the API version, such as a gateway using /v4 rather than /v1.
pinHost?
Section titled “pinHost?”optional pinHost?: boolean;Defined in: core/src/providers/openai.ts:111
Automatically pin OpenRouter calls to the first-party model vendor’s host when hitting openrouter.ai and providerOrder is not passed. Defaults to true.
providerOrder?
Section titled “providerOrder?”optional providerOrder?: string[];Defined in: core/src/providers/openai.ts:106
Pin OpenRouter to preferred upstream hosts so the PROMPT CACHE stays warm across rounds. The cache lives on the upstream host’s account and default routing hops between them. Every hop is a cold cache, with worse latency and higher effective input cost. Fallbacks stay on: this is a preference, not a lock.
serviceTier?
Section titled “serviceTier?”optional serviceTier?: ServiceTier;Defined in: core/src/providers/openai.ts:141
Default service_tier for every call; StreamOptions.serviceTier wins.
sessionHeader?
Section titled “sessionHeader?”optional sessionHeader?: string;Defined in: core/src/providers/openai.ts:125
Header that carries StreamOptions.sessionId. When set and a call has
no sessionId, the provider’s own per-instance id rides instead, so the
gateway never sees a call without one.
siteName?
Section titled “siteName?”optional siteName?: string;Defined in: core/src/providers/openai.ts:98
App name for OpenRouter’s rankings, sent as X-Title. See siteUrl.
siteUrl?
Section titled “siteUrl?”optional siteUrl?: string;Defined in: core/src/providers/openai.ts:94
App attribution for OpenRouter’s rankings. The site URL rides as
HTTP-Referer, the app name as X-Title. Public, not secret. Sent
whenever set (other vendors ignore unknown headers); an explicit entry
in headers always wins.
watchdog?
Section titled “watchdog?”optional watchdog?: WatchdogOptions;Defined in: core/src/fallback.ts:92
Watch every candidate separately. A silent candidate then times out and rotates; wrapping the completed pool would abort the whole chain instead. Fallback specs inherit this unless they set their own watchdog.