-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Adds Azure OpenAI support #769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds support for Azure OpenAI by allowing users to specify 'azure' as the provider. This change introduces the AzureOpenAI client and configures it with the appropriate API version. The code now checks the provider and instantiates either the OpenAI or AzureOpenAI client accordingly.
Adds support for Azure OpenAI by allowing users to specify 'azure' as the provider. This change introduces the AzureOpenAI client and configures it with the appropriate API version. The code now checks the provider and instantiates either the OpenAI or AzureOpenAI client accordingly.
Adds support for Azure OpenAI by allowing users to specify 'azure' as the provider. This change introduces the AzureOpenAI client and configures it with the appropriate API version. The code now checks the provider and instantiates either the OpenAI or AzureOpenAI client accordingly.
@thegovind Are you planning to use this PR to replace #92? |
I believe so. Curious how this is coming along and if there’s anything the community can do to support your efforts here. Have been following this closely and am anxious to get a hold of this to compare performance with Claude Code. |
@jslitzkerttcu I ran some tests. Claude Code is miles ahead; Codex didn't even come close to catching its tail lights! |
Nice thank you. Now that it is getting a bit more complicated, as part of this change, could you refactor the client instantiation so that we consistently instantiante it the same way across all the different callsites? Concretely, extract all the
to a common file / function and use that one everywhere. |
Sounds good. I'll work on this later tonight/tomorrow and update this PR |
Refactors the creation of OpenAI and AzureOpenAI clients into a single `createOpenAIClient` function. This change promotes code reuse and simplifies configuration across different components.
Alright, @tibo-openai - updated this PR accordingly. Please confirm and merge. |
@thegovind Thank you for pushing this! Many of us truly appreciate it. Looking forward to this being in main. |
@parasgoyal12 Hope you will approve and merge this soon. |
@tibo-openai - is it something you could possibly help with by any chance? Would greatly appreciate |
@theabhinavdas @nikodem-wrona @fouad-openai @tibo-openai This would be awesome if merged. Really looking forward to being able to use it. |
7d3f666
to
f015c63
Compare
@thegovind thank you for the PR! for me using provider settings as described did not work ootb - i needed to append '/openai' to azure url, ie:
without '/openai' in baseURL i would keep getting 404s. when using |
Thank you, @mzagar! That's actually what I have in my local |
@fouad-openai and @jslitzkerttcu - thank you for approving the PR. Could you please merge this now? |
I wish I could! I was just clicking around hoping it would help push things along but I do not have write access :( @fouad-openai - it's all you! @bolinfest also merged quite a bit yesterday if it requires a second person with write access - perhaps one of you could assist here? |
sorry for delay! thought i'd merged too, making a few changes this evening then will cut a release. thanks again @thegovind! |
Summary
This PR introduces support for Azure OpenAI as a provider within the Codex CLI. Users can now configure the tool to leverage their Azure OpenAI deployments by specifying
"azure"
as the provider inconfig.json
and setting the correspondingAZURE_OPENAI_API_KEY
andAZURE_OPENAI_API_VERSION
environment variables. This functionality is added alongside the existing provider options (OpenAI, OpenRouter, etc.).Related to #92
Note: This PR is currently in Draft status because tests on the
main
branch are failing. It will be marked as ready for review once themain
branch is stable and tests are passing.What’s Changed
config.ts
,providers.ts
,README.md
):"azure"
to the supportedproviders
list inproviders.ts
, specifying its name, default base URL structure, and environment variable key (AZURE_OPENAI_API_KEY
).AZURE_OPENAI_API_VERSION
environment variable inconfig.ts
with a default value (2025-03-01-preview
).README.md
to:AZURE_OPENAI_API_KEY
,AZURE_OPENAI_API_VERSION
) with examples.terminal-chat.tsx
,singlepass-cli-app.tsx
,agent-loop.ts
,compact-summary.ts
,model-utils.ts
):provider
is"azure"
.AzureOpenAI
client from theopenai
package is instantiated, using the configuredbaseURL
,apiKey
(fromAZURE_OPENAI_API_KEY
), andapiVersion
(fromAZURE_OPENAI_API_VERSION
).OpenAI
client is instantiated as before.openai
package's built-in support forAzureOpenAI
. No new external dependencies were added specifically for this Azure implementation beyond theopenai
package itself.How to Test
This has been tested locally and confirmed working with Azure OpenAI.
config.json
:Ensure your
~/.codex/config.json
(or project-specific config) includes Azure and sets it as the active provider:Clone your fork, checkout this branch (
feat/azure-openai
), navigate tocodex-cli
, and build:Run the locally built CLI using
node
from thecodex-cli
directory:node ./dist/cli.js "Explain the purpose of this PR"
pnpm link
after building, you can usecodex "Explain the purpose of this PR"
from anywhere).Tests
Checklist
providers.ts
,config.ts
).AzureOpenAI
client initialization based on provider setting.apiVersion
is passed correctly to the Azure client.README.md
with Azure OpenAI setup instructions.main
stability).cc @theabhinavdas @nikodem-wrona @fouad-openai @tibo-openai (adjust as needed)
I have read the CLA Document and I hereby sign the CLA