Skip to content

Yatin-Code/g4f-bridge

Repository files navigation

⚡ g4f-bridge

G4F + EAON → OpenCode · Claude Code · Codex CLI · Cursor · Antigravity

Python Node FastAPI Ink License

  ┌─────────────────────────────────────────────────┐
  │  ▸ deepseek/r1      POST /v1/chat/completions   │
  │  ▸ gemini/pro         ← 200 OK (1.2s)           │
  │  ▸ gpt-4o            POST /v1/messages          │
  │  ▸ claude-3.5          ← 200 OK (3.4s)          │
  │                                                 │
  │  [q] stop  [r] restart  [c] config  [m] models  │
  └─────────────────────────────────────────────────┘

Quick Start

git clone https://github.com/Yatin-Code/g4f-bridge.git
cd g4f-bridge
pip install -r requirements.txt
npm install && npm run build
pip install -e .
g4f-bridge

First run opens the setup wizard. After that, the dashboard starts.


Commands

TUI

g4f-bridge                Auto: first run → wizard, else → dashboard
g4f-bridge setup          Setup wizard
g4f-bridge config         IDEs, settings, API keys
g4f-bridge models         Model picker
g4f-bridge dashboard      Live logs

CLI

g4f-bridge -l                 List all models from all proxies
g4f-bridge -l 10              List top 10 models
g4f-bridge -b                 Auto-select top 15 models
g4f-bridge -b 5               Top 5 models
g4f-bridge -m gpt             Search by name
g4f-bridge -b -t              Auto-select + test before saving
g4f-bridge -b --target all    Generate for all tools
g4f-bridge -s                 Update API keys

How It Works

Your Tool ──► g4f-bridge:1337 ──► G4F / EAON
               │
               ├── Translates Anthropic ⇄ OpenAI
               ├── Sanitizes SSE streams
               └── Returns clean response
Endpoint Format Tools
POST /v1/chat/completions OpenAI Chat OpenCode, Codex, Cursor, Antigravity
POST /v1/messages Anthropic Messages Claude Code
GET /v1/models Model Discovery All

Supported Tools

Tool Config Format Status
OpenCode ~/.config/opencode/opencode.json @ai-sdk/openai-compatible ✅ Working
Claude Code ~/.claude/settings.json Anthropic env vars ✅ Working
Codex CLI ~/.codex/config.toml Custom provider ⚠️ Beta
Cursor ~/.cursor/settings.json OpenAI API ❌ In Devlopment
Antigravity ~/.gemini/settings.json Base URL ❌ In Devlopment

Configuration

~/.g4f-bridge/
├── keys.json         API keys (G4F, EAON, custom)
└── settings.json     IDEs, models, preferences

Custom config directory

export G4F_BRIDGE_CONFIG_DIR=/path/to/custom/dir
g4f-bridge

Custom providers — add via TUI settings or keys.json:

{
  "G4F": "your-key",
  "EAON": "your-key",
  "MY_PROVIDER": "your-key"
}

Features

  • One command for everything — dynamic API providers
  • 5 AI tools, 1 bridge — Anthropic ⇄ OpenAI translation
  • Live model stress testing — SSE stream sanitization
  • Model discovery endpoint — real-time TUI dashboard
  • Cross-platform (Linux/macOS/Windows)

Project Structure

g4f-bridge/
├── smart_bridge.py          Python shim
├── src/bridge/              FastAPI server
│   ├── main.py              CLI entry + TUI launcher
│   ├── models.py            Model discovery, testing
│   ├── translate.py         Anthropic ⇄ OpenAI translation
│   └── utils.py             Config, preflight checks
├── src/configs/             Per-IDE config generators
├── tui/                     Node.js TUI (Ink + React)
│   ├── index.tsx            TUI entry
│   ├── app.tsx              Root component
│   ├── screens/             5 screens
│   ├── components/          Reusable UI
│   └── lib/                 API, config, process
├── requirements.txt
├── pyproject.toml
└── package.json

GPL-3.0

About

Provides access to over 250+ models inside claude-code , opencode , codex and more. Free. Unlimited.

Topics

Resources

License

Contributing

Stars

5 stars

Watchers

0 watching

Forks

Contributors