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.2

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.2
File Size Uploaded Provenance Actions
circle_codex-0.154.2.tar.gz 95.5 kB With provenance Details for circle_codex-0.154.2.tar.gz

Built distribution (wheel)

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

Total release size: 199.0 kB

Release files / circle_codex-0.154.2.tar.gz

Download URL circle_codex-0.154.2.tar.gz
Size 95.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c377d841b8fc7a750d9d5d21d823ba7c15d759d4fe0a7fba3cae7beacf1a7f93
BLAKE2b-256 checksum
How to use checksums
45322fbb405998dc493d3c1a5eef6f4a24afd248d732c674d4f9a31186175913
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.2-py3-none-any.whl

Download URL circle_codex-0.154.2-py3-none-any.whl
Size 103.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76341cd99103cf5ac27ba00e54f53b50dac24c128bd223b5fdf1b1afc683b128
BLAKE2b-256 checksum
How to use checksums
d88ab8377624c00cee3034816cc6179ee6e6a3ffa88f2f8d6b16ce865ac444a2
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.2

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.2.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