Repository navigation
fix(ai): only send store on chat completions for OpenAI and Azure - #57239
Conversation
There was a problem hiding this comment.
I found nothing blocking. I built request bodies on the base and with this change. A generic OpenAI-compatible model (Sarashina-style) sent store: false on the base and now leaves store out. Native OpenAI and Azure chat still send store: false. In packages/ai, the tests pass with AWS_REGION unset and the type check passes. test/session-runner-recorded.test.ts in packages/core also passes.
Public API: unchanged. No config, SDK, HTTP or plugin surface changes. The only behaviour change is that Chat Completions requests leave out store unless compatibility.supportsStore is true.
Side effect, not blocking: on generic OpenAI-compatible providers, providerOptions.store is now silently ignored. Users can't opt back in from config either, because supportsStore isn't in the config compatibility schema (#52617). The provider body setting still works as an escape hatch.
Related: #52617
Partially addresses #57230 (the
storehalf;stream_optionsis left for a follow-up).The Chat Completions protocol sent
store: falseto every provider unless it was on a hardcoded non-standard list. Strict OpenAI-style APIs reject unknown body fields with a 400, so any provider missing from the list broke (Sarashina in #57230; also Cerebras, Upstage, the Gemini compat endpoint, and LiteLLM proxies in front of non-OpenAI backends, which raiseUnsupportedParamsErrorunlessdrop_paramsis set).No mainstream Chat Completions API stores by default: OpenAI's documented default is
false, and Azure stored completions were opt-in. OpenAI does have an org-level API call logging setting that can store requests that omitstore, so OpenAI and Azure keep getting an explicitstore: false.Changes:
detectSupportsStoreis now an allowlist: provideropenai/azure, or anapi.openai.com/ Azure OpenAI host (*.openai.azure.com,*.cognitiveservices.azure.com,*.services.ai.azure.com). Everything else omitsstore.compatibility.supportsStorestill overrides detection either way.supportsStore: falseentries are dropped from providers, since false is now the detected default."store":falseremoved from their recorded request bodies; responses are unchanged.Testing:
bun testinpackages/ai: all pass except the two Bedrock PDF cassettes, which fail only because of the host'sAWS_REGION; they pass with it unset.bun run typecheckinpackages/ai.store(even withproviderOptions.store),supportsStore: trueopts in, generic provider onapi.openai.comsends it, Azure sends it.Requested by: @rekram1-node (Aiden Cline via Slack)