Migrating from codex-cli to codex-rs

Resolved 💬 5 comments Opened Jun 22, 2025 by vvvlad Closed Jun 30, 2025
💡 Likely answer: A maintainer (bolinfest, collaborator) responded on this thread — see the highlighted reply below.

Im exposing o4-mini model via a project in Azure.

When using typescript version of codex (ver 0.1.2505172129) with the following config.json content, all works as expected:

{
"model": "o4-mini",
"provider": "azure",
"providers": {
"azure": {
"baseURL": "https://xxxxx.openai.azure.com/openai",
"envKey": "OPENAI_API_KEY",
"name": "azure"
}
}
}

but with rust version of codex @openai/codex@native (ver codex-cli 0.0.2505291458) with config in config.toml:

model="o4-mini"
model_provider = "azure"
[model_providers.azure]
name = "Azure Remote"
base_url = "https://xxxxx.openai.azure.com/openai"
env_key = "OPENAI_API_KEY"
wire_api = "chat"

I get:
BackgroundEvent(BackgroundEventEvent { message: "stream error: unexpected status 404 Not Found: {\"detail\":\"Not Found\"}; retrying

I tried to chang base_url to different variations, but no use, always the same result.

Is this a bug? Missing support for Azure?
Thanks

View original on GitHub ↗

5 Comments

bolinfest collaborator · 1 year ago

Hmm, that config seems like it should work...

Try setting RUST_LOG=debug (or RUST_LOG=trace for even more info) before running the Rust CLI. Assuming you are running the TUI, you can see logs by doing:

tail -F ~/.codex/log/codex-tui.log

If you use codex exec, the log messages should appear inline.

vvvlad · 1 year ago

@bolinfest
Thanks for the reply.
I looked at the logs, but there is no useful information in there as far as I can see.
Here is a relevant part

^[[2m2025-06-29T01:00:00.631850Z^[[0m ^[[35mTRACE^[[0m take? ("https", XXXX.openai.azure.com): expiration = Some(90s)
^[[2m2025-06-29T01:00:00.631864Z^[[0m ^[[34mDEBUG^[[0m reuse idle connection for ("https", XXXX.openai.azure.com)
^[[2m2025-06-29T01:00:00.925515Z^[[0m ^[[35mTRACE^[[0m put; add idle connection for ("https", XXXX.openai.azure.com)
^[[2m2025-06-29T01:00:00.925544Z^[[0m ^[[34mDEBUG^[[0m pooling idle connection for ("https", XXXX.openai.azure.com)
^[[2m2025-06-29T01:00:00.925582Z^[[0m ^[[33m WARN^[[0m stream disconnected - retrying turn (3/10 in 348ms)...
^[[2m2025-06-29T01:00:00.275731Z^[[0m ^[[34mDEBUG^[[0m POST (chat) ^[[3murl^[[0m^[[2m=^[[0m"https://XXXX.openai.azure.com/openai/chat/completions"

Any suggestions about this?

vvvlad · 1 year ago

@bolinfest
It looks like the issue might be the fact that azure expects to get request in the following format:

https://XXX.openai.azure.com/openai/deployments/XXXdeployment/chat/completions?api-version=2025-01-01-preview

but the existing post request is never appening the api-version

The deployment part can be added in config to base_url, but the api-version is not.

would be nice to have a fix for this.

bolinfest collaborator · 1 year ago

@vvvlad oh, I didn't realize we had this special logic in the TypeScript CLI:

https://github.com/openai/codex/blob/cd2d84d496158450ec25be0109016c7c70112132/codex-cli/src/utils/agent/agent-loop.ts#L334-L351

OK, I'll have to figure out how to make this configurable in a general way in the Rust CLI...

I'm tempted to add support for query_params as follows:

[model_providers.azure]
name = "Azure"
base_url = "https://xxxxx.openai.azure.com/openai"
env_key = "AZURE_OPENAI_API_KEY"  # Though you can use "OPENAI_API_KEY" if you want?
query_params = { api_version = "2025-04-01-preview" }

and to update wire_api to default to "chat", since that is the common case, in practice.

Do you think that would work for you?

bolinfest collaborator · 1 year ago

Oh, I guess that should be api-version, not api_version...