axio-transport-codex

ChatGPT OAuth transport using the Responses API.

It reads the stream through axio-responses, which it shares with axio-transport-openai. Its ProviderEvents therefore say provider="openai".

class axio_transport_codex.CodexTransport(name: 'str' = 'ChatGPT (Codex)', api_key: 'str' = '', refresh_token: 'str' = '', expires_at: 'str' = '', account_id: 'str' = '', base_url: 'str' = 'https://chatgpt.com/backend-api/codex', model: 'ModelSpec' = <factory>, models: 'ModelRegistry' = <factory>, session: 'aiohttp.ClientSession | None' = None, on_auth_refresh: 'Callable[[dict[str, str]], Awaitable[None]] | None' = None, max_retries: 'int' = 10, retry_base_delay: 'float' = 5.0)[source]
async fetch_models() → None[source]

Fetch available models from the Codex API.

CODEX_MODELS is the ModelRegistry this transport ships, and the default models for a CodexTransport. Query it like any other registry - CODEX_MODELS.by_capability(Capability.vision), CODEX_MODELS.ids().

OAuth

async axio_transport_codex.oauth.run_oauth_flow() → dict[str, str][source]

Run full OAuth2 PKCE flow with localhost callback.

Opens browser for ChatGPT sign-in, waits for callback, exchanges code for tokens.

Returns dict with keys: access_token, refresh_token, expires_at, account_id.

async axio_transport_codex.oauth.refresh_access_token(refresh_token: str) → dict[str, str][source]

Refresh an expired access token (JSON POST, matching codex-cli).