codex-relay 0.1.2__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,46 @@
1
+ """
2
+ codex-relay Python shim.
3
+
4
+ Provides a minimal interface to start/stop the relay process.
5
+ The actual binary is installed to PATH by the wheel.
6
+ """
7
+
8
+ import os
9
+ import shutil
10
+ import subprocess
11
+ from pathlib import Path
12
+
13
+
14
+ def _find_binary() -> Path:
15
+ path = shutil.which("codex-relay")
16
+ if path:
17
+ return Path(path)
18
+ # Fallback: look next to this file (editable / dev install)
19
+ local = Path(__file__).parent / "_bin" / "codex-relay"
20
+ if local.exists():
21
+ return local
22
+ raise FileNotFoundError(
23
+ "codex-relay binary not found. "
24
+ "Install with: pip install codex-relay or cargo install codex-relay"
25
+ )
26
+
27
+
28
+ def start(
29
+ port: int = 4444,
30
+ upstream: str = "https://openrouter.ai/api/v1",
31
+ api_key: str = "",
32
+ ) -> subprocess.Popen:
33
+ """Start codex-relay as a background process and return the Popen handle."""
34
+ env = os.environ.copy()
35
+ if api_key:
36
+ env["CODEX_RELAY_API_KEY"] = api_key
37
+
38
+ return subprocess.Popen(
39
+ [str(_find_binary()), "--port", str(port), "--upstream", upstream],
40
+ env=env,
41
+ stdout=subprocess.DEVNULL,
42
+ stderr=subprocess.PIPE,
43
+ )
44
+
45
+
46
+ __all__ = ["start"]
@@ -0,0 +1,107 @@
1
+ Metadata-Version: 2.4
2
+ Name: codex-relay
3
+ Version: 0.1.2
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Programming Language :: Rust
8
+ Classifier: Topic :: Software Development :: Libraries
9
+ License-File: LICENSE
10
+ Summary: Responses API ↔ Chat Completions translation bridge for Codex CLI
11
+ Keywords: codex,llm,proxy,relay
12
+ License: MIT
13
+ Requires-Python: >=3.11
14
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
15
+
16
+ # codex-relay
17
+
18
+ A lightweight Rust proxy that translates the OpenAI **Responses API** (used by [Codex CLI](https://github.com/openai/codex)) into the **Chat Completions API**, letting Codex work with any OpenAI-compatible provider — DeepSeek, Kimi, Qwen, Mistral, Groq, xAI, OpenRouter, and more.
19
+
20
+ ## Why
21
+
22
+ 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.
23
+
24
+ ## Install
25
+
26
+ ```bash
27
+ # From PyPI — prebuilt binary for your platform
28
+ pip install codex-relay
29
+
30
+ # From crates.io
31
+ cargo install codex-relay
32
+ ```
33
+
34
+ ## Quick start
35
+
36
+ **1. Start the relay**
37
+
38
+ ```bash
39
+ CODEX_RELAY_UPSTREAM=https://api.deepseek.com/v1 \
40
+ CODEX_RELAY_API_KEY=$DEEPSEEK_API_KEY \
41
+ CODEX_RELAY_PORT=4446 \
42
+ codex-relay
43
+ ```
44
+
45
+ **2. Configure Codex** (`~/.codex/config.toml`)
46
+
47
+ ```toml
48
+ model = "deepseek-chat"
49
+ model_provider = "deepseek-relay"
50
+
51
+ [model_providers.deepseek-relay]
52
+ name = "DeepSeek"
53
+ api_base_url = "http://127.0.0.1:4446/v1"
54
+ env_key = "DEEPSEEK_API_KEY"
55
+ ```
56
+
57
+ **3. Use Codex normally** — it routes through the relay transparently.
58
+
59
+ ## Supported providers
60
+
61
+ | Provider | Base URL | Suggested port |
62
+ |---|---|---|
63
+ | DeepSeek | `https://api.deepseek.com/v1` | 4446 |
64
+ | Kimi (Moonshot) | `https://api.moonshot.cn/v1` | 4447 |
65
+ | Qwen | `https://dashscope.aliyuncs.com/compatible-mode/v1` | 4448 |
66
+ | Mistral | `https://api.mistral.ai/v1` | 4449 |
67
+ | Groq | `https://api.groq.com/openai/v1` | 4450 |
68
+ | xAI | `https://api.x.ai/v1` | 4451 |
69
+ | OpenRouter | `https://openrouter.ai/api/v1` | 4452 |
70
+
71
+ Any OpenAI-compatible endpoint works.
72
+
73
+ ## Features
74
+
75
+ - **Streaming** — full SSE streaming with correct event sequencing
76
+ - **Tool calls** — accumulates streaming deltas and emits structured function_call items
77
+ - **Parallel tool calls** — consecutive function_call input items merged into one assistant message
78
+ - **Reasoning models** — preserves `reasoning_content` across turns (Kimi k2.6, DeepSeek-R1)
79
+ - **Model catalog** — proxies `/v1/models` from the upstream provider
80
+
81
+ ## Configuration
82
+
83
+ | Variable | Default | Description |
84
+ |---|---|---|
85
+ | `CODEX_RELAY_PORT` | `4444` | Port to listen on |
86
+ | `CODEX_RELAY_UPSTREAM` | `https://openrouter.ai/api/v1` | Upstream Chat Completions base URL |
87
+ | `CODEX_RELAY_API_KEY` | _(empty)_ | API key forwarded to upstream |
88
+ | `RUST_LOG` | `codex_relay=info` | Log verbosity |
89
+
90
+ ## Python API
91
+
92
+ ```python
93
+ from codex_relay import start
94
+
95
+ proc = start(port=4446, upstream="https://api.deepseek.com/v1", api_key="sk-...")
96
+ # ... use Codex ...
97
+ proc.terminate()
98
+ ```
99
+
100
+ ## Disclaimer
101
+
102
+ This project is **not affiliated with, endorsed by, or sponsored by OpenAI**. "Codex" refers to [OpenAI Codex CLI](https://github.com/openai/codex), an open-source project licensed under Apache-2.0. codex-relay is an independent, community-built translation proxy.
103
+
104
+ ## License
105
+
106
+ MIT
107
+
@@ -0,0 +1,7 @@
1
+ codex_relay/__init__.py,sha256=0WdFOcsS3-tc2Af6XUUnocPnXyldjrq1zaOPIXd8JGg,1214
2
+ codex_relay-0.1.2.data/scripts/codex-relay.exe,sha256=gYeSPqz2tZh7zSoCukW4pJTZmzXzXKKCDFdI_nbUmtw,5823488
3
+ codex_relay-0.1.2.dist-info/METADATA,sha256=M7O43wU8EP_M2HJMlIwhUN-sQKzmGpDOzrnbo_EBC0g,3599
4
+ codex_relay-0.1.2.dist-info/WHEEL,sha256=0cg7uMdVM1SNK0ih4zFWnV0wsxqvcArlTmRGOaRhEnw,94
5
+ codex_relay-0.1.2.dist-info/licenses/LICENSE,sha256=dwfkKVrUBe67tEbrhqBoVKDUCEihiBimm1mZD2WXIzY,1090
6
+ codex_relay-0.1.2.dist-info/sboms/codex-relay.cyclonedx.json,sha256=TxiUeTlSE9UHzP6dR5UEFmjO8KQWNQavsEa_fJKAkvk,199151
7
+ codex_relay-0.1.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.13.1)
3
+ Root-Is-Purelib: false
4
+ Tag: py3-none-win_amd64
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sapient Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.