Skip to content

Commit a123333

Browse files
authored
fix(provider): split providerOptions key on dot for openai-compatible, openai, and anthropic providers (anomalyco#25145)
1 parent 247284b commit a123333

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

packages/opencode/src/provider/transform.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,20 @@ export function providerOptions(model: Provider.Model, options: { [x: string]: a
10581058
return result
10591059
}
10601060

1061-
const key = sdkKey(model.api.npm) ?? model.providerID
1061+
// AI SDK packages that resolve providerOptionsName by splitting the
1062+
// provider name on "." (e.g. "wafer.ai" -> "wafer") need the same
1063+
// logic here so the key we write matches the key they read.
1064+
// Other SDKs (xai, mistral, groq, cohere, etc.) use hardcoded keys
1065+
// like "xai" or "cohere" - applying .split(".")[0] would break those.
1066+
const usesDotSplitOptions =
1067+
model.api.npm === "@ai-sdk/openai-compatible" ||
1068+
model.api.npm === "@ai-sdk/openai" ||
1069+
model.api.npm === "@ai-sdk/anthropic"
1070+
const key =
1071+
sdkKey(model.api.npm) ??
1072+
(usesDotSplitOptions
1073+
? model.providerID.split(".")[0]
1074+
: model.providerID)
10621075
// @ai-sdk/azure delegates to OpenAIChatLanguageModel which reads from
10631076
// providerOptions["openai"], but OpenAIResponsesLanguageModel checks
10641077
// "azure" first. Pass both so model options work on either code path.

0 commit comments

Comments
 (0)