I receive this error message: Request ID: 94fdbbe3-ed28-4eb0-a5b2-4758d999f33a
{“error”:“ERROR_BAD_USER_API_KEY”,“details”:{“title”:“Invalid API key.”,“detail”:“Unauthorized User API key”,“isRetryable”:false,“additionalInfo”:{},“buttons”:,“planChoices”:,“analyticsMetadata”:{“actionRequired”:“config”}},“isExpected”:true}
Unauthorized User API key
Invalid API key. Unauthorized User API key
ActionRequiredError: Invalid API key. Unauthorized User API key
at Nk1 (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:35723:27236)
at Eag (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:35723:26381)
at Wk1 (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:35724:7469)
at Mag.run (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:35724:12367)
at async zle.runAgentLoop (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:48116:2927)
at async W$g.streamFromAgentBackend (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:48187:13900)
at async W$g.getAgentStreamResponse (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:48187:22728)
at async hut.submitChatMaybeAbortCurrent (vscode-file://vscode-app/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:35854:1970)
Steps to Reproduce
Go to Google Ai Studio, copy your API key, Back to cursor, under settings, Google API key, paste the key you got from Google. Deselect ‘Override OpenAI Base URL…’ . Go to your chat interface, select any of the Gemini models then make a request, you will receive the error message above.
Expected Behavior
It should process your request and make a suggestion as a response.
Hey, thanks for the detailed report with the Request ID. The ERROR_BAD_USER_API_KEY error means Google returned a 401 for your key, so the key is being rejected on Google’s side, not by Cursor. All Gemini models fail, including Gemini 2.5 Flash, which points to a key or config issue rather than a specific model.
Let’s go step by step:
Reset the OpenAI Base URL, even if Override is unchecked. Go to Settings → Models → OpenAI → click Reset to default for Base URL → Save → restart Cursor. A stale custom Base URL is the most common cause of this exact error, even for Gemini. Here’s a thread where this fixed it: Getting "Unauthorized User API key" with Custom Gemini Key - Must I be a Pro User?
If you still get 401, recreate the key at https://aistudio.google.com/apikey, paste it with no leading or trailing spaces, make sure Generative Language API is enabled for that key’s project, and remove any API or HTTP referrer restrictions from the key.
If the key passes Verify but you still get 401 on all Gemini models, reply here and we’ll dig deeper.
Hey Nikita, this looks like a separate issue from the original BYOK topic, and since you can’t sign in to your account at all, our team should handle it directly.
Thanks for reaching out. Account and billing requests are handled by our team at [email protected]. They’ll be able to look into your specific situation.