# API key bug report

**URL:** <https://forum.cursor.com/t/api-key-bug-report/161950>\
**Category:** Bug Reports\
**Tags:** byok, openai, anthropic\
**Created:** [May 30, 2026, 4:44am UTC](https://forum.cursor.com/t/api-key-bug-report/161950 "2026-05-30T04:44:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gzquse](https://avatars.discourse-cdn.com/v4/letter/g/df788c/32.png) [@gzquse](https://forum.cursor.com/u/gzquse)\
**Post date:** [May 30, 2026, 4:44am UTC](https://forum.cursor.com/t/api-key-bug-report/161950/1 "2026-05-30T04:44:13Z")

</div>

### Where does the bug appear (feature/product)?

Somewhere else…

### Describe the Bug

If I simultaneously enable an Anthropic key and an OpenAI key overridden with OpenRouter, either the Anthropic or the OpenRouter models stop working. Is there a conflict when enabling multiple API keys?

### Steps to Reproduce

Enable both api keys for OpenAI and Anthropic keys.  
Override openai: [OpenRouter](https://openrouter.ai/api/v1)

### Operating System

MacOS

### Version Information

Version: 3.6.21 (Universal)  
VS Code Extension API: 1.105.1  
Commit: e7a7e93f4d75f8272503ecf33cedbaae10114a10  
Date: 2026-05-28T21:45:36.072Z  
Layout: editor  
Build Type: Stable  
Release Track: Default  
Electron: 39.8.1  
Chromium: 142.0.7444.265  
Node.js: 22.22.1  
V8: 14.2.231.22-electron.0  
xterm.js: 6.1.0-beta.220  
OS: Darwin arm64 25.5.0

### Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [May 30, 2026, 8:39am UTC](https://forum.cursor.com/t/api-key-bug-report/161950/5 "2026-05-30T08:39:48Z")

</div>

Hey, thanks for the report. This is a known limitation. OpenRouter isn’t officially supported in Cursor as a BYOK provider. When you enable Override OpenAI Base URL with OpenRouter, Cursor sends requests to that endpoint in the wrong format. Also, the override is global and breaks the direct path to Anthropic, so you get a conflict when both keys are enabled at the same time.

Supported BYOK providers right now:

- OpenAI
- Anthropic
- Google
- Azure OpenAI
- AWS Bedrock

The most reliable option is to not keep both enabled at once. Use either a direct Anthropic connection, or an OpenAI key with Override OpenAI Base URL set to OpenRouter, but not both.

Proper support for custom OpenAI compatible endpoints is something the team is working on, but there’s no specific timeline yet. Let me know if you’ve got any questions.

---

<div class="post-metadata">

**Author:** ![Aussie\_Smurf](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Aussie\_Smurf](https://forum.cursor.com/u/Aussie_Smurf)\
**Post date:** [June 5, 2026, 8:11pm UTC](https://forum.cursor.com/t/api-key-bug-report/161950/6 "2026-06-05T20:11:41Z")

</div>

# How to use OpenRouter in Cursor and compare its results with Cursor’s AI models.

The two rules to make this work are :-

## 1. use Ask mode (not Agent)

**OpenRouter models only work reliably in Ask mode.**

Agent mode routes requests through Cursor’s backend instead of your OpenRouter base URL. That causes errors such as _“Unauthorized User API key”_ even when your key, base URL, and model ID are all correct.

Before sending a prompt:

1. Open new chat
2. Switch the mode dropdown from **Agent** to **Ask**
3. Select your OpenRouter model (e.g. `deepseek/deepseek-v4-pro`)
4. Send your message

## 2. start a new chat (not just switch mode/model)

**OpenRouter often works in a fresh chat but fails again in an existing one.**

Cursor can “lock” a chat thread to the routing path used on the first message (Agent backend, Composer, or a Cursor-built-in model). Changing the mode dropdown or model picker **mid-thread** does not always switch the backend — you still get _Unauthorized User API key_ or similar errors even in Ask mode.

**Reliable workflow — do this every time:**

1. **New chat** : start fresh — do not reuse a thread that ever used Agent or Composer
2. Set **Ask** mode **before** your first message
3. Select your OpenRouter model **before** your first message
4. Send your prompt

**Start a new chat again when:**

- You switch from one OpenRouter model to another (DeepSeek → Kimi → Qwen)
- You previously used **Agent** or **Composer** in that thread
- Ask mode + correct model still fails — the thread is likely stuck; don’t retry in place

**Rule of thumb:** one OpenRouter model, one Ask-mode chat thread. Don’t mix Cursor models and OpenRouter models in the same chat.

---

<div class="post-metadata">

**Author:** ![inferflow.dev](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/inferflow.dev/32/111190_2.png) [@inferflow.dev](https://forum.cursor.com/u/inferflow.dev)\
**Post date:** [June 10, 2026, 3:19am UTC](https://forum.cursor.com/t/api-key-bug-report/161950/8 "2026-06-10T03:19:20Z")

</div>

One practical way to debug this is to separate endpoint validity from Cursor routing.

First test the OpenAI-compatible endpoint outside Cursor:

curl [https://api.inferflow.dev/v1/chat/completions](https://api.inferflow.dev/v1/chat/completions)  
-H “Authorization: Bearer YOUR\_KEY”  
-H “Content-Type: application/json”  
-d ‘{“model”:“deepseek-v4-flash”,“messages”:[{“role”:“user”,“content”:“Reply exactly: OK”}]}’

If that works but Cursor fails, the problem is probably not the key itself. It is more likely Cursor’s mode/model routing, especially when mixing built-in providers, Anthropic keys, OpenAI override URLs, Agent mode, or Composer.

Disclosure: I maintain Inferflow, so this is a biased test endpoint. I am sharing it because it gives a simple OpenAI-compatible text/chat baseline for isolating whether the failure is the API route or Cursor’s routing behavior.

i am human too

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [June 10, 2026, 11:35am UTC](https://forum.cursor.com/t/api-key-bug-report/161950/10 "2026-06-10T11:35:40Z")

</div>

Hey @inferflow.dev, the approach is useful. Isolating endpoint validity from Cursor routing with a direct curl test is the right move when debugging BYOK.

One request: as a baseline, let’s use a neutral OpenAI-compatible endpoint, not your own commercial service. Dropping your product into someone else’s troubleshooting thread, even with disclosure, goes beyond the community guidelines. Keep the diagnostic tip curl to check what’s failing, the key or Cursor routing, since that part is solid.

For context on the original request: OpenRouter isn’t officially supported as a BYOK provider, and you shouldn’t keep an Anthropic key together with an OpenAI override on OpenRouter at the same time. That’s what causes the conflict. More details are above in the thread.

---

<div class="post-metadata">

**Author:** ![inferflow.dev](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/inferflow.dev/32/111190_2.png) [@inferflow.dev](https://forum.cursor.com/u/inferflow.dev)\
**Post date:** [June 11, 2026, 9:52am UTC](https://forum.cursor.com/t/api-key-bug-report/161950/11 "2026-06-11T09:52:42Z")

</div>

Thanks, that’s fair. I’ll keep future replies focused on neutral OpenAI-compatible diagnostics and avoid linking a commercial endpoint in troubleshooting threads.

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [June 15, 2026, 1:58pm UTC](https://forum.cursor.com/t/api-key-bug-report/161950/12 "2026-06-15T13:58:05Z")

</div>

Thanks, I appreciate it. A neutral curl test to separate key vs routing is a really useful troubleshooting trick, so feel free to share tips like that in threads.

On the original request, everything still applies. OpenRouter still isn’t supported as a BYOK provider, and you shouldn’t keep an Anthropic key together with an OpenAI override on OpenRouter at the same time. That’s what causes the conflict. If another user runs into something similar, you can safely point them to this thread.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/system/32/99069_2.png) [@system](https://forum.cursor.com/u/system)\
**Post date:** [July 15, 2026, 1:58pm UTC](https://forum.cursor.com/t/api-key-bug-report/161950/13 "2026-07-15T13:58:48Z")

</div>

Closed on July 15, 2026, 1:58pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
