Cannot use Azure OpenAI with Codex – no_kv_space / “stream disconnected before completion” on every request

Resolved 💬 2 comments Opened Dec 17, 2025 by noestelar Closed Dec 17, 2025
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

codex-cli 0.71.0

What subscription do you have?

API Key based Azure OpenAI

Which model were you using?

gpt-5.2

What platform is your computer?

Darwin 25.1.0 arm64 arm

What issue are you seeing?

When using Azure as the provider for Codex, every request fails with a streaming error, even for trivial prompts like “hello”.
The UI shows “stream disconnected before completion”, and the underlying trace from Azure contains no_kv_space, which indicates a failure inside the Azure/OpenAI backend rather than an invalid request from the client.​
Using the same Azure resource and model outside Codex (direct API / SDK) works as expected, so the issue seems specific to the Codex–Azure integration path.​

<img width="1176" height="330" alt="Image" src="https://github.com/user-attachments/assets/a86fd160-aa7e-45c5-833a-9355a4469ccc" />

<img width="1336" height="255" alt="Image" src="https://github.com/user-attachments/assets/247013ce-df90-47e0-958f-263a81968d2b" />

What steps can reproduce the bug?

  1. Configure Codex to use Azure OpenAI (set OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_VERSION, and select the Azure deployment as the model).
  1. Start a new Codex session.
  1. Send a very simple request, e.g. hello or “Explain this codebase”.
  1. Wait for the response.

What is the expected behavior?

Codex should stream a normal completion from the Azure OpenAI deployment, just as it does with the non-Azure OpenAI endpoint.

Additional information

The request starts but fails mid-stream with a message similar to:

“stream disconnected before completion” (or equivalent error message in the Codex UI).

Azure’s trace includes no_kv_space indicating the backend GPU KV-cache runs out of capacity and aborts the request, while still returning HTTP 200 on the outer response.​

This happens consistently for all prompts, including very small ones, making Azure effectively unusable as a provider.

View original on GitHub ↗

2 Comments

etraut-openai contributor · 8 months ago

This appears to be an error on the Azure backend, not something that OpenAI can fix. Please report the problem to the Azure team at Microsoft.

supernitin · 8 months ago

I'm also facing this issue with gpt-5.2. Other gpt-5x models are working fine for me on azure openai. Frustrating that Azure can not be tested by the codex team.