fix(provider): split providerOptions key on dot for openai-compatible, openai, and anthropic providers (#25145)

This commit is contained in:
Sewer. 2026-05-01 00:05:56 +01:00 committed by GitHub
parent 247284b9af
commit a12333310f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1058,7 +1058,20 @@ export function providerOptions(model: Provider.Model, options: { [x: string]: a
return result
}
const key = sdkKey(model.api.npm) ?? model.providerID
// AI SDK packages that resolve providerOptionsName by splitting the
// provider name on "." (e.g. "wafer.ai" -> "wafer") need the same
// logic here so the key we write matches the key they read.
// Other SDKs (xai, mistral, groq, cohere, etc.) use hardcoded keys
// like "xai" or "cohere" - applying .split(".")[0] would break those.
const usesDotSplitOptions =
model.api.npm === "@ai-sdk/openai-compatible" ||
model.api.npm === "@ai-sdk/openai" ||
model.api.npm === "@ai-sdk/anthropic"
const key =
sdkKey(model.api.npm) ??
(usesDotSplitOptions
? model.providerID.split(".")[0]
: model.providerID)
// @ai-sdk/azure delegates to OpenAIChatLanguageModel which reads from
// providerOptions["openai"], but OpenAIResponsesLanguageModel checks
// "azure" first. Pass both so model options work on either code path.