Commit 2fe268f
committed
feat(rotator_library): ✨ add OpenAI Codex provider with Responses API support (#33)
* feat(rotator_library): ✨ add OpenAI Codex provider with Responses API support
Adds a new provider for OpenAI Codex models (GPT-5, GPT-5.1, GPT-5.2, Codex, Codex Mini)
via the ChatGPT Responses API with OAuth PKCE authentication.
Key features:
- OAuth base class for OpenAI authentication with PKCE flow and token refresh
- Responses API streaming with SSE event handling
- Reasoning/thinking output with configurable effort levels (minimal to xhigh)
- Tool calling support translated from OpenAI format
- System prompt validation using official opencode prompt
- Usage tracking with proper litellm.Usage objects
Files added:
- codex_provider.py: Main provider implementation
- openai_oauth_base.py: OAuth base class with PKCE support
- codex_prompt.txt: Required system prompt for API validation
* fix(codex): 🐛 prefix model names with provider identifier
Models must be returned with the 'codex/' prefix (e.g., 'codex/gpt-5.2')
to match the convention used by other providers like antigravity.
This ensures proper provider routing in the RotatingClient.
* feat(codex): ✨ add reasoning effort model variants
Exposes reasoning effort levels as model variants:
- codex/gpt-5.2:low, :medium, :high, :xhigh
- codex/gpt-5.1:low, :medium, :high
- And similar for all codex models
This allows clients to control reasoning effort by model name,
similar to how gemini models use :thinking suffix.
Total models: 9 base + 30 reasoning variants = 39 models
* feat(codex): ✨ add identity override for user system prompt precedence
Injects an identity override as the first user message that tells the model
to prioritize user-provided system prompts over the required opencode
instructions. This mirrors the pattern used by Antigravity provider.
Message order:
1. Identity override (<system_override> tag)
2. User's system message (converted to user message)
3. Rest of conversation
Controlled by CODEX_INJECT_IDENTITY_OVERRIDE env var (default: true)
* docs: 📝 add Codex provider configuration to .env.example
Documents all Codex environment variables:
- CODEX_REASONING_EFFORT: low/medium/high/xhigh
- CODEX_REASONING_SUMMARY: auto/concise/detailed/none
- CODEX_REASONING_COMPAT: think-tags/raw/none
- CODEX_INJECT_IDENTITY_OVERRIDE: true/false
- CODEX_INJECT_INSTRUCTION: true/false
- CODEX_EMPTY_RESPONSE_ATTEMPTS: retry count
- CODEX_EMPTY_RESPONSE_RETRY_DELAY: seconds
- CODEX_OAUTH_PORT: callback port
* fix(codex): 🐛 register Codex in provider factory for OAuth TUI
Adds Codex to PROVIDER_MAP so it appears in the credential tool's
"Add OAuth Credential" menu alongside other OAuth providers.
* feat(codex): ✨ add quota tracking with rate limit header parsing
Integrate CodexQuotaTracker mixin into CodexProvider to track API usage
via response headers and periodic quota API calls. Enables smart
credential selection based on remaining quota and automatic cooldowns
when limits are approached.
Signed-off-by: Moeeze Hassan <fammas.maz@gmail.com>
* feat(codex): add gpt-5.3-codex to model list and reasoning config
* feat(codex): wire quota header updates to UsageManager for TUI display
- Add set_usage_manager() to CodexQuotaTracker mixin
- Push parsed rate limit headers to UsageManager via update_quota_baseline
- Inject UsageManager reference during RotatingClient initialization
- Enables quota status display in TUI after each Codex API response
* feat(codex): default to sequential credential selection for token caching
Sequential mode reuses the same credential across requests, enabling
upstream token caching on the Codex API.
* fix(codex): standardize ChatGPT-Account-Id header casing
Match the exact capitalization used by the Codex CLI, consistent with
codex_quota_tracker.py. Addresses PR review feedback.1 parent 66d8f68 commit 2fe268f
File tree
9 files changed
+3681
-0
lines changed- src/rotator_library
- client
- providers
- utilities
9 files changed
+3681
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
407 | 466 | | |
408 | 467 | | |
409 | 468 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
297 | 305 | | |
298 | 306 | | |
299 | 307 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
Large diffs are not rendered by default.
0 commit comments