OpenAIConfig
Defined in: core/src/providers/openai.ts:40
Standard options that any provider config can accept to configure fallbacks inline.
Extends
Section titled “Extends”Properties
Section titled “Properties”allowProviderFallbacks?
Section titled “allowProviderFallbacks?”optional allowProviderFallbacks?: boolean;Defined in: core/src/providers/openai.ts:116
Set false to refuse hosts outside an explicit, nonempty OpenRouter providerOrder.
apiKey
Section titled “apiKey”apiKey: string;Defined in: core/src/providers/openai.ts:41
baseUrl?
Section titled “baseUrl?”optional baseUrl?: string;Defined in: core/src/providers/openai.ts:44
Any OpenAI-compatible endpoint. Defaults to OpenAI itself.
dataCollection?
Section titled “dataCollection?”optional dataCollection?: "allow" | "deny";Defined in: core/src/providers/openai.ts:137
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?: "low" | "medium" | "high" | "none" | "max";Defined in: core/src/providers/openai.ts:52
effortDialect?
Section titled “effortDialect?”optional effortDialect?: EffortDialect;Defined in: core/src/providers/openai.ts:58
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:109
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:103
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?: FetchLike;Defined in: core/src/providers/openai.ts:93
headers?
Section titled “headers?”optional headers?: Record<string, string>;Defined in: core/src/providers/openai.ts:96
optional id?: string;Defined in: core/src/providers/openai.ts:51
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:152
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:148
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:64
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:91
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:92
model: string;Defined in: core/src/providers/openai.ts:42
noSampling?
Section titled “noSampling?”optional noSampling?: boolean;Defined in: core/src/providers/openai.ts:155
Never send temperature or top_p. For an endpoint that fixes its own
sampling and rejects the fields (Gemini’s OpenAI-compatible route).
openRouterCost?
Section titled “openRouterCost?”optional openRouterCost?: "total" | "reported";Defined in: core/src/providers/openai.ts:122
Use only OpenRouter’s usage.cost when the host tracks BYOK inference separately.
The default includes the upstream provider’s bill when available.
openRouterDisableReasoning?
Section titled “openRouterDisableReasoning?”optional openRouterDisableReasoning?: boolean;Defined in: core/src/providers/openai.ts:119
Send reasoning.enabled: false for OpenRouter effort none. Use only with a model and
host known to accept it. Unset keeps the adapter’s per-model effort mapping.
optional path?: string;Defined in: core/src/providers/openai.ts:48
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:127
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:114
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. By default this is a preference, not a lock.
redactErrors?
Section titled “redactErrors?”optional redactErrors?: boolean;Defined in: core/src/providers/openai.ts:95
Leave the provider’s words out of every error. See PresetProviderConfig.redactErrors.
servesHostedTools?
Section titled “servesHostedTools?”optional servesHostedTools?: readonly ( | "web_search" | "web_fetch" | "code_execution" | "file_search" | "image_generation")[];Defined in: core/src/providers/openai.ts:167
For providers imported from @providerkit/core/hosted.
The hosted tools this endpoint runs. This wire has one, web search.
Defaults to it on openrouter.ai, which runs it as its own server tool,
and on api.openai.com for the -search-preview models, and to none
anywhere else: a gateway that ignores the tool answers unsearched
without saying so. A host other than OpenRouter that runs it is sent
OpenAI’s web_search_options.
serviceTier?
Section titled “serviceTier?”optional serviceTier?: ServiceTier;Defined in: core/src/providers/openai.ts:157
Default service_tier for every call; StreamOptions.serviceTier wins.
sessionHeader?
Section titled “sessionHeader?”optional sessionHeader?: string;Defined in: core/src/providers/openai.ts:141
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:107
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:103
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:107
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.