Skip to main content

circle-codex

Unofficial fork of the OpenAI Codex Python SDK. It bundles a Codex CLI build that adds a built-in xAI (Grok) model provider.

This project is not affiliated with, endorsed by, or supported by OpenAI or xAI. It is built from https://github.com/ashish447344/codex, a fork of https://github.com/openai/codex.

Build Python applications that start Codex threads, run turns, stream progress, and control workspace access.

Install

Install the SDK:

pip install circle-codex

The SDK runs the Codex CLI through its runtime package, circle-codex-cli-bin, which pip installs automatically. That package is small: the first time your code starts Codex, it downloads the runtime for your platform (about 150-200 MB) from the project's GitHub Release, checks its SHA-256 checksum and caches it in ~/Library/Caches/circle-codex (macOS) or ~/.cache/circle-codex (Linux). Later starts use the cached copy.

Supported platforms: macOS (Apple silicon and Intel) and Linux (x86_64 and aarch64). Windows is not supported.

To download the runtime ahead of time, for example while building a Docker image, run:

python -m codex_cli_bin download

Set CIRCLE_CODEX_CACHE_DIR to change the cache location, or CIRCLE_CODEX_DOWNLOAD_BASE_URL to download from a mirror.

The import package keeps the upstream name openai_codex, so do not install this package into the same environment as the official openai-codex.

Quickstart with xAI

Set XAI_API_KEY in your environment, then select the xAI provider:

from openai_codex import Codex, CodexConfig, Sandbox

config = CodexConfig(
    config_overrides=('model_provider="xai"', 'model="grok-4.7"'),
)

with Codex(config) as codex:
    thread = codex.thread_start(sandbox=Sandbox.workspace_write)
    result = thread.run("Explain this repository in three bullets.")
    print(result.final_response)

Quickstart

The SDK reuses your existing Codex authentication when one is already available:

from openai_codex import Codex

with Codex() as codex:
    thread = codex.thread_start()
    result = thread.run("Explain this repository in three bullets.")
    print(result.final_response)

thread.run(...) returns a TurnResult containing the final response, collected items, and token usage.

Authentication

Existing Codex authentication is reused automatically. To start ChatGPT browser login explicitly:

from openai_codex import Codex

with Codex() as codex:
    login = codex.login_chatgpt()
    print(login.auth_url)
    print(login.wait().success)

For device-code login:

with Codex() as codex:
    login = codex.login_chatgpt_device_code()
    print(login.verification_url, login.user_code)
    login.wait()

For API-key login:

with Codex() as codex:
    codex.login_api_key("sk-...")

Built-In Help

Use Python's standard help(openai_codex), help(Codex), or python -m pydoc openai_codex documentation tools.

Documentation

The SDK API is the same as upstream, so the upstream guides apply:

Where those guides say pip install openai-codex, use pip install circle-codex.

The package is licensed under the Apache License 2.0, the same license as upstream. See the repository NOTICE for attribution.

Metadata

Release files for circle-codex 0.154.1

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

Source distribution (sdist)

Source distribution for circle-codex 0.154.1
File Size Uploaded Provenance Actions
circle_codex-0.154.1.tar.gz 95.5 kB With provenance Details for circle_codex-0.154.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for circle-codex 0.154.1
File Interpreter ABI Platform Actions
circle_codex-0.154.1-py3-none-any.whl Python 3 none any Details for circle_codex-0.154.1-py3-none-any.whl

Total release size: 199.0 kB

Release files / circle_codex-0.154.1.tar.gz

Download URL circle_codex-0.154.1.tar.gz
Size 95.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bf15d1f722ae9e0ee2c1472d9c95b07e3114e917114037aac2692b5bea4a94aa
BLAKE2b-256 checksum
How to use checksums
e928863fc372b92cca243e5e34996a53301b673701499c29c0385cb62c3f7f79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / circle_codex-0.154.1-py3-none-any.whl

Download URL circle_codex-0.154.1-py3-none-any.whl
Size 103.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b99023698a4e21b82d5037326dd3acbe7984e18c4e354d2af4c06a3bd196592
BLAKE2b-256 checksum
How to use checksums
70cb1fb4323470756cfcf1752ae065d7ddd4cc117704fb4f1013ba5edb085466
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for circle-codex 0.154.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for circle_codex-0.154.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

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