Skip to main content
This guide helps you diagnose and resolve common issues with Codex-LB.

Authentication Issues

Invalid API Key

Error:
{
  "error": {
    "code": "invalid_api_key",
    "message": "Invalid API key",
    "type": "invalid_request_error"
  }
}
HTTP Status: 401 Unauthorized Common Causes:
  1. Missing Authorization header
    # Wrong
    curl https://your-instance.com/v1/chat/completions
    
    # Correct
    curl https://your-instance.com/v1/chat/completions \
      -H "Authorization: Bearer sk-clb-your-key"
    
  2. Incorrect key format
    • API keys must start with sk-clb-
    • Verify you’re not using a ChatGPT API key by mistake
  3. Key has been deleted or deactivated
    • Check the API Keys page in the dashboard
    • Verify the key’s is_active status is true
  4. Key has expired
    • Check the expires_at field in the dashboard
    • Create a new key or extend the expiration
Solution:
1

Verify Key Format

Ensure your key starts with sk-clb- and is the full token (not just the prefix).
2

Check Key Status

In the dashboard, verify:
  • Key exists in the API Keys list
  • is_active is true
  • expires_at is in the future (or null)
3

Test with New Key

Create a new API key and test with it to rule out key-specific issues.

OAuth Flow Failed

Error: “OAuth error: access_denied” or “Invalid OAuth callback state” Common Causes:
  1. User denied authorization
    • User clicked “Deny” or closed the browser window
    • Session expired during authorization
  2. State token mismatch
    • CSRF protection detected a potential attack
    • Session cookie was cleared or expired
    • Multiple OAuth flows started simultaneously
  3. Callback port not available
    • Default callback port 1455 is already in use
    • Firewall blocking the callback server
Solution:
1

Restart OAuth Flow

Close the OAuth dialog and start a fresh flow.
2

Complete Authorization Quickly

Don’t leave the authorization page open for extended periods. Complete it within a few minutes.
3

Check Callback Port

If using browser flow, ensure port 1455 is available:
# Check if port is in use
lsof -i :1455

# If in use, stop the conflicting process or use device flow instead
4

Try Device Flow

If browser flow continues to fail, use the device code flow instead:
  1. Select “Device code” in the OAuth dialog
  2. Copy the user code
  3. Open the verification URL on any device
  4. Enter the code and complete authorization

Account Deactivated

Symptom: Account shows status deactivated in the dashboard Common Causes:
  1. Refresh token expired
    • ChatGPT refresh tokens have a limited lifetime
    • Token was revoked on the ChatGPT side
  2. Account credentials revoked
    • Password changed on ChatGPT account
    • Account logged out of all sessions
    • 2FA settings changed
  3. Permanent authentication failure
    • Account deleted or suspended
    • Terms of service violation
Solution:
1

Remove Old Account

Delete the deactivated account from the dashboard.
2

Verify ChatGPT Account

Log in to ChatGPT directly to ensure:
  • Account is active and in good standing
  • No security alerts or verification required
  • Subscription is active (if applicable)
3

Re-add Account

Add the account again via OAuth with fresh credentials.
4

Monitor Status

Check the account status after a few requests to ensure it remains active.

Rate Limiting Issues

API Key Rate Limit Exceeded

Error:
{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "API key total_tokens daily limit exceeded",
    "type": "rate_limit_error"
  }
}
HTTP Status: 429 Too Many Requests Common Causes:
  1. Configured limit reached
    • API key has hit one of its rate limits
    • Check current_value vs max_value in the dashboard
  2. Underestimated usage
    • Actual usage higher than expected
    • Large prompts or long completions
    • Reasoning tokens for o1 models
Solution:
1

Check Current Usage

In the dashboard, view the API key’s limits:
{
  "limit_type": "total_tokens",
  "limit_window": "daily",
  "max_value": 1000000,
  "current_value": 1000000,
  "reset_at": "2026-03-04T00:00:00Z"
}
Note the reset_at time.
2

Wait for Reset

If you can wait, the limit will automatically reset at the reset_at time.Use the Retry-After header to know when to retry:
Retry-After: 43200
This indicates 43,200 seconds (12 hours) until reset.
3

Increase Limit

If you need immediate access:
  1. Edit the API key in the dashboard
  2. Increase the max_value for the limit
  3. Save changes
  4. Retry your request
4

Reset Usage (Emergency)

As a last resort, manually reset usage:
  1. Edit the API key
  2. Check “Reset usage”
  3. Save changes
This sets all current_value fields to 0 immediately.

Account Rate Limited

Symptom: Account shows status rate_limited in the dashboard Common Causes:
  1. ChatGPT rate limit hit
    • Account hit ChatGPT’s rate limits (requests per minute, tokens per day, etc.)
    • This is separate from Codex-LB API key limits
  2. High traffic spike
    • Sudden increase in request volume
    • Not enough accounts to handle load
Solution:
1

Check Reset Time

ChatGPT rate limits typically reset after 3-60 minutes. Check the account’s reset_at field if available.
2

Wait for Recovery

Codex-LB automatically routes requests to other accounts. The rate-limited account will recover automatically.
3

Add More Accounts

To prevent future rate limiting:
  1. Add more ChatGPT accounts to the load balancer
  2. Distribute traffic across more accounts
  3. Enable usage-weighted routing for better distribution

Quota Exceeded

Symptom: Account shows status quota_exceeded in the dashboard Common Causes:
  1. ChatGPT quota exhausted
    • Free tier accounts have daily/weekly quotas
    • Plus/Team accounts have higher but still limited quotas
  2. All accounts exhausted simultaneously
    • Insufficient total quota for traffic volume
Solution:
1

Check Account Plan

Verify the account’s plan type:
  • Free: Very limited quota
  • Plus: Higher quota
  • Team/Enterprise: Highest quota
2

Wait for Reset

Quotas typically reset daily or weekly. The account will automatically recover.
3

Upgrade Accounts

Consider upgrading accounts to Plus or Team for higher quotas.
4

Add More Accounts

Add accounts with fresh quotas to increase total capacity.

Routing Issues

No Available Accounts

Error:
{
  "error": {
    "code": "no_accounts",
    "message": "No active accounts available",
    "type": "server_error"
  }
}
HTTP Status: 503 Service Unavailable Common Causes:
  1. No accounts added
    • Load balancer has no accounts configured
  2. All accounts unavailable
    • All accounts are rate_limited, quota_exceeded, paused, or deactivated
  3. Token refresh failures
    • All accounts have failed token refresh and are deactivated
Solution:
1

Check Account Status

In the dashboard, review all accounts:
Account A: rate_limited
Account B: quota_exceeded
Account C: deactivated
If all accounts are unavailable, you’ll see this error.
2

Add New Accounts

If no accounts exist or all are deactivated:
  1. Click “Add Account” in the dashboard
  2. Complete OAuth flow
  3. Verify new account shows active status
3

Reactivate Paused Accounts

If accounts are paused:
  1. Select the paused account
  2. Click “Reactivate”
  3. Verify status changes to active
4

Wait for Recovery

If accounts are rate limited or quota exceeded, wait for them to reset automatically.

Model Not Allowed

Error:
{
  "error": {
    "code": "model_not_allowed",
    "message": "Model 'gpt-4' is not allowed for this API key",
    "type": "invalid_request_error"
  }
}
HTTP Status: 403 Forbidden Common Causes:
  1. Model not in allowed_models list
    • API key has allowed_models configured
    • Requested model is not in the list
  2. Case mismatch
    • Model names are case-sensitive
    • gpt-4 vs GPT-4 vs Gpt-4
Solution:
1

Check Allowed Models

In the dashboard, check the API key’s allowed_models:
{
  "allowed_models": ["gpt-3.5-turbo", "gpt-4o-mini"]
}
If gpt-4 is not in this list, it will be rejected.
2

Update Allowed Models

Add the requested model to the list:
  1. Edit the API key
  2. Add the model to allowed_models
  3. Ensure exact case match (e.g., gpt-4)
  4. Save changes
3

Allow All Models

Alternatively, remove the restriction entirely:
  1. Edit the API key
  2. Set allowed_models to empty or null
  3. Save changes

Sticky Sessions Not Working

Symptom: Requests with the same prompt_cache_key are routed to different accounts Common Causes:
  1. Sticky threads disabled
    • Setting sticky_threads_enabled is false
  2. Missing prompt_cache_key
    • Request doesn’t include prompt_cache_key in body
  3. Account became unavailable
    • Sticky account hit rate limit or was deactivated
    • Session reallocated to different account
Solution:
1

Enable Sticky Threads

In Settings, enable “Sticky threads”:
{
  "sticky_threads_enabled": true
}
2

Include prompt_cache_key

Add prompt_cache_key to all related requests:
{
  "model": "gpt-4",
  "messages": [...],
  "prompt_cache_key": "conversation-123"
}
3

Monitor Account Status

If the sticky account becomes unavailable, Codex-LB automatically reallocates to another account. This is expected behavior.

Request Issues

Upstream Error

Error:
{
  "error": {
    "code": "upstream_error",
    "message": "Upstream service error",
    "type": "server_error"
  }
}
HTTP Status: 502 Bad Gateway or 503 Service Unavailable Common Causes:
  1. ChatGPT API downtime
    • Upstream ChatGPT API is experiencing issues
    • Check OpenAI Status
  2. Network connectivity
    • Codex-LB cannot reach ChatGPT API
    • Firewall or proxy blocking requests
  3. Invalid request payload
    • Malformed JSON or unsupported parameters
    • Check request body for errors
Solution:
1

Check OpenAI Status

Visit https://status.openai.com/ to see if there are ongoing incidents.
2

Retry Request

Upstream errors are often transient. Retry with exponential backoff:
import time

for attempt in range(3):
    try:
        response = client.chat.completions.create(...)
        break
    except Exception as e:
        if attempt < 2:
            time.sleep(2 ** attempt)
        else:
            raise
3

Check Logs

Review Codex-LB logs for detailed error messages:
docker logs codex-lb
Look for connection errors, DNS failures, or timeout messages.
4

Verify Request Payload

Ensure your request is valid:
curl -X POST https://your-instance.com/v1/chat/completions \
  -H "Authorization: Bearer sk-clb-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "messages": [{"role": "user", "content": "test"}]
  }'

Timeout Errors

Symptom: Request takes a very long time or times out Common Causes:
  1. Large prompts or completions
    • Very long input or output
    • O1 models with high reasoning effort
  2. Upstream ChatGPT slow
    • ChatGPT API is experiencing high latency
  3. Client timeout too short
    • Client has a timeout shorter than the request duration
Solution:
1

Increase Client Timeout

Set a higher timeout in your client:
from openai import OpenAI

client = OpenAI(
    base_url="https://your-instance.com/v1",
    api_key="sk-clb-your-key",
    timeout=120.0  # 120 seconds
)
2

Use Streaming

For long completions, use streaming to get partial results:
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "..."}],
    stream=True
)

for chunk in response:
    print(chunk.choices[0].delta.content, end="")
3

Reduce Prompt Size

If possible, reduce the input size:
  • Summarize or truncate long contexts
  • Remove unnecessary information
  • Use more concise prompts

Invalid Response Format

Symptom: Response doesn’t match expected OpenAI format Common Causes:
  1. Error response
    • Request failed and returned an error object
    • Check for error field in response
  2. Streaming mode mismatch
    • Client expects streaming but stream: false
    • Client expects non-streaming but stream: true
Solution:
1

Check for Errors

Always check if the response is an error:
try:
    response = client.chat.completions.create(...)
except Exception as e:
    print(f"Error: {e}")
2

Match Streaming Mode

Ensure client and request agree on streaming:
# Non-streaming
response = client.chat.completions.create(
    model="gpt-4",
    messages=[...],
    stream=False  # or omit
)
print(response.choices[0].message.content)

# Streaming
response = client.chat.completions.create(
    model="gpt-4",
    messages=[...],
    stream=True
)
for chunk in response:
    print(chunk.choices[0].delta.content or "", end="")

Performance Issues

High Latency

Symptom: Requests take longer than expected Common Causes:
  1. Upstream latency
    • ChatGPT API is slow
    • Check OpenAI status
  2. Account selection overhead
    • Many accounts to evaluate
    • Complex routing logic
  3. Database queries
    • Slow database reads for account/key lookup
Solution:
1

Measure Latency Components

Check the X-Request-ID header and review logs to see:
  • Time to select account
  • Time for upstream request
  • Time for response processing
2

Optimize Routing

Use simpler routing strategy:
  • Switch to round_robin if using usage_weighted
  • Disable “prefer earlier reset” if enabled
  • Disable sticky sessions if not needed
3

Use Fewer Accounts

Remove inactive or redundant accounts:
  • Delete deactivated accounts
  • Remove paused accounts not in use
  • Keep only necessary accounts

High Error Rate

Symptom: Many requests fail with 429, 503, or 502 errors Common Causes:
  1. Insufficient capacity
    • Not enough accounts for request volume
    • Accounts hitting rate limits frequently
  2. Account issues
    • Accounts becoming deactivated
    • Token refresh failures
Solution:
1

Add More Accounts

Increase total capacity by adding more ChatGPT accounts.
2

Implement Client Retries

Add retry logic in your application:
from openai import OpenAI
import time

client = OpenAI(
    base_url="https://your-instance.com/v1",
    api_key="sk-clb-your-key",
    max_retries=3
)
3

Monitor Account Health

Regularly check account status in the dashboard and reactivate or replace problematic accounts.

Dashboard Issues

Cannot Access Dashboard

Symptom: Dashboard login page doesn’t load or returns error Common Causes:
  1. Codex-LB not running
    • Service is stopped or crashed
  2. Wrong URL or port
    • Dashboard runs on a different port (default: 3000)
  3. Firewall blocking access
    • Network firewall blocking dashboard port
Solution:
1

Verify Service Running

Check if Codex-LB is running:
docker ps | grep codex-lb
# or
systemctl status codex-lb
2

Check Port

Verify the correct port:
# Default: http://localhost:3000
curl http://localhost:3000/health
3

Check Logs

Review logs for startup errors:
docker logs codex-lb

Login Failed

Symptom: Cannot log in to dashboard Common Causes:
  1. Wrong password
    • Incorrect admin password
  2. TOTP enabled
    • 2FA required but not provided
  3. Session expired
    • Previous session timed out
Solution:
1

Verify Password

Double-check your admin password. If you’ve forgotten it, reset via environment variable or config file.
2

Enter TOTP Code

If 2FA is enabled, enter the 6-digit code from your authenticator app.
3

Clear Browser Cache

Clear cookies and try again:
  1. Open browser developer tools
  2. Go to Application → Cookies
  3. Delete cookies for the dashboard domain
  4. Refresh and log in again

Getting Help

If you’re still experiencing issues:
  1. Check Logs: Review Codex-LB logs for detailed error messages
    docker logs codex-lb --tail=100 --follow
    
  2. Enable Debug Logging: Set log level to DEBUG for more details
    LOG_LEVEL=DEBUG docker restart codex-lb
    
  3. Review Documentation: Check other guides for related information:
  4. Contact Support: Reach out with:
    • Error messages (sanitized)
    • Steps to reproduce
    • Relevant log excerpts
    • Configuration details (without secrets)

Next Steps

API Reference

Explore the complete API documentation

Development

Set up a development environment

Build docs developers (and LLMs) love