Repository navigation
Adds Azure OpenAI support - #769
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.jsonand setting the correspondingAZURE_OPENAI_API_KEYandAZURE_OPENAI_API_VERSIONenvironment 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
mainbranch are failing. It will be marked as ready for review once themainbranch is stable and tests are passing.What’s Changed
config.ts,providers.ts,README.md):"azure"to the supportedproviderslist inproviders.ts, specifying its name, default base URL structure, and environment variable key (AZURE_OPENAI_API_KEY).AZURE_OPENAI_API_VERSIONenvironment variable inconfig.tswith a default value (2025-03-01-preview).README.mdto: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):provideris"azure".AzureOpenAIclient from theopenaipackage is instantiated, using the configuredbaseURL,apiKey(fromAZURE_OPENAI_API_KEY), andapiVersion(fromAZURE_OPENAI_API_VERSION).OpenAIclient is instantiated as before.openaipackage's built-in support forAzureOpenAI. No new external dependencies were added specifically for this Azure implementation beyond theopenaipackage 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:{ "providers": { // ... other providers "azure": { "name": "AzureOpenAI", "baseURL": "https://YOUR_RESOURCE_NAME.openai.azure.com", // Replace with your Azure endpoint "envKey": "AZURE_OPENAI_API_KEY" } }, "provider": "azure", // Set Azure as the active provider "model": "o4-mini" // Use your Azure deployment name here // ... other config settings }Clone your fork, checkout this branch (
feat/azure-openai), navigate tocodex-cli, and build:Run the locally built CLI using
nodefrom thecodex-clidirectory:node ./dist/cli.js "Explain the purpose of this PR"pnpm linkafter building, you can usecodex "Explain the purpose of this PR"from anywhere).Tests
Checklist
providers.ts,config.ts).AzureOpenAIclient initialization based on provider setting.apiVersionis passed correctly to the Azure client.README.mdwith Azure OpenAI setup instructions.mainstability).cc @theabhinavdas @nikodem-wrona @fouad-openai @tibo-openai (adjust as needed)
I have read the CLA Document and I hereby sign the CLA