DEV Community

YiYaoAI
YiYaoAI

Posted on

I Stopped Paying for AI CLI Chaos: This Local Gateway Makes Claude Code, Codex, and Gemini Work as One

If you are juggling Claude Code, Codex CLI, Gemini CLI, and random API keys across different providers, the setup gets ugly fast.

Different protocols. Different auth flows. Different config files. Different model names. Different rate limits.

So I built CliGate: a local multi-protocol AI gateway that sits on localhost and turns that mess into one controllable entry point.

Instead of wiring every tool separately, you point them at CliGate once and get:

  • multi-account pooling
  • API key failover
  • protocol translation
  • app-level routing
  • free-model fallback
  • a visual dashboard for everything

What CliGate actually does

CliGate is an open-source local proxy for AI coding tools and model APIs.

It currently supports:

  • Claude Code via Anthropic Messages API
  • Codex CLI via OpenAI Responses API, Chat Completions, and the Codex internal endpoint
  • Gemini CLI via Gemini API compatibility
  • OpenClaw via provider injection

That means one local service can sit between your tools and multiple upstream providers like OpenAI, Anthropic, Google Gemini, Vertex AI, and even free-model routes.

The real problem it solves

Most people do not have one clean AI stack.

They have:

  • a few accounts with different limits
  • some paid API keys
  • a CLI tool that only speaks one protocol
  • another tool that expects a completely different endpoint
  • no decent visibility into cost, usage, or failures

CliGate fixes that by separating the client protocol from the upstream provider.

Your tool can keep speaking the protocol it expects, while CliGate decides where the request should actually go.

The killer features

1. One gateway for multiple AI coding tools

You can run Claude Code, Codex CLI, Gemini CLI, and OpenClaw through the same local server.

No more maintaining a fragile pile of per-tool environment variables and scattered config files.

2. Account pools, not just API keys

CliGate is not just another API proxy.

It can manage:

  • ChatGPT account pools
  • Claude account pools
  • Antigravity accounts
  • provider API key pools

It supports OAuth login, token refresh, rotation strategies, quota tracking, and per-account management from the dashboard.

3. Smart routing instead of manual switching

You can choose:

  • account-pool-first
  • API-key-first
  • automatic routing
  • manual app assignment

So Claude Code can use one credential source, Codex can use another, and fallback behavior stays under your control.

4. Free-model routing for cheap or zero-cost workflows

One of my favorite parts is the ability to route lightweight requests such as claude-haiku to free models through Kilo AI.

That gives you a practical low-cost path for lightweight coding, testing, and background tasks without burning premium quota for everything.

5. A real dashboard instead of blind debugging

CliGate ships with a web UI where you can manage:

  • accounts
  • API keys
  • model mapping
  • per-app routing
  • request logs
  • usage and cost stats
  • pricing overrides
  • local tool installation and one-click configuration

This matters because most proxy tools become painful the moment you need to debug token expiry, failed routing, or mismatched models.

Why I think the protocol translation matters

This is the part that makes CliGate more than a credential switcher.

It exposes compatible endpoints for:

  • POST /v1/messages
  • POST /v1/chat/completions
  • POST /v1/responses
  • POST /backend-api/codex/responses
  • POST /v1beta/models/*

So tools that were never designed to share the same backend can still be managed through one local layer.

That unlocks a cleaner workflow:

  1. Keep your preferred client.
  2. Route it however you want.
  3. Change upstream providers without rebuilding your whole local setup.

Local-first is the point

CliGate runs on localhost.

That means:

  • no third-party relay server
  • no hosted control plane
  • no forced telemetry layer
  • direct connections to official upstream APIs

For people who care about privacy, local control, or just not introducing another external dependency into their dev workflow, this is the right architecture.

Quick start

You can start it with:

npx cligate@latest start
Enter fullscreen mode Exit fullscreen mode

Or install globally:

npm install -g cligate
cligate start
Enter fullscreen mode Exit fullscreen mode

Then open:

http://localhost:8081
Enter fullscreen mode Exit fullscreen mode

From there you can add accounts or API keys, map models, and configure your CLI tools to hit the local gateway.

Who this is for

CliGate is especially useful if you:

  • use more than one AI coding CLI
  • switch between Claude, OpenAI, Gemini, and other providers
  • want fallback behavior when limits or keys fail
  • want usage visibility across accounts and models
  • want a local control plane instead of ad hoc shell config

Repo

GitHub: https://github.com/codeking-ai/cligate

If you are building serious local AI coding workflows, this project is designed to remove a surprising amount of friction.

It is the difference between “a pile of disconnected AI tools” and “one local gateway that actually behaves like infrastructure.”

Top comments (0)