@mariozechner/claude-bridge v1.0.10
claude-bridge
https://github.com/user-attachments/assets/6febdf81-e4b7-4ab8-9e70-46af77e2aba7
Use OpenAI, Google, and other LLM providers with Claude Code by intercepting and transforming API requests.
Not that anything can beat Opus, Sonnet and a Claude Max plan. But you can try that fools errand now. Go get Claude Max.
See this thread on Nitter for more examples
Quick Start
npm install -g @mariozechner/claude-bridge
# Set API keys (optional - can specify per-command with --apiKey)
export OPENAI_API_KEY=sk-...
export GOOGLE_API_KEY=...
# Discovery workflow
claude-bridge # Show available providers
claude-bridge openai # Show OpenAI models
claude-bridge openai gpt-4o # Run Claude Code with GPT-4
# Advanced usage
claude-bridge openai gpt-4o --apiKey sk-... # Custom API key
claude-bridge openai llama3.2 --baseURL http://localhost:11434/v1 # Local Ollama
claude-bridge openai gpt-4o --baseURL https://openrouter.ai/api/v1 --apiKey sk-or-... # OpenRouter
claude-bridge openai gpt-4o --debug # Enable debug logs
claude-bridge --trace -p "Hello world" # Spy on Claude ↔ Anthropic communication
# All Claude Code arguments work
claude-bridge google gemini-2.5-pro-preview-05-06 --resume --continue
claude-bridge openai o4-mini -p "Hello world"How It Works
Claude Code only works with Anthropic models. This tool intercepts Claude Code's API calls and routes them to other providers while preserving (almost) full tool compatibility.
- Spawn Claude Code as subprocess with custom Node.js loader
- Patch global fetch() to intercept
api.anthropic.com/v1/messagesrequests - Transform Anthropic requests → unified lemmy format → provider API
- Stream provider responses back in Anthropic SSE format
Limitations
This is a glorified hack that pretends other models are Claude. Here's what breaks:
Completely Broken:
- 🚫 Token usage/cost reporting (Claude Code's displays will lie to you)
- 🚫 Image uploads (drag/drop, paste, file paths - Claude Code expects Anthropic's servers)
- 🚫 Input caching (Claude Code's prompt caching isn't implemented - enjoy higher costs!)
- 🚫 Web search/fetch tools (Anthropic-specific magic)
Somewhat Janky:
- 🤷 Model-specific features don't translate (Claude's artifacts, GPT's reasoning modes)
- 🤷 Thinking/reasoning output formatting differs between providers
- 🤷 Error messages might be cryptic (provider auth failures won't surface clearly)
- 🤷 Tool schemas get converted (JSON Schema ↔ Zod) - usually works, sometimes doesn't
- 🤷 Streaming behavior has subtle differences despite SSE format conversion
OpenAI Specific Rant: OpenAI, put the goddamn thinking tokens into your API responses, you cowards. We're all tired of your "reasoning effort" parameter nonsense.
There are definitely mystery bugs hiding in the corners. You've been warned. 🐛
Development
Setup:
git clone https://github.com/badlogic/lemmy
cd lemmy && npm install && npm run devThis starts compilation in watch mode for all packages and apps. Code changes are reflected immediately. Use npx tsx src/cli.ts for on-the-fly compilation & testing.
Testing:
npm run test:all # All tests
npm run test:unit # Unit tests
npm run test:core # CLI functionality
npm run test:tools # Tool integration
npm run test:providers # Multi-providerDebugging:
# Enable debug logging
claude-bridge openai gpt-4o --debug
cat .claude-bridge/requests-*.jsonl # Raw request/response pairs
cat .claude-bridge/transformed-*.jsonl # Transformation details
cat .claude-bridge/context-*.jsonl # Message contexts and transform status
# Trace mode - spy on Claude Code ↔ Anthropic communication
claude-bridge --trace -p "Test prompt" # Normal Claude Code, but logs all requests/responses
cat .claude-bridge/trace-*.jsonl # See system prompts, tools, thinking status, messages
cat .claude-bridge/requests-*.jsonl # Raw request/response pairs
# VS Code debugging (requires patching Claude to disable anti-debugging)
npx tsx src/cli.ts <arguments> --patch-claude # In JavaScript Debug TerminalBundling:
This package uses a hybrid bundling approach:
- Core claude-bridge logic is bundled with lemmy package
- LLM provider SDKs (@anthropic-ai/sdk, openai, @google/genai, etc.) remain external dependencies
- This avoids Node.js dynamic require issues while keeping dependencies manageable
Core Files:
src/cli.ts- CLI with provider discoverysrc/interceptor.ts- Fetch interception & client creationsrc/transforms/- Request/response transformationssrc/utils/- SSE streaming, logging, parsing