Skip to main content

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.contentnull when upstream sends ""
  • choices[].message.reasoning_contentnull when upstream sends ""
  • choices[].delta.contentnull when upstream sends "" (streaming)
  • choices[].delta.reasoning_contentnull when upstream sends "" (streaming)
  • SSE lines without a space after data: are parsed and re-emitted as standard data: {...}

Development

uv run python -m unittest discover tests

Project details


Download files

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

Source Distribution

simpleopenai_proxy-0.1.0.tar.gz (53.2 kB view details)

Uploaded Source

Built Distribution

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

simpleopenai_proxy-0.1.0-py3-none-any.whl (52.4 kB view details)

Uploaded Python 3

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

Hashes for simpleopenai_proxy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 124f85a774aeccd035c6c2582336c10f361a2eded8aae6df4929e1140f8e3619
MD5 fc38a861a31938726971cc891945aa8b
BLAKE2b-256 776f1c42abf8744b6b28335982dc4fd9b520a0cdc55e669545d209c08d4899e8

See more details on using hashes here.

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

Hashes for simpleopenai_proxy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9afc9112e5ea630f3f8437b68bceb0e3505e44eb3e165b8a34c54228b3deac64
MD5 2b64b3d24668f99bec840b15f69b19a9
BLAKE2b-256 b57512351dcfdd71d460eca94a8dfd373fae8b3fa6c38438e861c8d9b0574764

See more details on using hashes here.

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