Skip to content

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

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

markwaddle
Copy link

@markwaddle markwaddle commented May 21, 2025

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
Copy link

github-actions bot commented May 21, 2025

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

@markwaddle
Copy link
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
Copy link

payneio commented May 21, 2025

Nice!

@bkrabach
Copy link

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.

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.

3 participants