Skip to main content

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_content across turns (Kimi k2.6, DeepSeek-R1)
  • Model catalog — proxies /v1/models from 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

codex_relay-0.1.4-py3-none-win_amd64.whl (2.5 MB view details)

Uploaded Python 3Windows x86-64

codex_relay-0.1.4-py3-none-manylinux_2_28_x86_64.whl (3.1 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

codex_relay-0.1.4-py3-none-manylinux_2_28_aarch64.whl (3.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

codex_relay-0.1.4-py3-none-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

codex_relay-0.1.4-py3-none-macosx_10_12_x86_64.whl (2.9 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file codex_relay-0.1.4-py3-none-win_amd64.whl.

File metadata

  • Download URL: codex_relay-0.1.4-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codex_relay-0.1.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 b74b0989bce0187b4ded0e680fa610a0ba49d155a8c0e9d42eaa2589c70f43a8
MD5 3fcbacfd60d25bed8f765f460d6748cf
BLAKE2b-256 5a8be9e6c4cf1a4d878a61cb3a2fb59f44691a3c185cc0adfc107947828366dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_relay-0.1.4-py3-none-win_amd64.whl:

Publisher: publish.yml on MetaFARS/codex-relay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_relay-0.1.4-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for codex_relay-0.1.4-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 104ad99b277dfd48b955fd82bb3cddea74dd6df015e74a680a4f78a1111db77f
MD5 7150a50c1bdcb08f3f314f360227305d
BLAKE2b-256 486f57e98720c7412d0263f88bcdb761a1d7f0d48083c122014d1ea79db9ff81

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_relay-0.1.4-py3-none-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on MetaFARS/codex-relay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_relay-0.1.4-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for codex_relay-0.1.4-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6362c38d2b85700b5ecd7bc81a2984801552efeaf13fe748ba48e9a4c46f3364
MD5 9b5676bc6a68e8e396e75438271dd25f
BLAKE2b-256 6e744ee8b037f2dda1ca8eeab15c80ca5c7d45349a6d98ee1b487efe3fe864db

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_relay-0.1.4-py3-none-manylinux_2_28_aarch64.whl:

Publisher: publish.yml on MetaFARS/codex-relay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_relay-0.1.4-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for codex_relay-0.1.4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f7ec7b87c18d5db4c6473f3f0e6f1f7185c2b5f1de5e0900a4be744ffd8e6154
MD5 70da9ad9291a2ea1062b7edfeb2e41a0
BLAKE2b-256 540eb3bb2c9ea59ee40a54748ca5e5a00d1999a8e8043af8536a0d224965dd09

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_relay-0.1.4-py3-none-macosx_11_0_arm64.whl:

Publisher: publish.yml on MetaFARS/codex-relay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file codex_relay-0.1.4-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for codex_relay-0.1.4-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 24404d39aaab8ec934f128e6ce64081c0b768dd25c08bcb305a515e4b8e49024
MD5 ec4406ed4bc57d44e706dfb3f3eca9ab
BLAKE2b-256 dba6ba8c75347f7eaaf3398aa99340d3c7732aa229a2ac237f1ab8c92d63f686

See more details on using hashes here.

Provenance

The following attestation bundles were made for codex_relay-0.1.4-py3-none-macosx_10_12_x86_64.whl:

Publisher: publish.yml on MetaFARS/codex-relay

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page