Skip to content

fix(opencode): @ai-sdk/azure - Set default to Responses instead of Completion API#9036

Closed
OmarMcAdam wants to merge 1 commit intoanomalyco:devfrom
OmarMcAdam:dev
Closed

fix(opencode): @ai-sdk/azure - Set default to Responses instead of Completion API#9036
OmarMcAdam wants to merge 1 commit intoanomalyco:devfrom
OmarMcAdam:dev

Conversation

@OmarMcAdam
Copy link

Summary

  • add an Azure-specific model loader that switches to chat/completions based on provider options
  • keep a fallback to the default language model loader

Issue

Fixes #9035

Testing

  • bun turbo typecheck

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@OmarMcAdam OmarMcAdam changed the title fix(opencode): handle azure loader options fix(opencode): @ai-sdk/azure - Set default to Responses instead of Completion API Jan 17, 2026
Comment on lines +945 to +953
if (!modelLoaders[providerID]) {
const isAzure = Object.values(provider.models).some((model) => model.api.npm === "@ai-sdk/azure")
if (isAzure) {
modelLoaders[providerID] = async (sdk: any, modelID: string, options?: Record<string, any>) => {
const useCompletionUrls = options?.["useCompletionUrls"] === true
if (useCompletionUrls) return sdk.chat(modelID)
return sdk.responses(modelID)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure this is correct solution

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any suggestions
tried looking at other patterns but didnt find any established for specific model loaders

Comment on lines 156 to 168
"azure-cognitive-services": async () => {
const resourceName = Env.get("AZURE_COGNITIVE_SERVICES_RESOURCE_NAME")
return {
autoload: false,
async getModel(sdk: any, modelID: string, options?: Record<string, any>) {
if (options?.["useCompletionUrls"]) {
return sdk.chat(modelID)
} else {
return sdk.responses(modelID)
}
},
options: {
baseURL: resourceName ? `https://${resourceName}.cognitiveservices.azure.com/openai` : undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The useCompletionUrls option should already be respected but this raises a good point of, I think this should be auto detected better.

I do not have azure cognitive services setup to test tho

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pinging in discord with some test stuff if needed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah this is cognitive services, different system iirc

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scroll up 5 lines, normaal azure does exact same flow, so ditto

@OmarMcAdam
Copy link
Author

i am an idiot

@OmarMcAdam OmarMcAdam closed this Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@ai-sdk/azure defaults to completions api instead of responses

2 participants