Skip to content

Conversation

@markusylisiurunen
Copy link
Contributor

Added azure-openai-responses using the OpenAI SDK’s AzureOpenAI client, with Azure auth + endpoint/resource resolution and optional deployment overrides. We clone OpenAI Responses models into an Azure provider during generation and set baseUrl: "" so runtime requires an Azure endpoint or resource name, which avoids accidental OpenAI defaults. Deployment names are treated as model IDs by default, but azureDeploymentName or AZURE_OPENAI_DEPLOYMENT_NAME lets you override when your deployment names differ. Tests and docs were updated across ai and coding-agent.

return (h2 >>> 0).toString(36) + (h1 >>> 0).toString(36);
}

const DEFAULT_AZURE_API_VERSION = "2025-04-01-preview";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm honestly not sure about this. Azure's documentation is extremely confusing, and I haven't been able to find any clear resources on this.

Here's one: https://learn.microsoft.com/en-us/azure/ai-foundry/openai/api-version-lifecycle

But when I try setting the path /openai/v1 as the base URL and removing the API version, I just get an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is now much better: 9f0b2fe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should also be fairly consistent with how Vercel AI SDK does this.

@markusylisiurunen
Copy link
Contributor Author

This might fix #886 as well.

@badlogic
Copy link
Owner

We are duplicating a lot of code between openai-reponses.ts, openai-responses-codex.ts and this new responses implementation. Do you have the time to fix that up by adding an openai-responses-shared.ts, that pulls in the the shared functions where possible?

If not, this PR will have to wait until after the great refactor.

@markusylisiurunen
Copy link
Contributor Author

We are duplicating a lot of code between openai-reponses.ts, openai-responses-codex.ts and this new responses implementation. Do you have the time to fix that up by adding an openai-responses-shared.ts, that pulls in the the shared functions where possible?

If not, this PR will have to wait until after the great refactor.

I'll see if I can continue working on this a bit tomorrow. Extracting the shared functions between openai-responses.ts and azure-openai-responses.ts should be fairly straightforward since they use the same OpenAI SDK client. Do you think it would be enough to share as much as possible between these two, or do you want to unify the openai-responses-codex.ts provider at the same time before merging this? That one seems to use a custom raw fetch implementation against the API, and has some ChatGPT-specific checks in place.

@badlogic
Copy link
Owner

@markusylisiurunen if we can share the SDK code for all the responses impls (openai, openai-codex, azure), that'd be ideal. I have not yet looked into the overlap for actual endpoint calls between SDK and the fetch impl. My guess is there's not much of a difference.

@markusylisiurunen
Copy link
Contributor Author

@badlogic Yeah I agree, I just need to stop being lazy. I'll continue on this later today.

@markusylisiurunen
Copy link
Contributor Author

markusylisiurunen commented Jan 22, 2026

@badlogic How does this look to you now? I ran the test suite with Azure OpenAI, OpenAI, and Codex OAuth; all passed. Also tested with pi and didn't encounter any issues.

# Conflicts:
#	packages/ai/CHANGELOG.md
#	packages/ai/src/providers/openai-responses.ts
@badlogic
Copy link
Owner

Merged to main via rebase.

@badlogic badlogic closed this Jan 24, 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.

2 participants