Local OpenAI-compatible bridge for AIRI that uses the official Claude Code CLI and Codex App Server—without reading or storing OAuth tokens.
AI SDK Bridge lets regular HTTP clients use the quota from signed-in Claude Code and Codex/ChatGPT subscriptions. It is implemented entirely in Rust, while authentication and token lifecycle remain under the control of the official CLIs.
- Official CLI credential boundary: the bridge never reads or stores OAuth tokens. Claude Code and Codex remain responsible for authentication.
- Built for AIRI tool loops: OpenAI
tools,tool_calls, androle: toolmessages are mapped to Codex App ServerdynamicTools. - Isolated Claude MCP: bridge-owned MCP configuration is separate from personal Claude Code settings and uses an explicit tool allowlist.
- Local, ephemeral observability: the admin UI shows OpenAI and provider-layer traffic, while logs remain in memory and are restricted to loopback access.
- Pure Rust deployment: one native service with no Node.js sidecar.
The broader subscription-to-API ecosystem includes projects such as CLIProxyAPI, auth2api, claude-max-api-proxy, and codex-proxy.
Those projects cover different combinations of built-in OAuth, multi-account pools, protocol translation, and provider routing. AI SDK Bridge deliberately has a narrower focus: it delegates credentials to the official CLIs, connects to the official Codex App Server, isolates Claude MCP configuration, and supports AIRI-oriented tool-call loops.
- Claude text generation and SSE streaming.
- Bridge-owned Claude MCP with configuration isolated from personal Claude Code settings.
- Codex App Server integration with AIRI/OpenAI
tools,tool_calls, androle: toolloops. json_objectresponse extraction, request timeouts, client disconnect handling, and Claude child-process cleanup.- In-memory live web logs for inspecting OpenAI and provider-layer inputs and outputs.
claude auth status
codex login status
rustc --versionThe Claude path requires an authenticated Claude Code CLI. The Codex path requires a Codex CLI signed in with ChatGPT.
git clone https://github.com/a951753abc/ai-sdk-bridge.git
Set-Location ai-sdk-bridge
Copy-Item bridge.example.toml bridge.toml
cargo build --release
.\target\release\ai-sdk-bridge.exe --config .\bridge.tomlUse --host 127.0.0.1 --port 8791 to temporarily override the listen address without editing the configuration file.
Without a bridge.toml, the built-in defaults listen on 0.0.0.0:8789.
| Purpose | Base URL |
|---|---|
| Legacy compatibility / Claude text | http://127.0.0.1:8789/v1 |
| Claude text | http://127.0.0.1:8789/claude/v1 |
| Claude Bridge MCP | http://127.0.0.1:8789/claude-mcp/v1 |
| Codex / AIRI tools | http://127.0.0.1:8789/codex/v1 |
| Live logs | http://127.0.0.1:8789/admin |
The API key field may contain any non-empty string; the bridge currently does not authenticate model API requests. If the service listens on 0.0.0.0, other devices on the same network may consume your subscription quota. The admin UI and log API are unaffected by this setting and always accept loopback connections only.
Keep real configuration only in the untracked bridge.toml. Every server must explicitly list its allowed_tools:
[claude.mcp_servers.filesystem]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "L:/shared"]
allowed_tools = ["mcp__filesystem__read_file", "mcp__filesystem__list_directory"]
[claude.mcp_servers.filesystem.env]
EXAMPLE_TOKEN = "${EXAMPLE_TOKEN}"${NAME} values are expanded from environment variables at startup. If a variable is missing, the bridge refuses to start without displaying the secret value. /claude/v1 always uses an empty MCP configuration; only /claude-mcp/v1 loads the configured servers.
Point AIRI's OpenAI-compatible provider Base URL to /codex/v1. The bridge converts AIRI function tools into the Codex App Server experimental dynamicTools format and converts item/tool/call events back into OpenAI tool_calls. When AIRI returns role: tool, it must preserve the tool_call_id returned by the bridge.
In Claude MCP mode, the bridge completes the tool loop itself, so AIRI receives only the final text. The tool process remains visible in /admin.
For development, the included pure Rust echo server can verify MCP behavior:
cargo build --example mcp_echo
# Point the MCP example command in bridge.example.toml to
# target/debug/examples/mcp_echo.exe- Full prompts, responses, tool arguments, and tool results remain in memory only.
- The default limit is 200 entries or 100 MiB; all entries disappear after restart.
- Authorization headers, cookies, OAuth tokens, actual environment-variable values, and MCP launch secrets are not logged.
/adminand/admin/api/*always return403to non-loopback clients.
cargo fmt --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-targets
cargo build --releaseCodex dynamicTools is an experimental App Server API. If a CLI upgrade introduces an incompatible protocol change, the bridge reports the error explicitly instead of silently switching providers.