Bug when I send a first message "stream error: ..."

Resolved 💬 65 comments Opened Jul 8, 2025 by dam62500 Closed Sep 7, 2025
💡 Likely answer: A maintainer (yusuf-eren, contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

0.3.0

Which model were you using?

codex-mini-latest

What platform is your computer?

MacOS

What steps can reproduce the bug?

1 ) codex login
2 ) codex
3 ) type prompt -> enter

What is the expected behavior?

send "Hello"
Expect to get "Hello" from Codex Mini

What do you see instead?

user
say "hello"

event
BackgroundEvent(BackgroundEventEvent {
message: "stream error: stream disconnected before completion: stream closed before response.completed; retrying 1/10 in 191ms…"
})

event
BackgroundEvent(BackgroundEventEvent {
message: "stream error: stream disconnected before completion: stream closed before response.completed; retrying 2/10 in 239ms…"
})

event
BackgroundEvent(BackgroundEventEvent {
message: "stream error: stream disconnected before completion: stream closed before response.completed; retrying 3/10 in 362ms…"
})

event
BackgroundEvent(BackgroundEventEvent {
message: "stream error: stream disconnected before completion: stream closed before response.completed; retrying 4/10 in 461ms…"
})

Additional information

_No response_

View original on GitHub ↗

65 Comments

dam62500 · 1 year ago
  • workdir: /home/dflandrin/PhpstormProjects/test-codex-cli
  • model: codex-mini-latest
  • provider: openai
  • approval: UnlessTrusted
  • sandbox: read-only
  • reasoning effort: medium
  • reasoning summaries: auto
aristoHero · 1 year ago

Same problem for me.
This happened when I updates to v0.3.
node v22.17.0 ubuntu 24.04

yusuf-eren contributor · 1 year ago

hey @dam62500 , what is your Node.js version?

dam62500 · 1 year ago

@yusuf-eren node v18.16.0 on Mac ( 2019 / Intel )
Don't work too with Windows 11, node v20.18.0. ( same problem )

GiladR1979 · 1 year ago

Same, with node v20.13.1 on mac

yusuf-eren contributor · 1 year ago

I tested it on v18.16.0, v20.18.3, v22.16.0. Also tried uninstalling and clean installing via brew install codex, but still couldn't reproduce the bug.

Are you using a config.toml file? It should be located at ~/.codex/config.toml
See: config docs

If so, could you share its contents?

LiutongZhou · 1 year ago

Same issue. Same version and OS

Enderboi · 1 year ago

Having the same issue on MacOS / Darwin 24.3.0.
No config.toml exists, just the auth.json,

It looks like this error is actually being triggered from submission of the (initial internally-generated) API Key creation request, NOT the user specified prompt. So this probably won't occur if you are connected to an Organisation with an existing API key, I would recommend testing if the issue is reproducable from a fresh OpenAI account - perhaps at least a fresh Org.

Sample from the codex-tui.log file:

2025-07-08T18:24:14.288188Z INFO Configuring session: model=codex-mini-latest; provider=ModelProviderInfo { name: "OpenAI", base_url: "https://api.openai.com/v1", env_key: Some("OPENAI_API_KEY"), env_key_instructions: Some("Create an API key (https://platform.openai.com) and export it as an environment variable."), wire_api: Responses, query_params: None, http_headers: Some({"version": "0.3.0", "originator": "codex_cli_rs"}), env_http_headers: Some({"OpenAI-Organization": "OPENAI_ORGANIZATION", "OpenAI-Project": "OPENAI_PROJECT"}) }
2025-07-08T18:24:16.099177Z WARN stream disconnected - retrying turn (1/10 in 211ms)...
2025-07-08T18:24:17.657017Z WARN stream disconnected - retrying turn (2/10 in 276ms)...
2025-07-08T18:24:19.706377Z WARN stream disconnected - retrying turn (3/10 in 364ms)...
2025-07-08T18:24:21.013135Z WARN stream disconnected - retrying turn (4/10 in 471ms)...
2025-07-08T18:24:22.278961Z WARN stream disconnected - retrying turn (5/10 in 544ms)...
2025-07-08T18:24:23.432097Z WARN stream disconnected - retrying turn (6/10 in 808ms)...
2025-07-08T18:24:24.947856Z WARN stream disconnected - retrying turn (7/10 in 1.052s)...
2025-07-08T18:24:26.719088Z WARN stream disconnected - retrying turn (8/10 in 1.358s)...
2025-07-08T18:24:28.690865Z WARN stream disconnected - retrying turn (9/10 in 1.591s)...
2025-07-08T18:24:32.318628Z WARN stream disconnected - retrying turn (10/10 in 2.221s)...
2025-07-08T18:24:35.114276Z INFO Turn error: stream disconnected before completion: stream closed before response.completed

PiotrKlimczak · 1 year ago

same here

bNTyARH1NeSTX · 1 year ago

same

jkbrlw · 1 year ago

I have the same issue node: v22.7.0, Ubuntu 24. I didn't have config.toml, so I created one according to the docs. This is what I have currently:

model_provider = "openai"
model = "gpt-3.5-turbo"
http_headers = { }

[model_providers.openai]
name = "OpenAI"
base_url = "https://api.openai.com/v1"
env_key = "OPENAI_API_KEY"

but nothing changed. It is essencially the same as gpt-4 and the codex-mini:

2025-07-08T21:56:43.069851Z  INFO Configuring session: model=gpt-4; provider=ModelProviderInfo { name: "OpenAI", base_url: "https://api.openai.com/v1", env_key: Some("OPENAI_API_KEY"), env_key_instructions: Some("Create an API key (https://platform.openai.com) and export it as an environment variable."), wire_api: Responses, query_params: None, http_headers: Some({"version": "0.3.0", "originator": "codex_cli_rs"}), env_http_headers: Some({"OpenAI-Project": "OPENAI_PROJECT", "OpenAI-Organization": "OPENAI_ORGANIZATION"}) }
2025-07-08T21:56:54.875488Z  WARN stream disconnected - retrying turn (1/10 in 184ms)...
2025-07-08T21:56:55.886712Z  WARN stream disconnected - retrying turn (2/10 in 241ms)...
2025-07-08T21:56:56.441631Z  WARN stream disconnected - retrying turn (3/10 in 361ms)...
2025-07-08T21:56:57.123050Z  WARN stream disconnected - retrying turn (4/10 in 444ms)...
2025-07-08T21:56:58.573299Z  WARN stream disconnected - retrying turn (5/10 in 623ms)...
2025-07-08T21:56:59.483054Z  WARN stream disconnected - retrying turn (6/10 in 788ms)...
2025-07-08T21:57:00.572255Z  WARN stream disconnected - retrying turn (7/10 in 924ms)...
2025-07-08T21:57:01.801383Z  WARN stream disconnected - retrying turn (8/10 in 1.308s)...
2025-07-08T21:57:03.393756Z  WARN stream disconnected - retrying turn (9/10 in 1.772s)...
2025-07-08T21:57:05.435836Z  WARN stream disconnected - retrying turn (10/10 in 2.248s)...
2025-07-08T21:57:07.963374Z  INFO Turn error: stream disconnected before completion: stream closed before response.completed
jagcardenas · 1 year ago

still unresolved?

devMtn30 · 1 year ago

I also get the same error. I'll show you the scenarios I tried below

1.npm install -g @openai/codex
2.codex login
3.codex
4.'hello world'
5.stream error: stream disconnected before completion: stream closed before response.completed
yonathanarbel · 1 year ago

same

weiting-tw · 1 year ago

same

devMtn30 · 1 year ago
I also get the same error. I'll show you the scenarios I tried below `` 1.npm install -g @openai/codex 2.codex login 3.codex 4.'hello world' 5.stream error: stream disconnected before completion: stream closed before response.completed ``

I found that the following message was displayed after codex login: Sorry, your subscription must be active for more than 7 days to redeem credits.

cammymcp · 1 year ago

I also encountered this issue on a newly created platform account, linking it to a longstanding ChatGPT identity. I suspect the CLI is failing on the attempt to redeem free credit on Pro/Plus accounts. Likely on the 7 day minimum account age check.

When I switched the CLI to use an older API key on another account, it started working.

GiladR1979 · 1 year ago

Well it turns out I only needed to put something in my Organization Balance for it to work.

timsehn · 1 year ago
Well it turns out I only needed to put something in my Organization Balance for it to work.

I tried adding money to my organization balance and this did not resolve for me.

timsehn · 1 year ago

I also generated a new key, not using codex login and tried setting OPENAI_API_KEY to that. It still resulted in the stream error on first prompt.

PiotrKlimczak · 1 year ago

I have added money to my org and it didn’t fix anything for me.
Now I can’t even spend the money I added!
Tried codex login multiple times. Tried env var. Deleted many times .codex from home dir. Nothing helps.

yonathanarbel · 1 year ago

My issue was resolved by adding money; the error message is not informative but when I downgraded to an older version, I got a more informative one. I'm also charged for the first tokens even though I'm on a data-sharing agreement, but that's for another time.

clarkio · 1 year ago

I've been getting this issue as well. I'm not entirely sure but I think it may be due to not verifying your organization here: https://platform.openai.com/settings/organization/general. This seems to be needed to access any of OpenAI's modern models however I've used them before in other context's without having to verify so it's confusing. Personally I'm reluctant to verify (sharing photo of government ID) just for briefly testing out Codex CLI right now.

Enderboi · 1 year ago

I think you're onto something there clarkio... but it seems they're using that LinkedIn spin-off that doesn't honour the nuances of regional and national differences in identity documents.... I don't have a current passport, so now I'm stuck.

A) Please just use my countries (AU in this case but it applies to all nations of the world I'm sure) well documented and maintained by the Federal Government DVS (Document Verification System). Either use localised national standards... or don't implement the ID requirement, please for the love of $DIETY_WHO_CREATED_THIS_SIMULATION...
(sure sure, you'll have to use different DVS/KYC backends for each country but like.... use CoPilot or something :P)

B) Don't Dark Pattern the UX. The workflow first made me add funds to buy some API credit, and only after that did it inform me I need to prove my ID to use them. You've taken money and immediately afterwards refused to provide a service - bad show old bean..

timsehn · 1 year ago

Verifying my organization fixed it as well

laricko · 1 year ago

Same problem.
If you have a paid OpenAI account, run the following to start the login process: that's what they say on https://github.com/openai/codex but it seems they are trying to get you with openai API account. Hope they fix it soon.

NJersyHiro · 1 year ago

Yesterday it worked well but today this error occured.

GiladR1979 · 1 year ago
Same problem. If you have a paid OpenAI account, run the following to start the login process: that's what they say on https://github.com/openai/codex but it seems they are trying to get you with openai API account. Hope they fix it soon.

That's a little misleading because you need to fund your Organization anyway to use the API. Right?

caleb-kan · 1 year ago

same here

LeandroLS · 1 year ago

same problem here

joshuabeny1999 · 1 year ago

Have the same issue. Wanted to try it locally due i have my repo not on github.

NJersyHiro · 1 year ago

I finally get it now. I was mistaken in thinking that a paid ChatGPT subscription would let me use the API freely. It turns out you actually have to pay for API usage on the OpenAI API Platform. It seems this error shows up when you don't have enough credits.

joshuabeny1999 · 1 year ago

@NJersyHiro But then the readme is misleading. As i understand with a Plus/Pro Subscription no API credits should be needed. Readme says either set openapi token or if you have Plus/Pro use the login method.

devkiloton · 1 year ago

I was using version 0.4.0, and having the same issue.

After downgrading with npm i @openai/codex@0.2.0 I was able to see more detailed error messages.

< _In my case_ > Even though I had OpenAI credits available, my organisation was not verified.

event
BackgroundEvent (BackgroundEventEvent { message: "stream error: unexpected status 400 Bad Request: {\n \"error\":
i\n
\"message)": \"Your organization must be verified to generate reasoning summaries. Please go to:
https://platform.openai.com/settings/organization/general and click on Verify Organization. If you just verified, it can take up to 15 minutes for access to propagate.\", \n \"typel": \"invalid_request_error\"
\"param)": \"reasoning-summary)"
', \n \"code\": \"unsupported_value\"\n J\n}; retrying 2/10 in 280ms..."

5 minutes after the verification process and I was able to run everything just fine.

NJersyHiro · 1 year ago
@NJersyHiro But then the readme is misleading. As i understand with a Plus/Pro Subscription no API credits should be needed. Readme says either set openapi token or if you have Plus/Pro use the login method.

Yes, the README is misleading.
The codex login command is intended only to provide a simpler authentication process; it doesn't mean that a Plus/Pro plan grants free or unlimited API usage.
In fact, as you can see during the authentication flow, the following message is displayed: "Codex CLI will receive a token that allows it to generate API keys and consume API credits."

AdarshAgrawal · 1 year ago
I was using version 0.4.0, and having the same issue. After downgrading with npm i @openai/codex@0.2.0 I was able to see more detailed error messages. < _In my case_ > Even though I had OpenAI credits available, my organisation was not verified. event BackgroundEvent (BackgroundEventEvent { message: "stream error: unexpected status 400 Bad Request: {\n \"error\": i\n \"message)": \"Your organization must be verified to generate reasoning summaries. Please go to: https://platform.openai.com/settings/organization/general and click on Verify Organization. If you just verified, it can take up to 15 minutes for access to propagate.\", \n \"typel": \"invalid_request_error\" \"param)": \"reasoning-summary)" ', \n \"code\": \"unsupported_value\"\n J\n}; retrying 2/10 in 280ms..." 5 minutes after the verification process and I was able to run everything just fine.

Verifying Organization resolved this issue for me. Thank you @devkiloton

OneTrueJASH · 1 year ago

I'm using v0.4.0 and was experiencing the same issue. Credit to @clarkio, about 5-10 minutes after organization verification, everything was working as expected.

oaj · 1 year ago

same issue

trukhinyuri · 1 year ago

Topping up my OpenAI Platform balance solved the immediate problem, but I’m disappointed that an unlimited Codex plan is not included in the OpenAI Pro subscription. While debugging a simple application I spent about €250+ on pay‑as‑you‑go Codex requests and eventually had to stop using the model altogether. Could you please reconsider this policy? At present Codex feels as impractical as a metered internet connection; an unlimited option—similar to what some other providers offer—would make it genuinely useful.

Underwater008 · 1 year ago

Same issue, 0.5.0.

Underwater008 · 1 year ago
Topping up my OpenAI Platform balance solved the immediate problem, but I’m disappointed that an unlimited Codex plan is not included in the OpenAI Pro subscription. While debugging a simple application I spent about €250+ on pay‑as‑you‑go Codex requests and eventually had to stop using the model altogether. Could you please reconsider this policy? At present Codex feels as impractical as a metered internet connection; an unlimited option—similar to what some other providers offer—would make it genuinely useful.

Claude is cheaper and works out of the box.

ElhoumYassine · 1 year ago

What the point to log in using plus credentials if we need to buy API credits.

youvalv · 1 year ago

same issue 0.7

yaochaoutokyo · 1 year ago

same issue

mrz1836 · 1 year ago

Same issue :(

esan0 · 1 year ago

Are any of the devs going to chime in here?

  1. Can codex or can codex not be used without identity verification?
  2. Are there or are there not models available to use that don't require identity verification?
  3. Is it or is it not the solution to OP's issue to verify identity?
pingssgp · 12 months ago

Same issue with codex-cli 0.8.0

powerOFMAX · 12 months ago

Same issue, not working even with credits in the account

asv2001 · 12 months ago

Me too

marcos-paulucci · 12 months ago

Same

IvanAquino · 12 months ago

I had the same issue until I find out that my credits were expired, I didn't know that the have to be used before 1 year

HunterHillegas · 11 months ago

I'm seeing this as well.

  • macOS 26 beta 4
  • Codex CLI v0.10
  • Multiple models: o3, codex-mini-latest
  • Organization has been long verified
  • Plenty of budget in the account

Getting this OFTEN.

SimonSchroffner · 11 months ago

same

archodev · 11 months ago

I am seeing this as well, on the latest version sharing my ChatGPT Plus subscription usage

tengocj · 11 months ago

same here wthelly

aristoHero · 11 months ago

I updated to the latest version and I have logged in again with my chatgpt sub. Now cli works fine.
Make sure that you have gpt-5 model as the model. There might be some issue where non gpt-5 models still require an api key

vitaliy-sk · 11 months ago

I had the same issue. It was fixed after I removed some variables from my .env file that I had used before (OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_MODEL).

tengocj · 11 months ago

I also logged in with my normal account and it was fine but when I went back and used my api key I got hit with the rate limit quite frequently

tengocj · 11 months ago

this popped up a few times as well
▌ ● Working (52s • Ctrl C to interrupt) [INFO codex_tui::chatwidget] BackgroundEvent: stream error: stream disconnected before completion: stream closed before

clarkio · 11 months ago

Quick update from my last message here...

As of today after updating to version 0.20.0 I was able to successfully log in via OAuth with both a personal and work/team account without having to verify my org by sharing a government ID.

For folks just catching up on this the last version I tested was <= 0.5.0. In those versions login would fail for me. After some digging into errors I found a message regarding verifying the organization associated to my account (this happened for both personal and work/team accounts). In order to do that I would have to upload/share a government ID via a third-party partner and I did not believe that should be necessary so I stopped there. Thankfully this is no longer the case.

So if you've run into issues with logging in previously, try updating to the latest version (npm i -g @openai/codex), use codex login and follow the OAuth flow to see if you get better results now.

QualityRobD · 11 months ago

Yep same in WSL. Using an enterprise account but aside from that it's setup the same.

v0.20.0 as well, so the latest available version.

  1. I can auth into the CLI but any calls are met wtih that streaming error.
  2. Our organization is verfified so it's not that the issue
himomohi · 11 months ago

I finally solved it!!!! 🎉
The problem was that OpenAI’s API settings were stored in the shell. Once I deleted all those values, completely removed Codex (including the .codex folder), and reinstalled it, it worked.
Instead of running codex login, just type codex to connect and log in.

cuongzdn · 10 months ago
I had the same issue. It was fixed after I removed some variables from my .env file that I had used before (OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_MODEL).

How to avoid it, In my project I have the same config .env but it should not be applied for codex cli

lshoo · 10 months ago

I got errors like:

stream error: error sending request for url (https://chatgpt.com/backend-api/codex/responses); retrying 3/5
in 867ms

The codex version is: 0.30.0
OS: Ubuntu 24.04 in win + wsl2

pakrym-oai contributor · 10 months ago
I had the same issue. It was fixed after I removed some variables from my .env file that I had used before (OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_MODEL).

We have fixed the issue with .env loading in the 0.30.

I'm going to close this issue as many problems enchanted here has been solved. Please file a new issue if things still don't work for you.