“cursor cli uses integrations User API Keys for command-line output, prompts Warning: The provided API key is invalid.
Please check you have the right key, create a new one, or authenticate without it.”
Does anyone have any ideas on how to fix this? Thanks in advance for any help!
There’s a known issue where the CLI shows “The provided API key is invalid” for any connectivity problem, not just an actually invalid key. So your key might be fine, but the CLI can’t reach our servers.
Can you try these two things?
Run agent status. Does it show “Login successful”?
Run this in your terminal:
curl -v https://api2.cursor.sh
This will tell us if there’s a network or TLS issue blocking the connection.
Also, are you behind a VPN, corporate proxy, or firewall? That’s the most common cause of this error.
I’m experiencing the same issue. Here’s what I’ve verified:
Same API key works for Cloud Agents API:
GET https://api.cursor.com/v0/me with Basic auth → 200 OK (returns apiKeyName, userEmail)
Network: api.cursor.com and api2.cursor.sh both return 200
Agent CLI rejects the key:
agent --api-key "..." "hello" → “The provided API key is invalid”
agent status → “Not logged in”
So the key is valid for the REST API but the CLI reports it as invalid. Environment: Windows, corporate proxy (both domains reachable). Would appreciate any update on this.
I see curl returns HTTP/2 200, so the network looks fine. This doesn’t look like a connectivity issue.
A few things to check:
What CLI version are you using? Check with agent -v. We recently fixed an API key auth bug, so please update to the latest CLI:
curl https://cursor.com/install -fsS | bash
Try logging in via the browser instead of using an API key:
agent login
After that, agent status should show “Login successful”.
If you need to use an API key, make sure it’s a User API Key from Settings > Integrations > User API Keys at https://cursor.com/settings. Admin API keys don’t work with the CLI.
Hey @t01-yoshioka, thanks for the detailed info. It’s really helpful. If the same key works with the REST API (/v0/me returns 200) but not in the CLI, that points to a bug on our side.
A few things to try:
Update to the latest CLI. We recently fixed a similar auth issue:
curl https://cursor.com/install -fsS | bash
(Or in Windows PowerShell: irm 'https://cursor.com/install?win32=true' | iex)
As an alternative, try browser login instead of an API key:
agent login
What CLI version are you on? agent -v
If updating doesn’t help, the team already knows the “invalid API key” message can be misleading and is tracking the issue. Your report comparing CLI vs REST API is helpful for prioritizing it.