Transparent OpenAI Chat Completions proxy and response normalizer
Project description
simpleopenai-proxy
A lightweight transparent proxy for OpenAI-compatible Chat Completions endpoints.
It sits in front of a non-standard upstream API and exposes a standard local OpenAI Chat Completions server. Currently it normalizes cases where upstream providers incorrectly emit empty strings ("") for content or reasoning_content instead of the expected OpenAI null.
Install / run with uvx
uvx simpleopenai-proxy <source-api-address> <localport>
Example:
uvx simpleopenai-proxy https://api.example.com/v1/chat/completions 8080
The proxy transparently forwards all request headers (including Authorization) to the upstream endpoint, so clients use the local server exactly like a standard OpenAI endpoint:
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <upstream-api-key>" \
-d '{
"model": "glm_5_dot_2_public",
"messages": [{"role": "user", "content": "hello"}],
"stream": true
}'
Run from source
uv run server.py <source-api-address> <localport>
Current normalizations
choices[].message.content→nullwhen upstream sends""choices[].message.reasoning_content→nullwhen upstream sends""choices[].delta.content→nullwhen upstream sends""(streaming)choices[].delta.reasoning_content→nullwhen upstream sends""(streaming)- SSE lines without a space after
data:are parsed and re-emitted as standarddata: {...}
Development
uv run python -m unittest discover tests
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 Distribution
Built Distribution
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 simpleopenai_proxy-0.1.0.tar.gz.
File metadata
- Download URL: simpleopenai_proxy-0.1.0.tar.gz
- Upload date:
- Size: 53.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
124f85a774aeccd035c6c2582336c10f361a2eded8aae6df4929e1140f8e3619
|
|
| MD5 |
fc38a861a31938726971cc891945aa8b
|
|
| BLAKE2b-256 |
776f1c42abf8744b6b28335982dc4fd9b520a0cdc55e669545d209c08d4899e8
|
File details
Details for the file simpleopenai_proxy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: simpleopenai_proxy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 52.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9afc9112e5ea630f3f8437b68bceb0e3505e44eb3e165b8a34c54228b3deac64
|
|
| MD5 |
2b64b3d24668f99bec840b15f69b19a9
|
|
| BLAKE2b-256 |
b57512351dcfdd71d460eca94a8dfd373fae8b3fa6c38438e861c8d9b0574764
|