Codex OAuth Python library with optional local OpenRouter-compatible server
Project description
Claw Codex Python Library + Local Server
Local tools for using Codex OAuth credentials (ChatGPT subscription) in two ways:
- As a reusable library for direct
chat.completions-style calls. - As a local FastAPI server with OpenRouter-like endpoints and a demo UI.
This project is for local testing/investigation. Make sure usage complies with provider terms.
Install
pip install claw-codex
For local development:
python -m venv .venv
source .venv/bin/activate
pip install -e '.[dev]'
Library Quickstart (recommended for other projects)
from claw_codex import ClawCodexClient
client = ClawCodexClient()
# One-time auth flow
start = client.start_auth()
print(start.authorize_url)
client.exchange_code("PASTE_REDIRECT_URL_OR_CODE")
# OpenRouter-style chat call
resp = client.chat_completions(
model="claw/codex",
messages=[
{"role": "system", "content": "You are helpful."},
{"role": "user", "content": "Say hello from Codex."},
],
)
print(resp["choices"][0]["message"]["content"])
CLI Authentication and Chat
- Start server (existing behavior):
claw-codex
- Interactive CLI auth:
claw-codex auth login --open-browser
- Check auth state:
claw-codex auth status
- Exchange pasted redirect URL/code:
claw-codex auth exchange 'http://localhost:1455/auth/callback?code=...&state=...'
- Send a prompt via library client:
claw-codex chat "Write a short haiku" --text-only
Credentials are stored in ~/.claw-codex/auth.json by default.
UI and Local Proxy
Run:
claw-codex serve
Then open:
- Demo UI:
http://127.0.0.1:1455/demo - Start auth via API:
POST /auth/codex/start - Chat endpoint:
POST /v1/chat/completions
Test Mode (no real OAuth)
CLAW_CODEX_MOCK=1 pytest
Testing
pytest
Publishing
The repo is configured for GitHub Actions trusted publishing to TestPyPI/PyPI.
Quick release flow:
- Bump
versioninpyproject.toml. - Commit, tag, and push:
git add . git commit -m "release: claw-codex vX.Y.Z" git tag -a vX.Y.Z -m "claw-codex vX.Y.Z" git push origin main --tags
- Create a GitHub Release for that tag (Actions
Publishruns automatically and uploads to PyPI).
Optional preflight checks:
python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
See docs/PUBLISHING.md for first-time setup and TestPyPI workflow details.
Library API details and streaming examples are in docs/LIBRARY.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claw_codex-0.2.1.tar.gz.
File metadata
- Download URL: claw_codex-0.2.1.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b7e6787cdab9d464ef41341042fb60ae3ebbb26a57f1282b1d2fcc621f47739
|
|
| MD5 |
ca438fb983e3716ed20156cc86db9131
|
|
| BLAKE2b-256 |
b3b33ef67cc57eac7f7d3c0159c3cc98af5d7891bdced625014f94d2a143ad05
|
Provenance
The following attestation bundles were made for claw_codex-0.2.1.tar.gz:
Publisher:
publish.yml on JayFarei/claw-codex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claw_codex-0.2.1.tar.gz -
Subject digest:
4b7e6787cdab9d464ef41341042fb60ae3ebbb26a57f1282b1d2fcc621f47739 - Sigstore transparency entry: 899496688
- Sigstore integration time:
-
Permalink:
JayFarei/claw-codex@c2cc6cc819ccfbcce05f68472734267a59ed7c90 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/JayFarei
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c2cc6cc819ccfbcce05f68472734267a59ed7c90 -
Trigger Event:
release
-
Statement type:
File details
Details for the file claw_codex-0.2.1-py3-none-any.whl.
File metadata
- Download URL: claw_codex-0.2.1-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2071e3074ddf753aa59d1d1de119f204011a41fc1eef7484be023405dc2419b
|
|
| MD5 |
aa761fad6fb4fe65dd362ddb3c919cb0
|
|
| BLAKE2b-256 |
06c57cf818ed7e5ab794ec90b510657dbb0fa27f5421b5b4abcb2a69c12e0627
|
Provenance
The following attestation bundles were made for claw_codex-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on JayFarei/claw-codex
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claw_codex-0.2.1-py3-none-any.whl -
Subject digest:
f2071e3074ddf753aa59d1d1de119f204011a41fc1eef7484be023405dc2419b - Sigstore transparency entry: 899496711
- Sigstore integration time:
-
Permalink:
JayFarei/claw-codex@c2cc6cc819ccfbcce05f68472734267a59ed7c90 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/JayFarei
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c2cc6cc819ccfbcce05f68472734267a59ed7c90 -
Trigger Event:
release
-
Statement type: