codex_quota_client
ChatGPT-quota inference adapter backed by the official Codex Python SDK.
Bases:
RuntimeErrorA safe operational error for the admin-facing GPT route.
effects_possiblerecords whether the failure could have left provider side effects behind. A Codex turn is effect-capable — its built-in shell/filesystem/web/MCP work can change real state — so the durable turn checkpoint must fail closed on an unknown crash. It defaults toTruefor exactly that reason: an unmarked failure is treated as if it might have run something.CodexQuotaClient.complete()clears it for failures raised before the Codex turn is started, which provably cannot have caused an effect. See_checkpointed_provider_decision.
- exception codex_quota_client.CodexQuotaExhausted(message, *, fallback_safe=False)
Bases:
CodexQuotaUnavailableThe linked ChatGPT account reported a definite usage-limit exhaustion.
- class codex_quota_client.CodexDeviceAuthorization(subject, account_id, login_id, verification_url, user_code)
Bases:
objectOne private device-code challenge bound to a canonical Star user.
- class codex_quota_client.CodexAccountStatus(account_id, plan_type)
Bases:
objectNon-secret status for one linked ChatGPT-backed Codex account.
- class codex_quota_client.CodexServiceTier(id, name, description)
Bases:
objectOne model service tier advertised by the linked Codex account.
- class codex_quota_client.CodexModelCapability(model, id, supported_efforts, default_effort, service_tiers, default_service_tier, is_default)
Bases:
objectNon-secret model capability data retained from the live catalog.
- Parameters:
- service_tiers: tuple[CodexServiceTier, ...]
- class codex_quota_client.CodexStreamEvent(kind, delta, sequence, user_visible=False, turn_id='', item_id='', phase=None)
Bases:
objectOne decoded, user-presentable delta from a live Codex turn.
- Parameters:
- class codex_quota_client.CodexQuotaClient(*, client_factory=None)
Bases:
objectAccount-isolated ChatGPT quota bridge backed by Codex app-server.
Concurrent generations for one account share one SDK/app-server process. Idle account processes stay warm for a bounded TTL, while different accounts always use different private homes and processes. Device login keeps its process alive only until that one attempt succeeds, fails, times out, or is cancelled.
- Parameters:
client_factory (Callable[..., Any | Awaitable[Any]] | None)
- validate_storage()
Validate the complete persistent identity boundary synchronously.
The inference owner calls this during construction, before it can report readiness. Missing records for otherwise valid legacy credentials are created, while missing/replaced keys, tampered records, unsafe account directories, and orphan identity records fail closed.
- Return type:
- async begin_device_login(subject)
Start one private ChatGPT device-code login for subject.
- Return type:
- Parameters:
subject (str)
- async finish_device_login(subject, login_id)
Wait for and validate the exact pending device-code login.
- Return type:
- Parameters:
- async cancel_device_login(subject)
Cancel and remove one pending device authorization.
- async account_status(account_id)
Return live non-secret account status, or
Nonewhen unlinked.- Return type:
- Parameters:
account_id (str)
- async logout_account(account_id)
Drain active calls, clear auth, and remove exactly one account home.
- async validate_route(model, effort, *, service_tier=None, account_id=None)
Verify the linked account’s live model, effort, and service tier.
- async model_catalog(*, account_id=None, refresh=False)
Return the linked account’s non-secret live Codex model catalog.
- Return type:
- Parameters:
- async capacity_identity(account_id)
Return a deployment-local opaque identity for capacity deduplication.
- async complete(messages, *, model, effort, tools, service_tier=None, forced_tool_name=None, require_tool=False, response_format=None, account_id=None, stream_callback=None, admin_authorized=False, timeout_seconds=<codex_quota_client._DefaultTimeoutPolicy object>)
Return one OpenAI-shaped message using exactly one linked account.
Marks failures raised before the Codex turn exists as provably effect-free. Account resolution, leasing, session setup, catalog validation, and prompt assembly all run before
thread_start, so a failure in any of them cannot have executed shell, filesystem, web, or MCP work. The durable turn checkpoint uses that to release its slot instead of stranding it — see_checkpointed_provider_decision.- Return type:
- Parameters: