Skip to main content

llm-async-codex

ChatGPT Codex subscription provider for llm-async.

from llm_async_codex import CodexProvider

provider = CodexProvider.from_codex_home()
response = await provider.acomplete(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Review this repository."}],
    stream=True,
)
async for chunk in response.stream_content():
    print(chunk, end="", flush=True)

This reads an existing Codex CLI login from $CODEX_HOME/auth.json or ~/.codex/auth.json by default (CodexProvider.from_codex_home()), or a CodexCredentials loaded from any path via load_credentials(path).

Login

If you don't already have a Codex CLI login, log in directly:

llm-async-codex login
llm-async-codex login --device-code   # headless/SSH, no local browser needed
llm-async-codex login --auth-file ~/.my-tool/auth.json
llm-async-codex login --verbose

or from Python: await login(device_code=False, auth_path=None, verbose=False).

Token refresh and shared auth files

Access tokens are refreshed automatically shortly before they expire. Each refresh also rotates the refresh token and revokes the previous one, so several providers (or processes) using the same auth file coordinate through it:

  • a refresh holds an exclusive lock on <auth file>.lock next to the auth file (next to its target, for a symlink);
  • under the lock it re-reads the file and reuses credentials another provider already refreshed, as long as they belong to the same account and are not older than its own;
  • the file is written to a temporary sibling and renamed into place, keeping its permission bits and any other fields in it (such as the Codex CLI's id_token), and written in place only if the rename is refused;
  • a refresh request already sent is finished and kept even if the caller is cancelled or saving fails.

Pass the same auth_path to every provider that shares a login (without one, the default ~/.codex/auth.json is used). Keep the auth file's directory writable: without it there is no lock, and refreshes are coordinated only within each provider (a warning is logged). login() takes the lock; use auth_file_lock(path) around your own writes to the file. The Codex CLI itself does not take this lock, so sharing its file only works through the re-read: a refresh here rotates the CLI's refresh token, and a Codex CLI process already running with the old one fails on its own next refresh until it is restarted. The lock may not be shared across network or VM file shares. A file without a stored expiry (as the Codex CLI writes) takes it from the access token's exp claim.

Tool calling

Tool calling works through the normal streaming API: call provider.acomplete(..., stream=True, tools=[...]), drain response.stream_content(), then read response.main_response.tool_calls. Requires llm-async>=0.5.2.

Model catalog

await provider.list_model_slugs() lists models available to the authenticated account. await provider.get_model_capabilities(model) returns its context-window and automatic compaction limits when present.

Limitations

  • Streaming only: the Codex backend requires stream=True; non-streaming requests are rejected.
  • No stateless multi-turn: the backend rejects store=True ("Store must be set to false"), so previous_response_id-based continuation (as used in some of llm-async's other Responses API examples) does not work here. Resend the full conversation history (including function_call/function_call_output items) on every turn instead.
  • max_output_tokens is ignored because the Codex backend rejects it.

Metadata

Release files for llm-async-codex 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-async-codex 0.3.0
File Size Uploaded Provenance Actions
llm_async_codex-0.3.0.tar.gz 13.9 kB Without provenance Details for llm_async_codex-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llm-async-codex 0.3.0
File Interpreter ABI Platform Actions
llm_async_codex-0.3.0-py3-none-any.whl Python 3 none any Details for llm_async_codex-0.3.0-py3-none-any.whl

Total release size: 29.4 kB

Release files / llm_async_codex-0.3.0.tar.gz

Download URL llm_async_codex-0.3.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cf224a5cf58dba4fdc7b5b5e137c4ab5743cd11f756484cf3315bf46c3728e04
BLAKE2b-256 checksum
How to use checksums
b205d91a5651d16db3c55e716038b885f8c812e66d1a9aa6ae5bfc416aba5c60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / llm_async_codex-0.3.0-py3-none-any.whl

Download URL llm_async_codex-0.3.0-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f59426ff6da562f8f4dcab4cbff1c553874765ae111ef952d738dd763a01991b
BLAKE2b-256 checksum
How to use checksums
22bf01d68adbbedc19a019c99f9faf7e17a7222691b2c02e618986ee3b68abb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for llm-async-codex 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page