A local bridge server for AI access you already have on your machine. It exposes that access behind one OpenAI-compatible HTTP surface and a CLI — it does not mint new cloud credentials.
THEBRIDGE takes AI access that already works locally and normalizes it behind one bridge. It discovers local providers, reuses their local auth, performs a token exchange when a provider needs one, and serves OpenAI-compatible HTTP endpoints plus a CLI for debugging and scripting. Two providers work today: openai-codex and github-copilot. It is a local API bridge over existing working access, not a cloud credential vending machine.
Providers it discovers and exposes:
openai-codex— reuses local Codex auth fromCODEX_HOMEor~/.codex/auth.json, then runscodex execinside an isolated temporaryCODEX_HOME.github-copilot— reads local OpenClaw auth profiles (~/.openclaw/agents/<agentId>/agent/auth-profiles.json), performs the GitHub-token to Copilot-API-token exchange at runtime, caches the result, and calls the Copilot endpoint directly.
HTTP surface (full list in docs/http-api.md): GET /health, GET /api/providers, GET /api/auth/probe, GET /api/exec/probe, POST /api/exec, GET /v1/models, GET /v1/models/{id}, POST /v1/responses, POST /v1/chat/completions. Hardening: optional bearer auth via THEBRIDGE_HTTP_TOKEN, refusal to bind a non-loopback host without a token, concurrency and body-size caps, an optional persistent request log, and per-request security headers.
CLI: serve, providers, models, runtime-health, auth-probe, codex-auth-probe, copilot-auth-probe, exec, responses, chat-completions, exec-probe.
Verified locally:
- provider discovery returns both
openai-codexandgithub-copilot codex-auth-probeconfirms the local Codex auth source and account id- the Copilot auth probe resolves a real runtime token from cache
modelsandGET /v1/models/{id}return OpenAI-compatible model cardsresponsesandchat-completionswork end-to-end againstgithub-copilot/gpt-5.4stream=trueworks on/v1/responses(provider SSE passthrough) and/v1/chat/completions(bridge-emitted SSE)- the same surfaces work through the HTTP daemon
- mock-provider and router tests cover token exchange, non-stream responses, SSE parsing, body-limit rejection, and log-file writing
cargo fmt --checkandcargo clippy --all-targets --all-features -- -D warningspass
What it does not do: it does not generate a normal OpenAI API key, does not replace the official platform API, does not bypass provider licensing or plan rules, and does not grant access to providers that are not already working locally.
Current gaps: no persistent metrics backend, no external-dependency health probe beyond auth and provider checks, and no full end-to-end daemon harness yet — live smoke still depends on local credentials.
Requires a Rust toolchain (edition 2021, rustc >= 1.77.2).
# start the bridge on loopback
cargo run -- serve --host 127.0.0.1 --port 7788
# probe local access from the CLI
cargo run -- providers
cargo run -- codex-auth-probe
cargo run -- copilot-auth-probe
# OpenAI-compatible calls
curl http://127.0.0.1:7788/v1/models
curl -X POST http://127.0.0.1:7788/v1/responses \
-H 'content-type: application/json' \
-d @examples/openresponses-copilot.json
# run the tests
cargo testSet THEBRIDGE_HTTP_TOKEN to require bearer auth and to allow binding a non-loopback host. THEBRIDGE_OPENCLAW_AGENT_ID (or --openclaw-agent-id <id>) selects the OpenClaw agent profile store; the default is main. See docs/operations.md for the hardened run and safety rules, and docs/providers.md for provider details.
Reusing local provider auth (Codex, Copilot) to serve requests through this bridge may violate those providers' terms of service depending on how you use it. Checking that is your responsibility; THEBRIDGE only re-exposes access that already exists on your machine.
MIT. Fork welcome. Reading the code, the next expansion areas:
- Richer native provider streaming passthrough beyond the current bridge-emitted SSE.
- Optional
/v1/embeddings, and closer/v1/chat/completionscompatibility. - Persistent auth-profile management inside THEBRIDGE, including
openai-codexprofile import and export instead of relying only on ambient local Codex auth. - More providers beyond Codex and Copilot.
A DEViance Intelligence prototype — beyond the edge · by Max Kle1nz