Skip to content
maxkle1nzPublic

About

Local bridge for AI access you already have: Codex and Copilot behind one OpenAI-compatible surface. No new credentials.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

THEBRIDGE

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.

What this is

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.

Status — honest

Providers it discovers and exposes:

  • openai-codex — reuses local Codex auth from CODEX_HOME or ~/.codex/auth.json, then runs codex exec inside an isolated temporary CODEX_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-codex and github-copilot
  • codex-auth-probe confirms the local Codex auth source and account id
  • the Copilot auth probe resolves a real runtime token from cache
  • models and GET /v1/models/{id} return OpenAI-compatible model cards
  • responses and chat-completions work end-to-end against github-copilot/gpt-5.4
  • stream=true works 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 --check and cargo clippy --all-targets --all-features -- -D warnings pass

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.

Run it

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 test

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

Terms of service note

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.

Continue from here

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/completions compatibility.
  • Persistent auth-profile management inside THEBRIDGE, including openai-codex profile import and export instead of relying only on ambient local Codex auth.
  • More providers beyond Codex and Copilot.

DEViance Intelligence
A DEViance Intelligence prototype — beyond the edge · by Max Kle1nz

About

Local bridge for AI access you already have: Codex and Copilot behind one OpenAI-compatible surface. No new credentials.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages