Bridging Responses API and Chat Completions API: A Practical Guide
This guide explains how to run a local bridge service that translates Responses API requests from a desktop coding tool into Chat Completions API calls for a cloud service. It covers the applicable conditions, key API differences, request/response mapping, workflow, environment prerequisites, build steps, API key security, and startup verification.
Applicability and Boundaries
This solution applies when all three conditions are true:
- A desktop coding tool can send only Responses API requests.
- The cloud coding service exposes only the Chat Completions API endpoint.
- You can run a local service on your own development machine or in a controlled environment, and you have access to the cloud service and its API key.
No changes to the desktop tool’s source code or the cloud service backend are required. The bridge service only converts between protocol formats; it does not add capabilities to the upstream service. If the desktop tool depends on server-side session state or built-in tools that the upstream service does not provide, those features will fail even if the bridge works. In those cases, use an upstream-supported interface or switch to a different tool.
Before using the bridge in production, read the upstream service’s terms of service and confirm that forwarding is allowed. Also verify the authentication method required by the upstream service.
Key Differences Between the Two APIs
The Responses API and the Chat Completions API use different request and response structures. The bridge service must map fields one by one.
| Aspect | Responses API | Chat Completions API |
|---|---|---|
| Request path | /v1/responses |
/v1/chat/completions |
| Input content | input field, which can be a string or a structured array |
messages array, where each message has a role |
| System prompt | instructions field |
A system message inside messages |
| Tool definitions | tools field, supporting multiple tool types |
tools field, mainly function type |
| Multi-turn state | Can reference the previous turn with previous_response_id |
Client must send the full messages array each time |
| Output structure | output array |
choices array, with content inside message |
| Streaming events | Event types such as response.output_text.delta |
Chunks are placed in choices[].delta |
The minimal field mapping is straightforward: instructions becomes a system message, input becomes user or assistant messages, and the upstream choices[0].message.content becomes the text content in the output structure.
How the Bridge Service Works
The bridge service runs locally as a lightweight reverse proxy and protocol translator. A complete call contains four steps.
Receive the request. The desktop tool sends a request to a local inbound address, for example
http://127.0.0.1:<port>/v1/responses. The port depends on your configuration.Parse and rebuild the request. Read
instructions,input, andtools, then convert the system prompt into asystemmessage and convert user input and history into amessagesarray. If the request includesprevious_response_id, the bridge must store the corresponding history messages locally; otherwise, multi-turn context will be lost. Whether this is supported depends on the implementation. Follow the project documentation, and confirm the history storage keys, expiration behavior, and clearing method.Forward the request upstream. The bridge uses the locally configured key to send the rebuilt request to the upstream Chat Completions endpoint.
Convert the response. Convert the upstream
choicescontent into theoutputstructure. In streaming scenarios, convert the chunks into event sequences that the desktop tool can recognize.
Environment Prerequisites
The bridge service requires the following environment.
- Node.js 20.0.0 or higher, for package management and script execution.
- npm 10.0.0 or higher.
- Rust 1.85.0 or higher, for compiling the core binary.
The version requirements in the project README take precedence over this article.
After installation, run the following commands in a terminal:
node --versionnpm --versionrustc --versioncargo --version
Each command should print a version number at or above the required version. If a command is not found, check whether the installation completed or whether the corresponding directory is in the PATH environment variable.
On Windows, install Rust with the official installer:
Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile "rustup-init.exe".\rustup-init.exe -y
After installation, reopen PowerShell and run rustc --version and cargo --version again. If both commands print version numbers, the Rust toolchain is ready. If the commands are still not found, check that %USERPROFILE%\.cargo\bin is included in the user PATH.
On macOS or Linux, install Rust with the official rustup script:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Reopen the terminal after installation and run the same version checks.
Source Code, Dependencies, and Build
The bridge source code is provided by the project maintainers. This article does not include a repository URL. If you are using a controlled source archive, extract it to a directory without spaces, for example D:\bridge, and run all subsequent commands from that directory.
After entering the directory, first confirm that package.json and Cargo.toml exist. Then run:
cd D:\bridgenpm installnpm run buildcargo build --release
What each command does:
npm installinstalls script dependencies.npm run buildgenerates scripts or frontend artifacts. If the project does not have this script, skip it.cargo build --releasecompiles the core binary.
A successful build has three signs: the command exits with code 0, an executable appears under target\release, and the filename and location match the project documentation. If the build fails, look at the first error in the output. It is usually caused by a version mismatch or a missing dependency.
API Key Configuration and Permissions
The basic rule for key protection is: do not write the key into code, do not commit it to version control, and do not expose it in command-line history or logs.
The recommended location for configuration is a .env file in the project directory. The variable names below are examples only; use the actual variable names from your project.
UPSTREAM_BASE_URL=<base URL of the upstream Chat Completions service>UPSTREAM_API_KEY=<your access key>BRIDGE_PORT=<local listening port>
After configuration, do three things.
- Make sure
.gitignorecontains.env, so the file is not committed accidentally. - Restrict file permissions. On Linux or macOS, run
chmod 600 .env. On Windows, run the following command to allow only the current user to read and write the file:
icacls .env /inheritance:r /grant:r "$env:USERNAME:(R,W)"
- Check logging. Bridge logs must not print the
Authorizationheader or the full key. If an error message needs to show the key, show only the last 4 characters. If the project logs full keys, fix the logging code before using the bridge.
Startup and Verification
Start the service from the project directory. The binary filename depends on the actual build output:
cd D:\bridge.\target\release\<binary filename>
After startup, verify the service in this order.
- Check the startup log and confirm the listening address and port, with no errors.
- If the project provides a health check endpoint, visit
http://127.0.0.1:<port>/health. It should return a success status. If the project does not provide this endpoint, skip this step. - Send a minimal Responses request to the local endpoint, using the request format documented by the bridge project. Confirm that the upstream response is converted back into the expected Responses API output structure.
