Authentication Methods
Weaver supports three authentication methods for OpenAI:1. API Key Authentication
Standard OpenAI API key authentication.Get API Key
- Visit OpenAI Platform
- Create a new API key
- Copy the key (starts with
sk-)
Configure Weaver
Option A: Configuration File Add to~/.weaver/config.json:
.env:
2. OAuth Authentication (Codex)
Use ChatGPT account credentials via OAuth for Codex backend access.~/.weaver/config.json:
OAuth authentication provides access to the Codex backend, which supports advanced models like
gpt-5.2 and experimental features.3. CLI Token Authentication
Use existingcodex-cli credentials.
codex-cli configuration.
Available Models
OpenAI API Models
| Model | Description | Context Window |
|---|---|---|
gpt-4 | Most capable GPT-4 model | 8K tokens |
gpt-4-turbo | Faster GPT-4 with JSON mode | 128K tokens |
gpt-4o | Optimized multimodal model | 128K tokens |
gpt-3.5-turbo | Fast and cost-effective | 16K tokens |
Codex Backend Models (OAuth)
| Model | Description | Context Window |
|---|---|---|
gpt-5.2 | Latest Codex model (default) | 128K tokens |
o3 | Experimental reasoning model | 128K tokens |
o4 | Advanced experimental model | 128K tokens |
Configuration Options
OpenAI API key (required for API key auth)
OpenAI API endpoint (for API key auth)
Authentication method:
api_key, oauth, token, or codex-cliHTTP/HTTPS proxy URL for API requests (optional)
Model Parameters
Configure model behavior:Maximum tokens in response (
max_output_tokens for Codex backend)Controls randomness (0.0 = deterministic, 2.0 = very random)
Codex Backend Details
The Codex backend provides access to advanced OpenAI models through the ChatGPT interface.Model Resolution
Weaver automatically maps models to Codex-compatible versions:- Models starting with
gpt-,o3, oro4are used as-is - Other model families (Claude, Gemini, etc.) fallback to
gpt-5.2 - OpenAI-specific models are stripped of
openai/prefix
pkg/providers/codex_provider.go:143-183
Account ID
Codex backend requires a ChatGPT account ID:- Automatically retrieved during OAuth login
- Stored in credentials after authentication
- Sent as
Chatgpt-Account-Idheader
Response Format
Codex uses streaming response format:pkg/providers/codex_provider.go:83-136
Usage Examples
Basic Usage
With Tool Calling
Custom Endpoint
Use Azure OpenAI or other OpenAI-compatible endpoints:Implementation Details
Weaver’s OpenAI integration uses:- HTTPProvider for standard API key authentication
- CodexProvider for OAuth and Codex backend access
- Native OpenAI Go SDK (
github.com/openai/openai-go/v3) - Automatic token refresh for OAuth sessions
pkg/providers/codex_provider.go, pkg/providers/http_provider.go:238-270
Troubleshooting
API Key Issues
OAuth Issues
Codex Backend Issues
400 Bad Request
400 Bad Request
- Verify account ID is present (
Chatgpt-Account-Idheader) - Check model compatibility (use GPT, o3, o4 families only)
- Re-authenticate to refresh credentials
Model Fallback Warning
Model Fallback Warning
- This is normal for non-OpenAI models
- Codex will use
gpt-5.2as fallback - Consider using OpenRouter for other model families
401 Unauthorized
401 Unauthorized
Next Steps
Provider Overview
Back to all providers
Tool Calling
Use tools with GPT models