smolagents-codex
Use a ChatGPT/Codex OAuth session as a smolagents.Model.
PyPI • Getting Started • Python Usage • Support Matrix • Troubleshooting
smolagents-codex is an unofficial external adapter that lets
smolagents.CodeAgent call the ChatGPT Codex Responses backend through OAuth
device-code login.
It does not fork smolagents, does not use the Codex CLI, does not require a
Platform API key, and does not use LiteLLM or the OpenAI Python SDK.
Features
smolagents.Modelimplementation forCodeAgent- OAuth device-code login against ChatGPT/Codex
- Access-token refresh with local credential storage
- Direct HTTPS/SSE transport to the Codex Responses backend
- Text-only message conversion for system, developer, user, assistant, and CodeAgent observation history
- Client-side stop-sequence trimming
Getting Started
Install from PyPI:
pip install smolagents-codex
Log in with device-code OAuth:
python -m smolagents_codex login
The command prints a verification URL and one-time code. Open the URL in a normal browser and enter the code only if you started the login.
Check or clear credentials:
python -m smolagents_codex status
python -m smolagents_codex logout
Python Usage
from smolagents import CodeAgent
from smolagents_codex import CodexOAuthModel
model = CodexOAuthModel(model_id="MODEL_ID")
agent = CodeAgent(
tools=[],
model=model,
stream_outputs=False,
use_structured_outputs_internally=False,
max_steps=3,
)
print(agent.run("Calculate 17 * 23 and return the result."))
Run the bundled example:
export SMOLAGENTS_CODEX_MODEL=MODEL_ID
python examples/code_agent.py
python examples/code_agent.py MODEL_ID
Credentials
Set SMOLAGENTS_CODEX_HOME to choose the credential directory. Otherwise the
package uses ~/.smolagents-codex/credentials.json.
Credential files are written with private Unix permissions where supported, but file permissions are not encryption.
Support Matrix
| Area | Status |
|---|---|
smolagents.CodeAgent |
Supported |
Blocking generate() |
Supported |
| Text messages | Supported |
| OAuth device-code login | Supported |
| Access-token refresh | Supported |
| Public smolagents streaming | Not supported |
ToolCallingAgent / native function calls |
Not supported |
Structured response_format |
Not supported |
| Images, audio, video, files | Not supported |
| Codex server-side tools | Not supported |
| Codex CLI state | Not used |
Troubleshooting
| Symptom | Fix |
|---|---|
| Device auth disabled | Enable device-code authentication in ChatGPT security settings or ask a workspace admin. |
401 after refresh |
Run python -m smolagents_codex login. |
403 |
Check workspace membership, RBAC, entitlements, and admin restrictions. |
404 |
Check the model ID and whether the endpoint is available to your plan. |
429 |
You hit ChatGPT/Codex plan or usage limits. |
| Timeout | Retry on a stable network. |
| Corporate proxy/custom CA | Use standard httpx environment settings such as HTTPS_PROXY, SSL_CERT_FILE, or SSL_CERT_DIR. |
| Malformed credential file | Run python -m smolagents_codex logout, then python -m smolagents_codex login. |
Development
pip install -e '.[dev]'
ruff check .
mypy src/smolagents_codex
python -m build
Protocol details and upstream source commits are recorded in
PROTOCOL.md. Re-check that file when Codex or smolagents
changes.
Metadata
Release files for smolagents-codex 0.1.1
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 | Actions |
|---|---|---|---|---|
| smolagents_codex-0.1.1.tar.gz | 14.2 kB | Without provenance | Details for smolagents_codex-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smolagents_codex-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for smolagents_codex-0.1.1-py3-none-any.whl |
Total release size: 31.1 kB
Release files / smolagents_codex-0.1.1.tar.gz
| Download URL | smolagents_codex-0.1.1.tar.gz |
|---|---|
| Size | 14.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42b07fea37d7638dd89ac08bbf9110aad5b9170dbe2e201220d9a828ef72c4f5
|
|
BLAKE2b-256 checksum How to use checksums |
944b47c213764190665b6e657973d47035f173600b2bab5ddbfab65579ae08c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Release files / smolagents_codex-0.1.1-py3-none-any.whl
| Download URL | smolagents_codex-0.1.1-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d0be0281e49dc8be978558a7c8e55042a16f3d814a764d49e7b8e55cab92c889
|
|
BLAKE2b-256 checksum How to use checksums |
0dcd2e417f208f42b5452cd4daa5897a9d8a44de355cf8a3b1b97152317097b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Security for smolagents-codex 0.1.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.
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.