Skip to main content

Common Error

When you see an error like this:
{
  "error": {
    "message": "Incorrect API key provided: sk-QqHvK***...",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}
This usually isn’t a problem with your API Key itself, but rather a Base URL misconfiguration.
Most common mistake: Using Nebula Lab’s Key but the request URL still points to OpenAI’s https://api.openai.com

What is Base URL?

Base URL is the target server address for API requests. Different providers use different Base URLs.

Base URL and API Key Must Match

ProviderBase URLAPI Key FormatMatch?
Nebula Labhttps://llm.ai-nebula.comsk-xxxx…✅ Correct
OpenAI Officialhttps://api.openai.comsk-xxxx…✅ Correct
❌ Nebula Keyhttps://api.openai.comsk-xxxx…Wrong
❌ OpenAI Keyhttps://llm.ai-nebula.comsk-xxxx…Wrong
Key principle: Use the provider’s Base URL that matches your API Key

Correct Configuration

from openai import OpenAI

client = OpenAI(
    api_key="sk-your-nebula-key",
    base_url="https://llm.ai-nebula.com/v1"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}]
)

Method 2: Environment Variables

export OPENAI_API_KEY="sk-your-nebula-key"
export OPENAI_BASE_URL="https://llm.ai-nebula.com/v1"

Supported URL Formats

FormatURLUse Case
With /v1 (recommended)https://llm.ai-nebula.com/v1Most libraries
With trailing slashhttps://llm.ai-nebula.com/v1/Some frameworks
Full pathhttps://llm.ai-nebula.com/v1/chat/completionscURL requests

Troubleshooting

Possible causes:
  1. Multiple configurations: Check config files, env vars, code initialization
  2. Proxy or middleware: Some tools may redirect requests
  3. Cache issues: Restart program or clear cache
  4. Typos: Verify the URL spelling
Check in Nebula Lab console:
  1. Login to Nebula Lab
  2. Go to “Tokens” page
  3. Check if Key status is “Enabled”
  4. Confirm account balance is sufficient
Most tools have “Custom API” options:
  • API URL / Base URL: https://llm.ai-nebula.com/v1
  • API Key: Copy from Nebula Lab console
  • Model name: Refer to model list

Wrong vs Correct Examples

❌ Wrong Configuration

client = OpenAI(
    api_key="sk-nebula-key",
    base_url="https://api.openai.com/v1"
    # ❌ Using OpenAI's URL
)
Result: OpenAI server rejects Nebula Lab’s Key

✅ Correct Configuration

client = OpenAI(
    api_key="sk-nebula-key",
    base_url="https://llm.ai-nebula.com/v1"
    # ✅ Using Nebula Lab URL
)
Result: Request successfully sent to Nebula Lab

Quick Test

Verify configuration with cURL:
curl https://llm.ai-nebula.com/v1/models \
  -H "Authorization: Bearer sk-your-nebula-key"
Expected result: Returns available models list
{
  "data": [
    {
      "id": "gpt-4o",
      "object": "model"
    }
  ]
}
If you get an error, check:
  1. API Key copied correctly (no extra spaces)
  2. Network connection is working
  3. Account balance is sufficient
Remember: Match the Key to its URL. Nebula Lab Key uses https://llm.ai-nebula.com/v1