Codex Client Provider
Reusable Python and LangChain adapter for the official codex app-server
protocol. It lets a local application use the Codex model access already managed
by the installed Codex client, without asking the user for an OpenAI API key.
The provider never reads, copies, logs, or stores Codex authentication files. It
starts codex app-server, communicates through JSONL over stdio, and leaves
authentication and account policy enforcement to the Codex client.
This is an unofficial community project. Codex and OpenAI are trademarks of OpenAI. See the official Codex App Server documentation for the protocol and compatibility guidance.
Features
- Persistent App Server process with request correlation and clean shutdown.
- LangChain
BaseChatModelwith sync and async invocation. - Text, local image, and data URL image inputs.
- LangChain tool calls while keeping tool execution inside the host application.
- Structured output through Codex output schemas.
- Bounded image resizing and JPEG compression with temporary-file cleanup.
- Model, reasoning effort, timeout, client identity, and Codex binary overrides.
- Windows, macOS, and Linux support when the Codex CLI is available.
flowchart LR
A[Host application] --> B[Codex Client Provider]
B -->|JSONL over stdio| C[codex app-server]
C --> D[Existing Codex login]
D --> E[Codex model]
B -->|tool call request| A
Requirements
- Python 3.10 or newer.
- A compatible Codex CLI or Codex desktop installation.
- An active Codex login.
Verify the login before using the provider:
codex login
codex login status
Install
Install the current source checkout:
python -m pip install .
After the first PyPI release, install it with:
python -m pip install codex-client-provider
Basic usage
from codex_client_provider import CodexAppServerChatModel
model = CodexAppServerChatModel(
model_name="default",
reasoning_effort="low",
timeout_seconds=120,
)
response = model.invoke("Return a concise status message.")
print(response.content)
The provider also supports LangChain tools:
from langchain_core.tools import tool
from codex_client_provider import CodexAppServerChatModel
@tool
def lookup_temperature(city: str) -> str:
"""Return a sample temperature for a city."""
return f"{city}: 23 C"
model = CodexAppServerChatModel().bind_tools([lookup_temperature])
message = model.invoke("What is the temperature in Shanghai?")
for call in message.tool_calls:
result = lookup_temperature.invoke(call["args"])
print(result)
The host application remains responsible for running tools. The provider only asks Codex to return a LangChain-compatible tool call, which prevents the model from silently using Codex built-in shell, browser, or file tools on the host's behalf.
Configuration
| Setting | Default | Purpose |
|---|---|---|
CODEX_CLIENT_BIN |
Auto-detected | Absolute path to codex or codex.exe. |
CODEX_CLIENT_IMAGE_MAX_EDGE |
1600 |
Maximum image width or height in pixels. |
CODEX_CLIENT_IMAGE_MAX_BYTES |
786432 |
Target maximum encoded image size. |
CODEX_CLIENT_IMAGE_JPEG_QUALITY |
82 |
Initial JPEG quality for compressed images. |
The constructor accepts model_name, reasoning_effort, timeout_seconds,
codex_binary, and service_name. The provider uses the App Server's read-only
sandbox for model turns.
For compatibility with the original Artemis integration, the legacy
ARTEMIS_CODEX_* environment variable names are accepted when the corresponding
CODEX_CLIENT_* variable is absent.
Development
python -m pip install -e ".[dev]"
ruff check .
ruff format --check .
pyright
pytest
python -m build
twine check dist/*
Run the opt-in live smoke test only on a machine with a working Codex login:
python scripts/smoke.py
See CONTRIBUTING.md for the release workflow and SECURITY.md for the authentication boundary.
Metadata
Release files for codex-client-provider 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| codex_client_provider-0.1.0.tar.gz | 21.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| codex_client_provider-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.2 kB
Release files / codex_client_provider-0.1.0.tar.gz
| Download URL | codex_client_provider-0.1.0.tar.gz |
|---|---|
| Size | 21.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51a34c29e83e7c8116771aa982f44269a910e56301ce9703ee0d86cbf3f35394
|
|
BLAKE2b-256 checksum How to use checksums |
b9981efae3874a2a17e7e29609854cd0f8ca74550c58c15c2f5e4823f76dd2e7
|
| 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 Sep 19, 2026.
Transparency logRelease files / codex_client_provider-0.1.0-py3-none-any.whl
| Download URL | codex_client_provider-0.1.0-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d0e6bbd697c49d6caf2aece9a6a5d3ff007b696ad3942b0f6ec804814c29646
|
|
BLAKE2b-256 checksum How to use checksums |
cf2f643bba9b0850e9d3af4f6acb2767188524d75bb39a9ced43e07e81f67137
|
| 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 Sep 19, 2026.
Transparency logSecurity for codex-client-provider 0.1.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for codex_client_provider-0.1.0.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 Sep 19, 2026.
Transparency logA 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.