scitex_genai.gateway
Structured provider gateways for external agent harnesses.
- class scitex_genai.gateway.AnthropicStreamTranslator(requested_model, message_id=<factory>, started=False, stopped=False, next_index=0, open_blocks=<factory>, block_types=<factory>, input_tokens=0, output_tokens=0)[source]
Statefully translate Codex Responses SSE objects to Anthropic SSE.
- __init__(requested_model, message_id=<factory>, started=False, stopped=False, next_index=0, open_blocks=<factory>, block_types=<factory>, input_tokens=0, output_tokens=0)
- class scitex_genai.gateway.CodexAccount(alias, credential, in_flight=0, last_used_at=0.0, cooldown_until=0.0, refresh_lock=<factory>, primary_used_percent=None, secondary_used_percent=None, usage_refreshed_at=0.0)[source]
Runtime scheduling state for one provider-qualified account.
- credential: CodexCredential
- refresh_lock: Lock
- __init__(alias, credential, in_flight=0, last_used_at=0.0, cooldown_until=0.0, refresh_lock=<factory>, primary_used_percent=None, secondary_used_percent=None, usage_refreshed_at=0.0)
- class scitex_genai.gateway.CodexAccountPool(accounts, *, choose=None)[source]
Select accounts per session and rotate around temporary failures.
Every new session uses
chooseafter quota and concurrent-load filtering. This includes a one-account pool: the selector receives a one-element list instead of bypassing rotation with a singleton shortcut.
- class scitex_genai.gateway.CodexBackend(pool, transport, usage_client=None)[source]
Apply account scheduling and failover around
CodexTransport.
- class scitex_genai.gateway.CodexCredential(path, access_token, refresh_token, account_id, expires_at, email='')[source]
One refreshable Codex subscription credential.
- async refresh(*, post=None)[source]
Refresh in place and atomically update the source
auth.json.- Return type:
- __init__(path, access_token, refresh_token, account_id, expires_at, email='')
- class scitex_genai.gateway.CodexTransport(*, base_url='https://chatgpt.com/backend-api', client=None)[source]
Make raw Codex subscription requests; never run returned tools.
- class scitex_genai.gateway.CodexUsageClient(client=None)[source]
Read quota windows without exposing tokens or account identifiers.
- scitex_genai.gateway.anthropic_to_codex(body, *, session_id='')[source]
Build a Codex Responses request without executing any tools.