Skip to content

api key bach not working #4554

Closed
Closed

Description

@firmai

What version of Codex is running?

latest

Which model were you using?

No response

What platform is your computer?

No response

What steps can reproduce the bug?

%%bash

Always grab latest Codex

npm install -g @openai/codex@latest

✅ API key authentication (fake)

export OPENAI_API_KEY="sk-proj-8Dvo0_nGTvHe6fffWX8xb5HhX5s5MHBLPlfEbc22uxKkdLs8A"

Quick smoke test (should not 401)

codex exec --full-auto --skip-git-repo-check --config preferred_auth_method="apikey" "echo Codex API auth OK"

anged 1 package in 3s
[2025-10-01T15:36:50] OpenAI Codex v0.42.0 (research preview)

workdir: /content
model: gpt-5-codex
provider: openai
approval: never
sandbox: workspace-write [workdir, /tmp, $TMPDIR]
reasoning effort: none
reasoning summaries: auto

[2025-10-01T15:36:50] User instructions:
echo Codex auth OK
[2025-10-01T15:36:54] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 1/5 in 208ms…
[2025-10-01T15:36:58] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 2/5 in 420ms…
[2025-10-01T15:37:02] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 3/5 in 776ms…
[2025-10-01T15:37:06] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 4/5 in 1.546s…
[2025-10-01T15:37:11] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 5/5 in 3.374s…
[2025-10-01T15:37:18] ERROR: exceeded retry limit, last status: 401 Unauthorized
[2025-10-01T15:37:18] OpenAI Codex v0.42.0 (research preview)

workdir: /content
model: gpt-5-codex
provider: openai
approval: never
sandbox: workspace-write [workdir, /tmp, $TMPDIR]
reasoning effort: none
reasoning summaries: auto

[2025-10-01T15:37:18] User instructions:
Extract and analyze fake made up contents. Produce an HTML report with 4 creative visualizations. Save to summary_visuals.html.
[2025-10-01T15:37:21] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 1/5 in 185ms…
[2025-10-01T15:37:25] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 2/5 in 396ms…
[2025-10-01T15:37:29] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 3/5 in 801ms…
[2025-10-01T15:37:33] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 4/5 in 1.577s…
[2025-10-01T15:37:38] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 5/5 in 3.2s…
[2025-10-01T15:37:45] ERROR: exceeded retry limit, last status: 401 Unauthorized

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

Activity

  1. Aradesh3k commented on Oct 1, 2025

    @Aradesh3k

    Getting similar issues. I think the codex authorization server is down or something.

  2. dedrisian-oai commented on Oct 2, 2025

    @dedrisian-oai
    Contributor

    Just to confirm, this is latest prod or alpha? Can you attach the exact version?

  3. firmai commented on Oct 2, 2025

    @firmai
    Author

    latest prod

  4. added
    authIssues related to authentication and accounts
    on Nov 14, 2025
  5. etraut-openai commented on Dec 10, 2025

    @etraut-openai
    Contributor

    The behavior you're describing can be explained by a corrupt or incorrect API Key.

    I presume this bug report is stale, so I'm going to close.

  6. evalphobia commented on Dec 10, 2025

    @evalphobia

    I struggled this issue more than 1month.

    [2025-12-10T13:17:18] User instructions:
    hello
    [2025-12-10T13:17:22] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 1/5 in 191ms…
    [2025-12-10T13:17:26] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 2/5 in 382ms…
    [2025-12-10T13:17:30] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 3/5 in 800ms…
    [2025-12-10T13:17:35] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 4/5 in 1.568s…
    [2025-12-10T13:17:41] stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 5/5 in 3.304s…
    [2025-12-10T13:17:48] ERROR: exceeded retry limit, last status: 401 Unauthorized
    

    I solved in my situation finally.

    before v0.34

    You can use OPENAI_API_KEY envvar (I used this version)

    export OPENAI_API_KEY='sk-svcacct-...'
    codex exec -m "gpt-5.1-codex-mini" --full-auto "hello"

    after v0.36

    You should use codex login --api-key command explicitly,

    codex login --api-key "$OPENAI_API_KEY"
    codex exec -m "gpt-5.1-codex-mini" --full-auto "hello"

    after v0.46

    Use codex login --with-api-key to follow the instruction below,
    https://github.com/openai/codex/blob/main/docs/authentication.md#usage-based-billing-alternative-use-an-openai-api-key

    echo $OPENAI_API_KEY | codex login --with-api-key
    codex exec -m "gpt-5.1-codex-mini" --full-auto "hello"
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

    authIssues related to authentication and accountsbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions