codex - 💡(How to fix) Fix Codex Desktop mixes local custom provider base_url with remote auth.json API key

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

{"error":"Invalid API key"}

Code Example

POST /v1/responses
Originator: Codex Desktop
User-Agent: Codex Desktop/0.129.0-alpha.15 (Windows 10.0.26200; x86_64)
Host: local-custom-provider.example
Authorization: Bearer remote-key...wxyz
Status: 401
{"error":"Invalid API key"}

---

### Steps to reproduce

1. Configure Codex Desktop on the local machine with a custom Responses API provider:

---

2. Configure the local machine's Codex auth file with API key A:

---

3. Use Codex Desktop with a remote workspace / remote environment that has its own Codex auth file configured with API key B:

---

4. Ensure API key A is valid for `local-custom-provider.example`, and API key B is valid for a different provider or environment.

5. From Codex Desktop, start a session that targets the local custom provider while connected to the remote workspace / environment.

6. Send any request that uses the Responses API, for example a normal chat turn.

7. Inspect the local custom provider's request logs.

8. Observe that the request is sent to the local custom provider URL, but the `Authorization` header contains API key B from the remote environment instead of API key A from the local machine.
RAW_BUFFERClick to expand / collapse

What version of the Codex App are you using (From “About Codex” dialog)?

Codex Desktop/26.506.21252 Dev

What subscription do you have?

Plus

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What issue are you seeing?

Codex Desktop appears to combine the local custom provider base_url with an API key from a remote environment's auth.json.

This does not look like a server-side issue. The local custom provider expects one API key, but Codex Desktop sends a different key that belongs to the remote active Codex environment.

Local Windows Codex config:

Remote Codex environment:

POST /v1/responses
Originator: Codex Desktop
User-Agent: Codex Desktop/0.129.0-alpha.15 (Windows 10.0.26200; x86_64)
Host: local-custom-provider.example
Authorization: Bearer remote-key...wxyz
Status: 401
{"error":"Invalid API key"}

The request URL/host is the local custom provider, but the Authorization header uses the remote active key.

What steps can reproduce the bug?

### Steps to reproduce

1. Configure Codex Desktop on the local machine with a custom Responses API provider:

```toml
model_provider = "custom"

[model_providers.custom]
name = "custom"
wire_api = "responses"
requires_openai_auth = true
base_url = "https://local-custom-provider.example/v1"
  1. Configure the local machine's Codex auth file with API key A:
{
  "OPENAI_API_KEY": "local-key...abcd"
}
  1. Use Codex Desktop with a remote workspace / remote environment that has its own Codex auth file configured with API key B:
{
  "OPENAI_API_KEY": "remote-key...wxyz"
}
  1. Ensure API key A is valid for local-custom-provider.example, and API key B is valid for a different provider or environment.

  2. From Codex Desktop, start a session that targets the local custom provider while connected to the remote workspace / environment.

  3. Send any request that uses the Responses API, for example a normal chat turn.

  4. Inspect the local custom provider's request logs.

  5. Observe that the request is sent to the local custom provider URL, but the Authorization header contains API key B from the remote environment instead of API key A from the local machine.


### What is the expected behavior?

The Authorization header should come from the same configuration scope as the selected base_url.

If Codex Desktop is sending requests to the local custom provider configured in the local Windows ~/.codex/config.toml, it should use the local Windows ~/.codex/auth.json key.

It should not use the remote environment's active OPENAI_API_KEY when the request target is the local custom provider.

### Additional information

_No response_

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING