/v1 endpoint to leverage account pooling and usage tracking.
Endpoint
The OpenAI SDK uses the standard OpenAI-compatible
/v1 endpoint.Installation
Install the OpenAI Python SDK:Basic Usage
- Without API Key Auth
- With API Key Auth
When API key authentication is disabled (default):
The OpenAI SDK requires an
api_key parameter. When auth is disabled, any string value works.Complete Example
Here’s a complete example with error handling:Streaming Responses
Stream responses for real-time output:Advanced Features
Async Client
Use the async client for concurrent requests:Function Calling
Use function calling (tools) for structured outputs:Vision (Image Input)
Send images to vision-capable models:Configuration Options
Example with custom config:
Verify Configuration
Test your connection:Troubleshooting
Error: Connection refused
Error: Connection refused
Ensure Codex-LB is running:If using Docker:
Error: Model not found
Error: Model not found
The requested model isn’t available:
- Verify the model ID matches exactly (case-sensitive)
- Ensure at least one account supports the model
- Check model sync in dashboard settings
Timeout errors
Timeout errors
Increase the timeout for long-running requests:
Rate limit errors
Rate limit errors
You’re hitting rate limits:
- Check your API key limits in the dashboard
- Implement exponential backoff:
- Add more accounts to the pool
Remote Access
If Codex-LB is running on a different machine:Next Steps
API Keys
Create and manage API keys for authentication
Rate Limiting
Configure rate limits per key or account
Chat Completions API
Full API reference for
/v1/chat/completionsUsage Tracking
Monitor SDK usage in the dashboard