401 Unauthorized from v0.dev API when using Codex CLI (`--provider vercel`)

Resolved 💬 3 comments Opened Jun 15, 2025 by loaishar Closed Aug 7, 2025

What version of Codex is running?

v0.1.2505172129

Which model were you using?

Codex

What platform is your computer?

_No response_

What steps can reproduce the bug?

401 Unauthorized from v0.dev API when using Codex CLI (--provider vercel)

Account / Plan

  • v0.dev account email: loai1@…
  • Plan: <Premium / Team> ← (confirm what Billing shows)
  • API key last 4 chars: ...eT3 (begins v1:)

---

| Config path | /home/<user>/.codex/config.json (see contents below) |

~/.codex/config.json

{
  "providers": {
    "vercel": {
      "name": "Vercel",
      "baseURL": "https://api.v0.dev/v1",
      "envKey": "V0_API_KEY"
    }
  }
}
````

**Session Reproduction**

```bash
export V0_API_KEY="v1:2n................................................3"
codex --provider vercel --model v0-1.0-md --verbose

CLI output

● OpenAI Codex (research preview) v0.1.2505172129
...
POST https://api.v0.dev/v1/chat/completions
→ 401 Unauthorized
⚠️  OpenAI rejected the request. Status: 401, Message: "Unauthorized"

Direct cURL test

curl -s -o /dev/null -w "%{http_code}\n" \
  -H "Authorization: Bearer $V0_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"v0-1.5-md","messages":[{"role":"user","content":"ping"}]}' \
  https://api.v0.dev/v1/chat/completions
# ⇒ 401

---

What I’ve tried

  1. Regenerated API key twice and re-exported it.
  2. Confirmed key length (53 chars incl. v1: prefix).
  3. Ensured OPENAI_API_KEY is unset to avoid provider mix-up.
  4. Placed config file inside WSL $HOME (not Windows path).
  5. Tested both v0-1.0-md and v0-1.5-md models.
  6. Verified billing page shows active usage-based billing.

Still receive 401 for every request.

---

Expected
200 OK and a valid chat completion.

Actual
401 Unauthorized with message "Unauthorized".

Please advise on any missing configuration or backend-side flag that needs to be enabled.
Happy to provide extra logs or run further diagnostics.

Thanks a lot!

What is the expected behavior?

_No response_

What do you see instead?

_No response_

Additional information

_No response_

View original on GitHub ↗

3 Comments

codex-maintainers · 1 year ago

Thank you for the detailed report. Please try using the latest version of Codex CLI, as we've been focusing on improvements and fixes in the native Rust implementation. If the issue persists, feel free to reach out again.

dvic · 11 months ago

I just wanted to try out codex and hit this as well. I get ⚠️ stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 1/5 in 190ms… (with the default config, I just entered the freshly created API key)

Is there anyway I can debug what's going on?

paul-hammant · 11 months ago

I got this, then I didn't after I prepended the rest of my API-KEY I had not copy/pasted fully