npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@czp3009/openai-stream-proxy

v0.0.7

Published

Convert OpenAI Responses/ChatCompletions API request from non-stream mode to stream mode

Downloads

267

Readme

openai-stream-proxy CLI

:cli is the Kotlin Multiplatform executable subproject for openai-stream-proxy. It starts a local Ktor server that proxies OpenAI-compatible HTTP and WebSocket traffic to one or more upstream providers.

The main use case is running clients that make non-streaming OpenAI API requests against an upstream provider through streaming SSE. For supported endpoints, the CLI rewrites a downstream non-streaming request into an upstream streaming request, consumes the upstream SSE stream, accumulates the result, and returns a single non-streaming JSON response.

The CLI is built on top of the shared :proxy multiplatform library and adds configuration loading, server startup, WebSocket passthrough, platform-specific HTTP client engines, logging, and shutdown handling.

Behavior

HTTP requests are routed by path:

  • paths ending with /responses use the Responses API conversion flow;
  • paths ending with /chat/completions use the Chat Completions API conversion flow;
  • all other HTTP paths are forwarded without conversion.

Requests that already contain stream: true are not converted. They are forwarded upstream unchanged.

WebSocket requests are proxied to the matching upstream ws:// or wss:// URL. Frames are forwarded directly in both directions without payload rewriting or whole-session buffering.

This project does not convert between API protocols. For example, it does not convert Responses API payloads to Chat Completions payloads or to another provider-specific protocol.

Configuration

The CLI reads config.json from the current working directory by default:

{
  "timeoutSeconds": 600,
  "rules": [
    {
      "listenPort": 8080,
      "upstreamUrl": "https://api.openai.com"
    },
    {
      "listenPort": 8081,
      "upstreamUrl": "https://some-other-provider.example.com"
    }
  ]
}

timeoutSeconds is the upstream request timeout in seconds. If omitted, it defaults to 600.

Each rules entry maps one local listen port to one upstream base URL. The request path and query string are appended to upstreamUrl, so upstreamUrl usually should not include /v1.

With the config above:

  • POST http://localhost:8080/v1/responses is proxied to POST https://api.openai.com/v1/responses;
  • POST http://localhost:8080/v1/chat/completions is proxied to POST https://api.openai.com/v1/chat/completions;
  • WS ws://localhost:8080/v1/realtime?model=... is proxied to WSS wss://api.openai.com/v1/realtime?model=...;
  • POST http://localhost:8081/v1/responses is proxied to POST https://some-other-provider.example.com/v1/responses.

Use --config-file or -c to load a config file from another path.

Run From Gradle KMP

When running from the GitHub repository, use the repository root as the working directory so the default config.json is resolved from the root project.

Run the JVM target:

./gradlew :cli:jvmRun

Run with an explicit config file:

./gradlew :cli:jvmRun --args="--config-file /path/to/config.json"

Build and run the JVM fat JAR:

./gradlew :cli:shadowJar
java -jar cli/build/libs/openai-stream-proxy-<version>-fat.jar --config-file config.json

Build native executables on their corresponding platforms:

./gradlew :cli:linkReleaseExecutableLinuxX64
./gradlew :cli:linkReleaseExecutableMingwX64
./gradlew :cli:linkReleaseExecutableMacosArm64

The CLI native targets are Linux x64, Windows x64, and macOS Apple Silicon. The JVM target is also available for local development and JVM distribution.

Run With npx

After the npm packages are published, run the native launcher with:

npx @czp3009/openai-stream-proxy

Run with an explicit config file:

npx @czp3009/openai-stream-proxy --config-file /path/to/config.json
npx @czp3009/openai-stream-proxy -c /path/to/config.json

The npm package is a launcher package with platform-specific optional native packages. At runtime, it selects the native binary for the current OS and CPU.