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.

    1. 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.

    2. Parse and rebuild the request. Read instructions, input, and tools, then convert the system prompt into a system message and convert user input and history into a messages array. If the request includes previous_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.

    3. Forward the request upstream. The bridge uses the locally configured key to send the rebuilt request to the upstream Chat Completions endpoint.

    4. Convert the response. Convert the upstream choices content into the output structure. 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:

    1. node --version
    2. npm --version
    3. rustc --version
    4. cargo --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:

    1. Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile "rustup-init.exe"
    2. .\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:

    1. 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:

    1. cd D:\bridge
    2. npm install
    3. npm run build
    4. cargo build --release

    What each command does:

    • npm install installs script dependencies.
    • npm run build generates scripts or frontend artifacts. If the project does not have this script, skip it.
    • cargo build --release compiles 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.

    1. UPSTREAM_BASE_URL=<base URL of the upstream Chat Completions service>
    2. UPSTREAM_API_KEY=<your access key>
    3. BRIDGE_PORT=<local listening port>

    After configuration, do three things.

    1. Make sure .gitignore contains .env, so the file is not committed accidentally.
    2. 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:
    1. icacls .env /inheritance:r /grant:r "$env:USERNAME:(R,W)"
    1. Check logging. Bridge logs must not print the Authorization header 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:

    1. cd D:\bridge
    2. .\target\release\<binary filename>

    After startup, verify the service in this order.

    1. Check the startup log and confirm the listening address and port, with no errors.
    2. 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.
    3. 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.