[KongchangAI]
Product Reviews· 2 min read· 1,392 words

CliRelay: Use GPT-5/Gemini Pro for Free — Turn CLI Tools into API Services Instantly

CliRelay: Use GPT-5/Gemini Pro for Free — Turn CLI Tools into API Services Instantly

CliRelay converts free AI CLI tools into standard APIs for zero-cost access to top LLMs

CliRelay is an open-source Go project that uses process proxy technology to wrap free AI command-line tools like Gemini CLI, ChatGPT Codex, and Claude Code into OpenAI-compatible HTTP API services. Developers can use it to access GPT-5, Gemini 2.5 Pro, and other top-tier models for free in graphical clients and automation scripts, though compliance risks and stability concerns should be carefully considered.

Project Overview: One Command to Access Top-Tier LLM APIs for Free

CliRelay is an open-source project written in Go that wraps mainstream AI command-line tools like Gemini CLI, ChatGPT Codex, Claude Code, and Qwen Code into standard API services compatible with OpenAI/Gemini/Claude formats.

In simple terms, you can call top-tier models like Gemini 2.5 Pro, GPT-5, Claude, and Qwen through a unified API interface — completely free of charge.

The project has already earned 646 stars and 50 forks on GitHub, with popularity continuing to climb.

Why Do We Need CliRelay? Bridging CLI Tools to APIs

The Pain Points of Free CLI Tools

Google, OpenAI, Anthropic, and other providers have all released free AI command-line tools with remarkably generous quotas. In 2025, the free tiers offered by major providers through their CLI tools are quite substantial: Google's Gemini CLI provides 60 requests per minute and 1,000 per day for free, with access to the latest Gemini 2.5 Pro model; OpenAI's ChatGPT Codex offers developers free code generation and conversation capabilities; Anthropic's Claude Code allows developers to interact with Claude directly in the terminal.

But here's the problem: these tools can only be used interactively in the terminal — they can't be called directly by third-party applications, automation scripts, or development tools. Their common characteristic is generous quotas limited exclusively to command-line interaction mode, with no programmable HTTP API endpoints.

Want to use free Gemini 2.5 Pro in LobeChat? Want to batch-call GPT-5 in your own project? CLI tools can't help you there.

How CliRelay Solves This

CliRelay acts as a middle layer (Relay), transforming the input/output of CLI tools into standard HTTP API interfaces. Any client that supports the OpenAI API format can connect directly without modifying a single line of code.

An important industry context to understand here: The Chat Completions API format established by OpenAI in 2023 (centered on the /v1/chat/completions endpoint) has become the de facto standard for LLM invocation. Virtually all mainstream AI clients, development frameworks (such as LangChain, LlamaIndex), and orchestration tools prioritize support for this format. This means that as long as a service can output JSON responses conforming to the OpenAI API specification (including fields like model, choices, and usage), it can be seamlessly called by hundreds of tools across the ecosystem. CliRelay leverages exactly this ecosystem advantage — it doesn't need to convince each client to add custom integration; it just needs to "speak OpenAI's language."

Supported Tools and Models at a Glance

CLI ToolCorresponding ModelCompatible API Format
Gemini CLIGemini 2.5 ProOpenAI/Gemini
ChatGPT CodexGPT-5OpenAI/Codex
Claude CodeClaude SeriesClaude/OpenAI
Qwen CodeQwen SeriesOpenAI
AntigravityMulti-modelOpenAI
iFlowMulti-modelOpenAI

Technical Implementation: Process Proxy + Go's Natural Advantages

CliRelay's core design philosophy is Process Proxy. This is a classic system integration pattern whose core idea is: wrapping a command-line program that only supports stdin/stdout interaction into a service callable via network protocols.

The workflow is as follows:

  1. Start an HTTP server locally
  2. Upon receiving an API request, convert parameters into the corresponding CLI tool's input
  3. Spawn a subprocess to execute the CLI tool
  4. Capture the output and return it to the caller in standard API response format

In the concrete implementation, the proxy program creates subprocesses through the operating system's process management APIs (such as Go's os/exec package), serializes parameters from the HTTP request and writes them to the subprocess's stdin, then continuously reads the stdout output stream, parsing and formatting it into standard API responses for the caller. For streaming output, the proxy also needs to implement the Server-Sent Events (SSE) protocol, pushing the subprocess's line-by-line output to the client in real-time, simulating the token-by-token generation effect of LLMs. The advantage of this architecture is that it requires absolutely no modification to the original CLI tool's code — it's a non-invasive integration.

Go is an excellent choice for this task:

  • Strong concurrency handling: Go's goroutines are naturally suited for parallel forwarding of multiple API requests simultaneously. A goroutine is a user-space lightweight thread managed by Go's runtime scheduler, rather than being directly mapped to OS threads. A goroutine's initial stack space is only about 2-8 KB (compared to 1-8 MB typically required by OS threads), meaning a single machine can easily run hundreds of thousands of goroutines. In CliRelay's scenario, each API request can be handled by an independent goroutine — including spawning subprocesses, waiting for output, and formatting responses — without blocking each other. Combined with Go's channel mechanism for inter-goroutine communication, this enables elegant request queue management and concurrency control, preventing system resource exhaustion from too many simultaneous subprocesses.
  • Single binary deployment: After compilation, it's just one executable file with no runtime dependencies
  • Cross-platform compilation: Easily generate Linux, macOS, and Windows builds, covering all major operating systems

Three Practical Use Cases

Scenario 1: Connecting to Graphical AI Clients

Popular AI clients like ChatBox, Open WebUI, and LobeChat all support custom OpenAI-compatible endpoints. These tools represent the mainstream direction of current open-source AI clients: LobeChat is a modern chat interface supporting plugin extensions, with built-in multi-model switching and knowledge base management; Open WebUI (formerly Ollama WebUI) was originally designed for local models but has expanded into a universal frontend supporting any OpenAI-compatible endpoint; ChatBox is a cross-platform desktop client known for its simplicity and ease of use.

The common design philosophy of these tools is "backend-agnostic" — users only need to fill in an API address and key to switch between different model providers. This architecture creates perfect integration conditions for middleware tools like CliRelay. Combined with CliRelay, you can connect free CLI models to a graphical interface, say goodbye to white-text-on-black-background terminal windows, and enjoy a more user-friendly conversation experience.

Scenario 2: Development Integration and Automation

Developers can directly call the API provided by CliRelay in their own applications without writing separate adapter code for each AI service. The unified interface standard dramatically reduces integration costs, making it particularly suitable for rapid prototyping scenarios.

Scenario 3: Cross-Model Comparative Evaluation

Since CliRelay supports API-ification of multiple models simultaneously, researchers can use the same test scripts to compare GPT-5, Gemini 2.5 Pro, and Claude side by side without separately configuring API keys for each — saving both time and effort.

Usage Risks and Considerations

This type of tool is essentially a secondary wrapper around free CLI tools. Before using it, you should understand the following risks:

  • Compliance issues: Converting CLI tools into API services may violate some providers' terms of service — be sure to carefully read the relevant service agreements. Major AI providers' CLI tools typically specify permitted usage methods explicitly in their terms of service. For example, Google's Gemini CLI terms of service may include clauses like "automated bulk invocation is prohibited" or "resale or redistribution of the service is forbidden"; OpenAI's usage policies also have explicit restrictions on API abuse. Converting a CLI tool into an API service fundamentally changes the tool's intended use case — from human-computer interaction to machine-to-machine calls — which providers may consider a violation of the service agreement. Historically, similar "free-to-API" projects (such as early ChatGPT reverse proxies) have faced technical blocks and legal warnings from providers. Therefore, users should fully assess legal risks when using CliRelay and avoid commercial use or large-scale deployment.
  • Stability concerns: Once upstream CLI tools update their versions or providers adjust their restriction policies, CliRelay's service may be interrupted at any time
  • Rate limiting: Free quotas inherently have call frequency and total volume caps — after API-ification, without proper controls, it's easy to trigger rate limiting or even account bans

Summary: A Practical Zero-Cost Solution for Experiencing Top-Tier AI Models

CliRelay demonstrates the open-source community's typical innovative approach — using clever engineering to consolidate scattered free resources into a unified, standardized service.

For individual developers and small teams, it provides a zero-cost shortcut to experience APIs from top-tier models like GPT-5, Gemini 2.5 Pro, and Claude. However, in actual use, be sure to pay attention to each platform's usage policies and leverage these resources in a reasonable and compliant manner.

Project URL: github.com/kittors/CliRelay

#CliRelay#free GPT-5 API#Gemini CLI to API#OpenAI compatible API#Claude Code API#free LLM access#AI CLI tools
Share:

Related articles