# Free LLM Router & Failover Gateway

> Pools your free LLM tiers behind one local OpenAI/Anthropic-compatible API and fails over to the next best model when a provider answers 429, 402 or 5xx — so agents stop dying at the daily quota.

Free LLM Router & Failover Gateway is a paid AI agent skill on Agensi by Jace Reid, in LLM Ops. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $5 (one-time purchase)
- Creator: [Jace Reid](https://www.agensi.io/creators/wu-san)
- Category: [LLM Ops](https://www.agensi.io/skills/llm-ops)
- Version: 1.0
- Last updated: 2026-11-27
- Security: scan passed (2026-11-27); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/free-llm-router-failover-gateway
- Tags: llm-ops, ai-agents, api, llm, gateway, failover, openai, anthropic

## About this skill

Free tiers are the cheapest way to run an agent, and the flakiest: the key that worked all morning answers 429 at 3 p.m., a provider retires a model id, and one endpoint speaks OpenAI's wire while your client speaks Anthropic's.

This skill is one Node file that sits between your client and every free tier you already have, and makes them look like a single reliable API.

### What it does

- **One endpoint, both wires.** `POST /v1/chat/completions` for OpenAI clients, `POST /v1/messages` for Anthropic clients, JSON or streaming. If the winning provider speaks the other wire, the request and the answer are translated - system prompt, images, tools, tool calls, stop sequences, max_tokens, JSON mode, stop reasons and usage counts.
- **Quality-ordered routing.** Every model carries your rating; a request goes to the highest-rated free model that can do what it asks (tools / vision / JSON / context size).
- **Failover instead of failure.** A provider answering 402, 429 or 5xx, rejecting its key, timing out or unreachable is cooled down and the next candidate serves the request. The client never sees the 429.
- **Visible decisions.** `x-gateway-provider`, `x-gateway-model` and `x-gateway-rating` on every answer, one log line per request, and `/healthz` with per-provider cooldowns and counters.

### What you need

One config file listing the free tiers you have (base URL, wire, key env var, models, your rating), the keys in environment variables, and Node 18+. The package ships a starting config for Groq, Cerebras, Gemini's OpenAI-compatible endpoint and an OpenRouter free model - model ids and free-tier terms change, so verify them before trusting a route.

```sh
node scripts/gateway.mjs --config gateway.config.json
# gateway: listening on http://127.0.0.1:8787 — 4 free models over 4 providers, cooldown 60s
```

Then point any OpenAI SDK at `http://127.0.0.1:8787/v1`, or any Anthropic SDK at `http://127.0.0.1:8787`.

### Honest limits

- No keys of its own: you bring the free tiers; nothing is scraped or borrowed.
- Two upstream wires only (OpenAI `/chat/completions`, Anthropic `/messages`). Gemini works through its OpenAI-compatible base URL, not its native wire.
- Cooldowns are time-based, not quota-aware: a provider whose daily quota is gone is retried once per cooldown and fails again (one wasted request).
- Ratings and capabilities are your claims; `--check` only verifies that keys authenticate.
- Provider-specific extras (reasoning traces, prompt caching, audio) are not translated.
- No auth on the local port: it binds 127.0.0.1, but any process on the machine can spend your quota.
- Stateless: chat history is whatever the client sends, so mid-conversation failover is safe.

## Requires

- Node.js 18+

Needs a free-tier API key for at least one provider (Groq, Cerebras, Gemini or OpenRouter all work). Keys are read from the environment variables named in gateway.config.json (key_env) and never sent to the client.

## Known limitations

Requires Node 18+. No native Gemini wire support. Provider-specific extras like prompt caching are dropped during wire translation. Local port has no built-in auth.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Free LLM Router & Failover Gateway skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### How does this skill prevent my AI agents from stopping when I hit free-tier rate limits?

The router eliminates workflow interruptions caused by 429 rate limit errors by automatically retrying failed requests with other available providers in your pool, ensuring your agent keeps running even when individual quotas are hit.

### Can I use this to run an Anthropic-coded agent using only OpenAI-compatible free providers?

Yes, the gateway performs real-time wire translation, allowing you to use Anthropic-based agents with OpenAI-compatible providers (and vice versa) without changing your agent's core logic.

### What exactly is included in the download after purchase?

You will receive the complete, zero-dependency Node.js gateway source file, a sample configuration schema for model ranking, and a detailed setup guide for environment variables.

### What are the technical requirements to run this gateway locally?

The skill requires Node.js (v18+) and access to free-tier API keys from providers like Groq, Cerebras, or Gemini; it is designed to be lightweight with no external database or complex dependencies required.

### How can I monitor which providers are currently on 'cooldown' due to rate limits?

The router includes a built-in health endpoint that allows you to monitor real-time success rates, active cooldown periods for specific keys, and overall provider performance.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
