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.2.tar.gz (53.5 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.2-py3-none-any.whl (52.7 kB view details)

Uploaded Python 3

File details

Details for the file simpleopenai_proxy-0.1.2.tar.gz.

File metadata

  • Download URL: simpleopenai_proxy-0.1.2.tar.gz
  • Upload date:
  • Size: 53.5 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.2.tar.gz
Algorithm Hash digest
SHA256 2bd6ebaebbb7a68fb679acd1cc4fdf7f785d8aad11bad669a2314593a7c922c5
MD5 aa476ffaccea5f06d9ebe62c0f650098
BLAKE2b-256 0b7ec7693767e02c95f4dcc22d791a1d86b492bf9c80604f7d27006af75f2050

See more details on using hashes here.

File details

Details for the file simpleopenai_proxy-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: simpleopenai_proxy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 52.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 463e2bf5495d951d5f7c01bf1195bff1fcd6e1ea3a998836a930346a63bd84c7
MD5 12e5daf3a326de6bcd43efc781014058
BLAKE2b-256 ee17ea996b127580106c90e067bd5a29d8a0000c036b4055bc1eccce207c8fd8

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