Responses API ↔ Chat Completions translation bridge for Codex CLI
Project description
codex-relay
A lightweight Rust proxy that translates the OpenAI Responses API (used by Codex CLI) into the Chat Completions API, letting Codex work with any OpenAI-compatible provider — DeepSeek, Kimi, Qwen, Mistral, Groq, xAI, OpenRouter, and more.
Why
Codex CLI speaks the OpenAI Responses API, which is an OpenAI-proprietary stateful protocol. Every other provider exposes the standard Chat Completions API. codex-relay sits between Codex and your chosen provider, translating on the fly — no code changes to Codex required.
Install
# From PyPI — prebuilt binary for your platform
pip install codex-relay
# From crates.io
cargo install codex-relay
Quick start
1. Start the relay
CODEX_RELAY_UPSTREAM=https://api.deepseek.com/v1 \
CODEX_RELAY_API_KEY=$DEEPSEEK_API_KEY \
CODEX_RELAY_PORT=4446 \
codex-relay
2. Configure Codex (~/.codex/config.toml)
model = "deepseek-chat"
model_provider = "deepseek-relay"
[model_providers.deepseek-relay]
name = "DeepSeek"
api_base_url = "http://127.0.0.1:4446/v1"
env_key = "DEEPSEEK_API_KEY"
3. Use Codex normally — it routes through the relay transparently.
Supported providers
| Provider | Base URL | Suggested port |
|---|---|---|
| DeepSeek | https://api.deepseek.com/v1 |
4446 |
| Kimi (Moonshot) | https://api.moonshot.cn/v1 |
4447 |
| Qwen | https://dashscope.aliyuncs.com/compatible-mode/v1 |
4448 |
| Mistral | https://api.mistral.ai/v1 |
4449 |
| Groq | https://api.groq.com/openai/v1 |
4450 |
| xAI | https://api.x.ai/v1 |
4451 |
| OpenRouter | https://openrouter.ai/api/v1 |
4452 |
Any OpenAI-compatible endpoint works.
Features
- Streaming — full SSE streaming with correct event sequencing
- Tool calls — accumulates streaming deltas and emits structured function_call items
- Parallel tool calls — consecutive function_call input items merged into one assistant message
- Reasoning models — preserves
reasoning_contentacross turns (Kimi k2.6, DeepSeek-R1) - Model catalog — proxies
/v1/modelsfrom the upstream provider
Configuration
| Variable | Default | Description |
|---|---|---|
CODEX_RELAY_PORT |
4444 |
Port to listen on |
CODEX_RELAY_UPSTREAM |
https://openrouter.ai/api/v1 |
Upstream Chat Completions base URL |
CODEX_RELAY_API_KEY |
(empty) | API key forwarded to upstream |
RUST_LOG |
codex_relay=info |
Log verbosity |
Python API
from codex_relay import start
proc = start(port=4446, upstream="https://api.deepseek.com/v1", api_key="sk-...")
# ... use Codex ...
proc.terminate()
Disclaimer
This project is not affiliated with, endorsed by, or sponsored by OpenAI. "Codex" refers to OpenAI Codex CLI, an open-source project licensed under Apache-2.0. codex-relay is an independent, community-built translation proxy.
License
MIT
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 Distributions
Built Distributions
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 codex_relay-0.1.5-py3-none-win_amd64.whl.
File metadata
- Download URL: codex_relay-0.1.5-py3-none-win_amd64.whl
- Upload date:
- Size: 2.6 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
340ea7dc60234ed9f926338a1cd97a4ff0d14bf80b39c2782ede4c5fdf01a8e2
|
|
| MD5 |
5e218ddd27fa297678fc7d3b6fe566eb
|
|
| BLAKE2b-256 |
079c08cac88729df6793d3c5c8225514227609cf5a0cf83135d53808cd562d76
|
Provenance
The following attestation bundles were made for codex_relay-0.1.5-py3-none-win_amd64.whl:
Publisher:
publish.yml on MetaFARS/codex-relay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_relay-0.1.5-py3-none-win_amd64.whl -
Subject digest:
340ea7dc60234ed9f926338a1cd97a4ff0d14bf80b39c2782ede4c5fdf01a8e2 - Sigstore transparency entry: 1459150691
- Sigstore integration time:
-
Permalink:
MetaFARS/codex-relay@05a879a1238154947c7726a6ddcfcb7531ea530c -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/MetaFARS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05a879a1238154947c7726a6ddcfcb7531ea530c -
Trigger Event:
push
-
Statement type:
File details
Details for the file codex_relay-0.1.5-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: codex_relay-0.1.5-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce31ae112d076518fb528e9258d39f863e2fb4abf0038a3da55f0f139c49e9e3
|
|
| MD5 |
eb5ff20da3dae38c8315e93296251251
|
|
| BLAKE2b-256 |
2ae252514713a2af6c36231804c869a0f7e14010ded0b99b084e066ef26ce38a
|
Provenance
The following attestation bundles were made for codex_relay-0.1.5-py3-none-manylinux_2_28_x86_64.whl:
Publisher:
publish.yml on MetaFARS/codex-relay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_relay-0.1.5-py3-none-manylinux_2_28_x86_64.whl -
Subject digest:
ce31ae112d076518fb528e9258d39f863e2fb4abf0038a3da55f0f139c49e9e3 - Sigstore transparency entry: 1459150572
- Sigstore integration time:
-
Permalink:
MetaFARS/codex-relay@05a879a1238154947c7726a6ddcfcb7531ea530c -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/MetaFARS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05a879a1238154947c7726a6ddcfcb7531ea530c -
Trigger Event:
push
-
Statement type:
File details
Details for the file codex_relay-0.1.5-py3-none-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: codex_relay-0.1.5-py3-none-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 3.0 MB
- Tags: Python 3, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9efb80c4da6fa8b7683ab729390a4873bb6e535d6756a413d68bf2b54cab68e
|
|
| MD5 |
cf074a1cf4380d7bdd111d475da86f42
|
|
| BLAKE2b-256 |
13f1cc6a0fd60ee653dec6c8806389d996c435b1fc5da27a02635a5492c563c7
|
Provenance
The following attestation bundles were made for codex_relay-0.1.5-py3-none-manylinux_2_28_aarch64.whl:
Publisher:
publish.yml on MetaFARS/codex-relay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_relay-0.1.5-py3-none-manylinux_2_28_aarch64.whl -
Subject digest:
e9efb80c4da6fa8b7683ab729390a4873bb6e535d6756a413d68bf2b54cab68e - Sigstore transparency entry: 1459150829
- Sigstore integration time:
-
Permalink:
MetaFARS/codex-relay@05a879a1238154947c7726a6ddcfcb7531ea530c -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/MetaFARS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05a879a1238154947c7726a6ddcfcb7531ea530c -
Trigger Event:
push
-
Statement type:
File details
Details for the file codex_relay-0.1.5-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: codex_relay-0.1.5-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.8 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c43768a905c59ab08b1a1a20a9e3914108d2af72ca929da5e107936e92e9f982
|
|
| MD5 |
ea8eacc87126b5255bc205787687a16e
|
|
| BLAKE2b-256 |
2595d9d1a51c721807de4d15586a48ebc381991006c4774a194d93af79c99b60
|
Provenance
The following attestation bundles were made for codex_relay-0.1.5-py3-none-macosx_11_0_arm64.whl:
Publisher:
publish.yml on MetaFARS/codex-relay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_relay-0.1.5-py3-none-macosx_11_0_arm64.whl -
Subject digest:
c43768a905c59ab08b1a1a20a9e3914108d2af72ca929da5e107936e92e9f982 - Sigstore transparency entry: 1459150397
- Sigstore integration time:
-
Permalink:
MetaFARS/codex-relay@05a879a1238154947c7726a6ddcfcb7531ea530c -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/MetaFARS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05a879a1238154947c7726a6ddcfcb7531ea530c -
Trigger Event:
push
-
Statement type:
File details
Details for the file codex_relay-0.1.5-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: codex_relay-0.1.5-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.9 MB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01bda63bf6fe12d91ed20d691056c7e0441752e7d1059011ae174959aa1e5c35
|
|
| MD5 |
58fc474a9c0aa556213da5b9cdc220e8
|
|
| BLAKE2b-256 |
6a5749ad20dc7757ae8042affce0a499e9dd0069806a8d155f19ddd3d347d35c
|
Provenance
The following attestation bundles were made for codex_relay-0.1.5-py3-none-macosx_10_12_x86_64.whl:
Publisher:
publish.yml on MetaFARS/codex-relay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_relay-0.1.5-py3-none-macosx_10_12_x86_64.whl -
Subject digest:
01bda63bf6fe12d91ed20d691056c7e0441752e7d1059011ae174959aa1e5c35 - Sigstore transparency entry: 1459151001
- Sigstore integration time:
-
Permalink:
MetaFARS/codex-relay@05a879a1238154947c7726a6ddcfcb7531ea530c -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/MetaFARS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05a879a1238154947c7726a6ddcfcb7531ea530c -
Trigger Event:
push
-
Statement type: