#API Key Returns "User not found" (401) from Production Server IP

3 messages · Page 1 of 1 (latest)

smoky raven
#

Hello OpenRouter Support,

I'm experiencing an issue where my API key works perfectly from my local development environment but returns a 401 "User not found" error when used from my production server.

Details:

API Key (first 20 chars): sk-or-v1-sk-or-v1-fb67...

Error: {"error":{"message":"User not found.","code":401}}Status Code: 401
What I've verified:

The API key works correctly from my local development machine

The same API key returns "User not found" when called directly from my production server using curlThe key is correctly set in the production environment (verified via docker exec m2d-api printenv)

Direct curl test from production server:
curl -X POST https://openrouter.ai/api/v1/chat/completions
-H "Authorization: Bearer [API_KEY]"
-H "Content-Type: application/json"
-d '{"model": "google/gemini-2.0-flash-exp", "messages": [{"role": "user", "content": "test"}]}'

Returns: {"error":{"message":"User not found.","code":401}}

Production Server Details:

Server Type: Azure VM

Public IP: xxxxxxxxxx.162 (Blocked it out on discord)The server is making direct outbound HTTPS requests to openrouter.ai
Questions:

Is my production server's IP address blocked or flagged in your system?

Are there any IP restrictions by openrouter?Is there an account status issue that would cause this error?What steps can I take to resolve this?
The API key works fine from development, so this appears to be IP or account-related rather than a key validity issue.

Thank you for your assistance.

Best regards,

magic pewterBOT
#

I'm an AI assistant - my answers may be incorrect and I cannot see screenshots. Please verify information with the OpenRouter docs.

To help you and the mods debug the "User not found" (401) error from your production server, I need a bit more information:

  1. Can you provide the full exact error response (beyond just the message) from the production server?
  2. What is the exact model identifier you're using (full string, e.g., google/gemini-2.0-flash-exp)?
  3. Are there any differences in how your staging/local and production environments send requests (proxy, custom headers, networking setup, etc.)?

These details will help pinpoint if this is an account, configuration, or infrastructure-related issue.

For your direct questions:

  • I don't have access to real-time blocklists or IP flagging details. For current service status or network-related issues, check the OpenRouter status page or the #announcements channel in Discord, or ask a mod directly.
  • There is no documentation stating that OpenRouter enforces IP-based restrictions on API keys, but a 401 usually means an authorization issue. Double-check your Authorization header format: it should be:
    Authorization: Bearer sk-or-v1-your-key
    
    (See: "All requests must include an Authorization header with your API key" API Documentation).

If after providing the above details you're still blocked, for possible account or key issues contact [email protected], as Discord mods do not handle billing or account access.

-# This is an automated response powered by Answer HQ. Use !mute to stop the bot from responding.

The author you are looking for could not be found.

smoky raven
#

nvm im stupid but leaving this up bc i own up to it