Skip to content

Remote compaction fails with 401 'Incorrect API key' (sk-svcacct) for ChatGPT-authenticated users #48232

Closed as duplicate

Description

@sethusehitch

What happened

Remote compaction fails with a 401. The rejected key is an OpenAI service-account key (sk-svcacct-…), but that key isn't configured anywhere on the client. The session shows "Compaction interrupted" followed by "Reconnecting 2/…".

Error running remote compact task: unexpected status 401 Unauthorized: Incorrect API key provided: sk-svcac***…fvMA. You can find your API key at https://platform.openai.com/account/api-keys., url: https://chatgpt.com/backend-api/codex/responses, cf-ray: a40d8b075ce54801-SJC, request id: f7192488-dccb-430c-a65f-d5884bb4228c

Why this looks server-side

  • The client is logged in with ChatGPT (auth_mode: chatgpt in ~/.codex/auth.json, and OPENAI_API_KEY there is null).
  • OPENAI_API_KEY is not set in the environment.
  • No custom model_provider or env_key is set in config.toml.
  • A second user on a different machine and account hit the same error at the same time.

So the sk-svcacct key seems to belong to the backend's remote-compaction path, and it's being rejected.

Environment

  • codex-cli 0.157.0
  • macOS (Darwin 25.4.0)
  • Auth: ChatGPT login

Steps to reproduce

Use a ChatGPT-authenticated Codex session until auto-compaction triggers.

Expected

Compaction succeeds, or at least doesn't fail with an unrelated service-account key.

IDs for tracing

  • request id: f7192488-dccb-430c-a65f-d5884bb4228c
  • cf-ray: a40d8b075ce54801-SJC

Activity

  1. added
    bug
    CLI
    auth
    context
    on Sep 25, 2026
  2. github-actions commented on Sep 25, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. rafaself commented on Sep 25, 2026

    @rafaself

    Same as related in #48230

  4. MrrKirill commented on Sep 25, 2026

    @MrrKirill

    same

  5. AlexanderMorou commented on Sep 25, 2026

    @AlexanderMorou

    Same here. Windows 10 through WSL 2. Debian image.

  6. mo-mew commented on Sep 25, 2026

    @mo-mew

    Seeing the same issue here, and in my case it is not limited to remote compaction or resuming an existing thread, 2 sessions interrupted, and completely new Codex sessions fail as well.

    The sequence is:

    Reconnecting 1/5...
    stream disconnected before completion: websocket closed by server before response.completed

    and then

    unexpected status 401 Unauthorized: Incorrect API key provided: sk-svcac***fvMA
    url: https://chatgpt.com/backend-api/codex/responses
    cf-ray: a40d952299f1d284-FRA
    request id: 86bbd2cf-2f76-43f5-99d3-3077fe87679d

    Notably, the rejected sk-svcac...fvMA credential appears to be the same one reported by other users, despite requests going through different Cloudflare locations.

    Fresh sessions fail immediately, so this looks broader than a stale/resumed-thread authentication state.

  7. andkondev commented on Sep 25, 2026

    @andkondev

    Same here:

    Image
  8. shinch2844-ops commented on Sep 25, 2026

    @shinch2844-ops

    I can reproduce this on Windows, and in my case it is also not limited to an existing/resumed thread.

    Environment / checks:

    • Windows 11 x64
    • Codex CLI: 0.149.0-alpha.4.1
    • codex login status => Logged in using ChatGPT
    • OPENAI_API_KEY and CODEX_API_KEY are not set at Process/User/Machine scope
    • Codex is routed through a local bridge at http://127.0.0.1:17841/v1
    • Bridge health check http://127.0.0.1:17841/healthz returns HTTP 200
    • A completely fresh Codex chat fails
    • Switching to a ChatGPT Web model also fails

    Current error:

    unexpected status 401 Unauthorized: Incorrect API key provided: sk-svcac***fvMA
    url: http://127.0.0.1:17841/v1/responses
    cf-ray: a40d9ba48c526cea-ICN
    request id: 9ac3ba09-4607-4bbf-8d28-55cbd2d1ad7a
    

    The masked credential suffix fvMA matches the credential reported by other users in this issue. Since fresh sessions fail immediately and local ChatGPT/API-key environment variables are absent, this appears broader than compaction/resume state and is consistent with the other reports here.

  9. Xipong commented on Sep 25, 2026

    @Xipong

    same

  10. ZhouWeihua2008 commented on Sep 25, 2026

    @ZhouWeihua2008

    Another occurrence of the same issue.

    Observed error (API key redacted):

    Error running remote compact task: unexpected status 401 Unauthorized:
    Incorrect API key provided: sk-svcac***...fvMA.
    url: https://chatgpt.com/backend-api/codex/responses
    cf-ray: a40d94f5fd011ee0-LAX
    request id: 6543c6cb-0c22-4940-b81f-c2847005fa00
    

    This was reported from a Windows user using ChatGPT/Codex. The error surfaced specifically during a remote compact task. The rejected credential appears to be the same service-account-style key family described in this issue, rather than a user-supplied key.

    Additional trace IDs for backend investigation:

    • request id: 6543c6cb-0c22-4940-b81f-c2847005fa00
    • cf-ray: a40d94f5fd011ee0-LAX

    Exact Codex client version was not captured at the time of the failure.

  11. Anthony-Access commented on Sep 25, 2026

    @Anthony-Access

    same on codex cli last

  12. samuraicobra commented on Sep 25, 2026

    @samuraicobra
    Image Codex Version 26.924.20706 Released Sep 25, 2026
  13. 7 remaining items

  14. LukasNel commented on Sep 25, 2026

    @LukasNel

    same issue

  15. svre-mc commented on Sep 25, 2026

    @svre-mc

    same

  16. etraut-openai commented on Sep 25, 2026

    @etraut-openai
    Contributor

    Thanks for reporting. We're aware of the problem. Investigation is underway.

  17. DemFlax commented on Sep 25, 2026

    @DemFlax

    Same issue here. ChatGPT login, no API key configured.

    Error: unexpected status 401 Unauthorized: Incorrect API key provided: sk-svcac***…fvMA
    url: https://chatgpt.com/backend-api/codex/responses
    cf-ray: a40dae24df4dcfca-MAD
    request id: 48881aa0-5e37-4a33-af6c-0d80be15ad6d
    OS: Windows 11
    Region: Madrid, Spain

  18. yuyangzhang-young commented on Sep 25, 2026

    @yuyangzhang-young

    Same here
    Codex CLI 0.157.0 (standalone installer), WSL2 Ubuntu on Windows

    Request IDs:

    • e6c44a64-c156-4f87-bbb3-58637af50b11
    • 79afd33a-d687-45e8-8b85-778540d24e16
    • baa41483-c419-4657-890f-2cd36b642e1b
  19. FantaSeaAI commented on Sep 25, 2026

    @FantaSeaAI

    Same here.
    Request id: 9ccbb34e-fe45-4aca-b137-5cd4598603d9

  20. self9dmin commented on Sep 25, 2026

    @self9dmin

    Same issue here, started today. Same rejected key suffix (fvMA).

    unexpected status 401 Unauthorized: Incorrect API key provided: sk-svcac***…fvMA
    url: https://chatgpt.com/backend-api/codex/responses
    request id: c84c711c-0b86-47f0-86d8-93878c972213

    Signed in with ChatGPT, no API key configured on my side.

  21. jegirard commented on Sep 25, 2026

    @jegirard

    Yep me too

  22. LUIGIVAMPER commented on Sep 25, 2026

    @LUIGIVAMPER

    Same error here (key also ends in fvMA) on a fresh session (sending it a "hello" as initial message) in the Codex extension for Cursor.

    unexpected status 401 Unauthorized: Incorrect API key provided: sk-svcac***********************************************************************************************************************************************************fvMA. You can find your API key at https://platform.openai.com/account/api-keys., url: https://chatgpt.com/backend-api/codex/responses, cf-ray: a40db5b9cc259a2e-ORD, request id: ec37939c-9769-4e08-a133-d91c283fbc2d

    At the same time, ChatGPT web in Work mode fails with "Error in message stream" after ~1m of thinking. ChatGPT login (Pro), OPENAI_API_KEY unset, and codex logout + codex login didn't help.

  23. ctechfl1 commented on Sep 25, 2026

    @ctechfl1

    unexpected status 401 Unauthorized: Incorrect API key provided: sk-svcac***********************************************************************************************************************************************************fvMA. You can find your API key at https://platform.openai.com/account/api-keys., url: https://chatgpt.com/backend-api/codex/responses, cf-ray: a40dc24269c833e0-MIA, request id: 203b7417-7fd7-4eeb-a58b-37940cc270ac

  24. mrinalmishra commented on Sep 25, 2026

    @mrinalmishra

    Same error here, and it is not limited to compaction: it also fails on the
    first message of a brand-new thread.

    Request IDs (25 Sep 2026):

    • 7eadf844-758e-4a95-b29a-02c2186fdfb7 (cf-ray a40d8885c80cf4a2-ORD)
    • d99edd5a-9739-4fab-aa61-61b3b9b8c411 (cf-ray a40da36a1c97b0fc-ORD)
    • f863e099-1cb8-45f5-8fa3-fd5150b2a410 (cf-ray a40db15edc0690c6-ORD),
      first message of a new thread
  25. christianahjemiyo commented on Sep 25, 2026

    @christianahjemiyo

    same here.

  26. SirGinshi commented on Sep 25, 2026

    @SirGinshi

    Same error here

    Codex on Windows 11, signed in with ChatGPT, no API KEY
    Relogin doesnt helps

    unexpected status 401 Unauthorized: Incorrect API key provided: sk-svcac***********************************************************************************************************************************************************fvMA. You can find your API key at https://platform.openai.com/account/api-keys., url: https://chatgpt.com/backend-api/codex/responses, cf-ray: a40dcbe9ab38bb44-FRA, request id: a3191e25-e002-4e93-8de2-9b003d98fa87

  27. jegirard commented on Sep 25, 2026

    @jegirard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIauthbugcontext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions