Claude Code model router

Agent CLI To API

Expose agent CLIs (Codex, Cursor Agent, Claude Code, Gemini) as an OpenAI-compatible /v1 API gateway.

Install

Install
uvx --from git+https://github.com/leeguooooo/agent-cli-to-api agent-cli-to-api codex

Found in the project README. Check it for setup steps after installing.

From source
git clone https://github.com/leeguooooo/agent-cli-to-api.git

From the README

agent-cli-to-api

Expose popular agent CLIs as a small OpenAI-compatible HTTP API (/v1/*).

Works great as a local gateway (localhost) or behind a reverse proxy.

Think of it as LiteLLM for agent CLIs: you point existing OpenAI SDKs/tools at base_url, and choose a backend by model.

Supported backends:
- OpenAI Codex - defaults to backend /responses for vision and image generation (DALL-E / gpt-image-class output); falls back to codex exec
- Cursor Agent - via cursor-agent CLI
- Claude Code - via CLI or direct API (auto-detects ~/.claude/settings.json config)
- Gemini - via CLI or CloudCode direct (set GEMINI_USE_CLOUDCODE_API=1)

Why this exists:
- Many tools/SDKs only speak the OpenAI API (/v1/chat/completions) - this lets you plug agent CLIs into that ecosystem.
- One gateway, multiple CLIs: pick a backend by model (with optional prefixes like cursor: / claude: / gemini:).
- Expose your ChatGPT Plus / Pro subscription's image generation as an HTTP API. No OPENAI_API_KEY required — the gateway reuses the OAuth token from codex login, lets you call image_generation via plain chat completions, and returns the PNG inline (data URI). See Image generation (ChatGPT subscription).

Table of Contents

- Requirements
- Install
- Run (No .env Needed)
- Core Configuration
- API
- Image generation (ChatGPT subscription)
- OpenAI SDK examples
- Security notes
- Logging & Performance Diagnosis
- Performance notes (important)
- Advanced setup (optional)
- Keywords (SEO)

Requirements

- Python 3.10+ (tested on 3.13)
- Install and authenticate the CLI(s) you want to use (codex, cursor-agent, claude, gemini)

Install

Option A: one-line installer

Install and start the macOS launchd service:

Pin a token and install the launchd service:

The installer defaults to ~/.agent-cli-to-api,…
Read the full README on GitHub

Details

Language
Python
Last updated
7 October 2026
Topics
agentchat-completionsclaude-codeclicodexcursor-agentfastapigatewaygeminiopenai-apiopenai-compatibleproxy

FAQ

What is Agent CLI To API?

Expose agent CLIs (Codex, Cursor Agent, Claude Code, Gemini) as an OpenAI-compatible /v1 API gateway. It is a model router for Claude Code, from leeguooooo/agent-cli-to-api on GitHub.

How do I install Agent CLI To API?

Run uvx --from git+https://github.com/leeguooooo/agent-cli-to-api agent-cli-to-api codex, then follow the setup in the README.

Is Agent CLI To API popular?

leeguooooo/agent-cli-to-api has 84 GitHub stars and 23 forks. It was last updated on 7 October 2026.

More model routers & proxies

Browse the most popular Claude Code mods, all model routers & proxies, or the skills and MCP server directories.