Skip to content

feature: Supports Entra/AD auth for Azure OpenAI - #1062

Closed
markwaddle wants to merge 6 commits into
openai:mainfrom
markwaddle:markwaddle/azure-openai-entra-auth
Closed

markwaddle wants to merge 6 commits into
openai:mainfrom
markwaddle:markwaddle/azure-openai-entra-auth

Conversation

@markwaddle

@markwaddle markwaddle commented May 21, 2025 •

Copy link
Copy Markdown

This PR adds support for Azure Entra (formerly Azure AD) authentication for the Codex CLI when connecting to Azure OpenAI services.

Changes

  • Added support for Azure Entra authentication via @azure/identity dependency, allowing users to authenticate using Azure credentials without requiring an explicit API key
  • Added support for configuring Azure OpenAI deployment names, allowing for cases where deployment names differ from model names
  • Updated documentation in README to clarify Azure authentication options
  • Improved proxy handling for both OpenAI and Azure connections
  • Removed prompt for OpenAI API key on startup when another provider is specified by the user
  • Refactored agent-loop.ts to use shared OpenAI client creation logic in openai-client.ts
  • Made AZURE_OPENAI_API_KEY optional when using Azure provider (falls back to Entra auth)

Dependencies

  • Added @azure/identity version ^4.10.0 to package.json

These changes enable users who work with Azure OpenAI services in enterprise environments where Azure Entra authentication is required.

Fixes issue #1056

- uses Entra/AD auth if azure API key is not set
- supports AZURE_OPENAI_DEPLOYMENT to specify deployment name
- refactors agent-loop to use `createOpenAIClient`
- supports HTTPS_PROXY, from the implementation in agent-loop
If provider is not openai
@github-actions

github-actions Bot commented May 21, 2025 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@markwaddle

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request May 21, 2025
@payneio

payneio commented May 21, 2025

Copy link
Copy Markdown

Nice!

@bkrabach

Copy link
Copy Markdown

This is great! A big help for those of us with policy that prevents use of API keys but want to leverage Codex CLI at work.

@robotdad robotdad mentioned this pull request May 21, 2025
@markwaddle

markwaddle commented May 31, 2025 •

Copy link
Copy Markdown
Author

@fouad-openai hello! i noticed that you helped with the integration of #769 (Adds Azure OpenAI Support). any advice on getting this improvement integrated as well?

@codex-maintainers

Copy link
Copy Markdown

Thanks for the contribution! We're primarily focused on the native/Rust implementation of Codex CLI and would love to see if this is still an issue on the latest version. If it is, we're happy to take a look at a PR to the codex-rs/ implementation.

@github-actions github-actions Bot locked and limited conversation to collaborators Aug 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants