With custom model api key get request error

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When I set my own OpenAI API key in the settings, the agent mode stops working. None of the models (GPT-5 Codex, GPT-5) work.
Moreover, if I switch to the Opus or Sonnet models, they also stop working.
Request IDS:
63ba3b7b-193a-45a4-bab6-7c3ca3d3f2ad gpt-5.1 codex
614f6ca0-4533-4dcc-bae8-d051d552bcd9 opus-4.5

Steps to Reproduce

Insert OpenAI key in settings

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.1.36 (Universal)
VSCode Version: 1.105.1
Commit: 9cd7c8b6cebcbccc1242df211dee45a4b6fe15e0

For AI issues: which model did you use?

GPT-5.1 Codex
Opus 4.5

Does this stop you from using Cursor

Yes - Cursor is unusable

Hey, thanks for the report. This is a known bug: when you enable a custom OpenAI API key, it mistakenly applies to all models, causing other models (Claude, Gemini, etc.) to fail.

Workaround:

  • Turn off your OpenAI API key toggle when using Claude/Gemini models (Settings > Models > API Keys)
  • Turn it back on only when using OpenAI models
  • Quick toggle shortcut: Cmd+Shift+0
  • Unfortunately, there’s no ETA for a fix yet. The team is tracking this issue

Let me know if the workaround helps!

I think you don’t understand me )

I set OpenAI token and try agent mode with GPT-5.1 Codex model and get error.

Request ID: d6f188ab-53a8-467b-926f-1043a53ce07e
{"error":"ERROR_OPENAI","details":{"title":"Unable to reach the model provider","detail":"We encountered an issue when using your API key: Provider was unable to process your request\n\nAPI Error:\n\n```\nRequest failed with status code 404: {\n  \"error\": {\n    \"message\": \"This is not a chat model and thus not supported in the v1/chat/completions endpoint. Did you mean to use v1/completions?\",\n    \"type\": \"invalid_request_error\",\n    \"param\": \"model\",\n    \"code\": null\n  }\n}\n```","additionalInfo":{},"buttons":[],"planChoices":[]},"isExpected":true}
ConnectError: [invalid_argument] Error
    at RZc.$endAiConnectTransportReportError (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6331:408452)
    at KPo._doInvokeHandler (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6948:21873)
    at KPo._invokeHandler (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6948:21615)
    at KPo._receiveRequest (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6948:20377)
    at KPo._receiveOneMessage (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6948:19194)
    at yPt.value (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6948:17286)
    at _e._deliver (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:49:2962)
    at _e.fire (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:49:3283)
    at Xmt.fire (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:6316:12156)
    at MessagePort.<anonymous> (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:8973:18439)

Thanks for clarifying.

The error you’re seeing This is not a chat model and thus not supported in the v1/chat/completions endpoint indicates that GPT-5.1 Codex requires the /responses API from OpenAI, but Cursor’s BYOK (bring your own key) currently only supports /chat/completions. This affects all GPT-5 models when using custom API keys.

Current situation:

  • GPT-5/GPT-5.1 Codex work fine with Cursor’s built-in API (no custom key).
  • When you add your own OpenAI API key, Cursor tries to use /chat/completions, which GPT-5 models don’t support.
  • This is a known limitation affecting many users.

I’ll pass this on to the team.