Azure OpenAI API-Key support for VSCode Extension

Resolved 💬 2 comments Opened Oct 13, 2025 by heyarny Closed Jan 24, 2026
💡 Likely answer: A maintainer (bolinfest, collaborator) responded on this thread — see the highlighted reply below.

What version of the VS Code extension are you using?

0.4.19

Which IDE are you using?

VS Code

What platform is your computer?

Darwin 25.0.0 arm64 arm

What steps can reproduce the bug?

As of now it seems like the only way to make the AZURE_OPENAI_API_KEY environment variable visible for the extension is to start VS Code from within the terminal.

What is the expected behavior?

Use codex in VSCode with azure api key.

What do you see instead?

Can't use the extension with azure api key when starting the default way.

Additional information

Please add a way to add an api key to the extension.
You could also use the available auth.json file setup and put the key there.

{
  "AZURE_OPENAI_API_KEY": "azure-openai-api-key-here...",
  "OPENAI_API_KEY": "openai-api-key-here.."
}

View original on GitHub ↗

2 Comments

bolinfest collaborator · 10 months ago

I don't think we documented it because we weren't sure we wanted to commit to it, but if you create a "dotenv" folder in your $CODEX_HOME, e.g., ~/.codex/.env with the environment variables, does that work?

A .env file is not JSON, but should be:

AZURE_OPENAI_API_KEY=azure-openai-api-key-here...
OPENAI_API_KEY=openai-api-key-here...

https://github.com/openai/codex/blob/fd0673e457da65f1fccb4551fe59b9df79b27d85/codex-rs/arg0/src/lib.rs#L108-L118

heyarny · 10 months ago

@bolinfest providing .env inside .codex with AZURE_OPENAI_API_KEY inside seems to work.
What also works is just having the default OPENAI_API_KEY inside auth.json, but with azure Key, which is really confusing.
You see all this tutorials on how to setup Codex Extension: https://devblogs.microsoft.com/all-things-azure/codex-azure-openai-integration-fast-secure-code-development/

There should be one dokumentation that just works "the right way" and I think OpenAI should provide that documentation.