Skip to content

About

One small Go binary that turns every free LLM tier (Groq, Gemini, OpenRouter, Cerebras, GitHub Models…) into a single OpenAI-compatible endpoint with automatic fallback.

Topics

Resources

Stars

29 stars

Watchers

1 watching

Forks

Repository files navigation

free-llm-proxy-router

Free LLM inference that doesn't run dry.

One Go binary turns every free LLM tier you have into a single OpenAI-compatible endpoint.
When Groq says 429, your request moves on to Gemini, Cerebras or OpenRouter, and your tool never notices.

CI Release Go tests License: MIT

Free model list · Why this one · What's new · Install · PicoClaw & small boards · Strategies · How it works · Limits

Try it in one minute. You need one free key from Groq (no credit card). No Go toolchain, no config file. On Linux or macOS:

curl -fsSL https://raw.githubusercontent.com/kaiser-data/free-llm-proxy-router/main/scripts/install.sh | sh
GROQ_API_KEY=gsk_... ./free-llm-proxy

In a second terminal:

curl -si localhost:8080/v1/chat/completions -H 'Content-Type: application/json' \
  -d '{"model":"auto","messages":[{"role":"user","content":"In one sentence: why do free LLM tiers run dry?"}]}'

The script picks the latest release for your OS and CPU (amd64, arm64, armv6, armv7, riscv64), checks it against checksums.txt and unpacks it into the current directory; VERSION=x.y.z pins a release, DIR=… picks another directory. The X-Used-Model header tells you which free model answered. The archive brings its own provider list and free-model catalog. Windows: the .zip on the releases page, or Docker (see Install).

A real request on 31 October 2026. A tool sends model auto to the proxy on localhost. The proxy first tries Groq kimi-k2, which returns 404 model not found, and puts that model on a one-hour cooldown. It then tries Groq gpt-oss-20b, which answers. The other providers were not needed. The client saw one clean 200 after 0.45 seconds.

Why this one

Small enough to live on a $10 board next to your agent, fast enough that you never notice it, and strict about what counts as free.

One 10 MB binary Static Go, no runtime, no database. Prebuilt for Linux (amd64, arm64, armv6, armv7, riscv64), macOS and Windows, as archives and .deb/.rpm/.apk.
About 12 MB of RAM when idle With the full bundled catalog of 1137 models loaded. Requests, provider answers and the cache are each capped at 16 MB, so it fits beside an agent on a 512 MB board.
0.5 ms to route a request On one Jetson Orin Nano core with a 3000-model catalog, 24× faster than v0.1.8 (#42).
A 429 adds under a millisecond The next free model answers and your tool sees a normal 200 (benchmark).
479 free models from 16 providers Found by scanning the providers' own model APIs, rescanned every week. No hand-kept list that goes stale.
Official free tiers only The API keys providers hand out. No OAuth tricks, no reused consumer sessions, no credit card.
About 9.6k lines of Go Readable in an afternoon. 184 tests, all run under the race detector in CI.

The idea

Groq, Google AI Studio, Cerebras, OpenRouter, GitHub Models, Mistral and NVIDIA all give away LLM inference on official API keys. Each tier is generous on its own, but small: a few requests per minute, a daily cap, models that disappear without notice. A script or a coding agent that leans on one of them stops working by the afternoon. Wiring all of them together by hand means juggling base URLs, model names, rate-limit headers and cooldowns in every tool.

This proxy does that once, locally, for every tool you use.

Without With
One provider's 429 stops your agent mid-task The request moves on to the next free model; your agent sees a normal 200
A model gets retired and your config breaks A 404 puts that model on cooldown and the next one answers
Every tool needs its own key, base URL and model name Every tool points at localhost:8080/v1 and asks for auto
You keep your own list of which models are free this week FREE_MODELS.md is rebuilt every week by scanning the providers' model APIs
Quotas reset at different times, and you track them in your head Per-model cooldowns, reliability scores and daily usage are tracked and kept across restarts

How it works

  1. Your tool sends a normal OpenAI chat request, with model set to auto, a strategy (coding, speed, long_context…), an agent profile, or a specific model.

  2. The strategy ranks the free models in the catalog, for example "largest context window first" or "fastest provider first".

  3. The fallback chain tries them in order. It skips models on cooldown and moves on when a provider fails.

    Upstream says The proxy does
    429 rate limited cools down that model on that key until the provider's reset time, and retries it at once with your next key if you have several
    400 bad request skips that provider for this request (also 413/422, and a moderation 403). If the error blames the model itself (decommissioned, not a chat model), that model sits out for an hour and the provider's next model is tried at once
    404 model not found cools down that model for an hour
    401/403 bad key cools down that key for ten minutes and tries your next key; the provider sits out only when no key works
    403 from an aggregator about one model (consent needed, upstream out of credit) cools down only that model and tries the next one; the key stays in use
    error inside a 200 stream handled like the same status sent as a plain response, as long as no content has been sent yet
    5xx server error rests that model for 30 seconds and lowers the provider's reliability score
    timeout or connection error moves on and lowers that provider's reliability score
    200 with no content tries another model; an empty reply cut off by max_tokens is kept only as a last resort
  4. The first good answer goes back to your tool. With stream: true the provider's own SSE stream is passed through token by token: the chain still falls back on anything that fails before the first content chunk (an error status, an error event, an empty stream, a dropped connection), then commits to that provider.

  5. If every free model fails, fallback.max_attempts upstream calls have failed (default 5; 0 means no cap, so every ranked provider is tried), or fallback.request_timeout (90 s) passes, you get 503 with a Retry-After header, never a fake answer. If the request itself was rejected (400/413/422) by every provider that was called, and none was merely skipped for a cooldown (or two different providers rejected it), you get that error instead, since retrying would not help.

Why not a full AI gateway?

LiteLLM and OmniRoute are great when you want hundreds of providers, paid-key budgets and a web dashboard. This project is deliberately smaller:

free-llm-proxy-router Full AI gateways
Install one static binary, about 10 MB Node or Python runtime, Docker, often a database
Scope free tiers only: official, recharging, no card paid, free and subscription logins
Terms of service official API keys only, no OAuth or session reuse some route through consumer subscriptions
Code you have to trust about 9.6k lines of Go (tests not counted), readable in an afternoon very large codebases
Free-model catalog discovered from the providers' model APIs, refreshed weekly curated lists
Runs on laptop, Raspberry Pi (Zero included), RISC-V boards, NAS, $4 VPS, CI runner servers

What's new

Latest release: v0.1.11 (29 Nov 2026). Full notes on the releases page; credits in Contributors.

  • No open port without a token (breaking). On a non-loopback host the proxy refuses to start unless PROXY_AUTH_TOKEN / proxy.auth_token is set, or you opt out with --allow-no-auth. The Docker image already opts out (#61).
  • Cut-off streams are flagged. A provider that closes a stream before [DONE] or a finish_reason now ends it with a stream_interrupted error event, never a silently truncated answer (#64).
  • fallback.max_attempts: 0 tries every model (#51, #65, by @BenediktChlopik).
  • long_context ranks by prompt + reply fit (#53).
  • Failover benchmark: make bench-failover measures what a failing provider costs (#62).

From v0.1.9: 24× faster routing (#42), model filters for context size and tool calling (#38), and a 16 MB memory ceiling for answers and cache (#43).

Use it with your tools

Anything that speaks the OpenAI API works. Point it at the proxy and use any API key, because the proxy holds the real ones:

export OPENAI_BASE_URL=http://localhost:8080/v1   # OpenAI SDKs, LangChain, most CLIs
export OPENAI_API_BASE=http://localhost:8080/v1   # older tools, e.g. aider
export OPENAI_API_KEY=unused                      # or your proxy.auth_token

In GUI tools (Continue, Cline, Open WebUI, LibreChat…), add an "OpenAI-compatible" provider with base URL http://localhost:8080/v1. GET /v1/models lists auto, every strategy, your agent profiles and all free models, so they show up in model pickers.

Run it beside PicoClaw on a $10 board

PicoClaw runs an AI agent on a Pi Zero or a Sipeed RISC-V board. It still needs a model API, and a single free tier runs dry fast. Run this proxy on the same board and PicoClaw gets every free tier you have, with fallback, through one local endpoint.

Add it to PicoClaw's config.json as a custom OpenAI-compatible provider (PicoClaw's provider docs):

{
  "model_list": [
    {
      "model_name": "free",
      "provider": "openai",
      "model": "auto",
      "api_base": "http://localhost:8080/v1",
      "api_keys": ["unused"]
    }
  ],
  "agents": { "defaults": { "model_name": "free" } }
}

Use "model": "coding", "speed" or any other strategy in place of auto.

Measured
Binary about 10 MB, static, no runtime (CGO_ENABLED=0; 10.3 MB on darwin/arm64, 1 Dec 2026)
Memory about 12 MB resident when idle (macOS arm64, bundled catalog of 1137 models loaded, 1 Dec 2026)
Routing overhead about 0.5 ms and 160 KB per request on one Jetson Orin Nano core, 3000-model catalog (BenchmarkChatCompletions_Buffered, 22 Nov 2026; was 12 ms and 2.5 MB in v0.1.8)
Memory ceiling requests, provider answers and the response cache are each capped at 16 MB
Prebuilt for linux/arm v6 (Pi Zero, Pi 1), v7 (32-bit Pi OS, LicheePi), linux/riscv64 (LicheeRV Nano), linux/arm64, amd64, as archives and .deb/.rpm/.apk

What failover costs you

How long a client waits for its first token when the first provider fails. Two local upstreams, the first one failing, 400 streaming requests per row, 16 concurrent clients, upstream first token after 25 ms, first-provider timeout 2 s (8-core Apple Silicon Mac, 27 Nov 2026):

First provider Completed p50 TTFT p95 TTFT p99 TTFT
no proxy (direct to upstream) 100% 26.2 ms 26.6 ms 26.7 ms
healthy 100% 26.7 ms 28.1 ms 29.9 ms
returns 429 100% 27.1 ms 28.0 ms 31.1 ms
stalls before its first token 100% 2028 ms 2032 ms 2036 ms

Each request starts with no health history here, so every one of them pays the fallback. In a running proxy the first failures put the provider on cooldown: after a 429, 11 of 400 requests still reached it; after a stall, 16 did (one per client in flight), and p95 fell back to 33 ms. A 429 costs about half a millisecond. A stall costs the provider's timeout, because the proxy cannot tell a slow first token from none, unless fallback.first_token_timeout is set (10 s in the example config): then a stream with no content token for that long moves on, and every reasoning chunk restarts the clock so a thinking model is not cut off. With first_token_timeout: 500ms in the same run, a stall cost 528 ms at p50 instead of 2028 ms; the healthy and 429 rows did not change. How to pick a value and what it costs: docs/first-token-timeout.md. Reproduce with make bench-failover (knobs: FAILOVER_BENCH_N, _CONC, _TIMEOUT, _UPSTREAM_TTFT, _FIRST_TOKEN).

The install script picks the right archive on the board itself. For mipsle, loong64 or other targets, cross-compile from any machine with Go and copy the result over:

CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags="-s -w" -o free-llm-proxy ./cmd/free-llm-proxy
scp -r free-llm-proxy configs/ user@board.local:~/free-llm-proxy-router/   # keep configs/ next to the binary

On an SD card, proxy.log_level: "warn" drops the per-request log lines.

Pick a strategy

Put a strategy name in the model field, or set the default in config.yaml:

Strategy Picks Good for
auto / adaptive reliability-weighted ranking that adjusts over time everyday use
performance the largest model available hard questions
speed fastest providers first (Cerebras, Groq) chat, autocomplete
volume highest daily request limits batch jobs
coding models with code capability coding agents
long_context largest context window first (small prompts can rank quality-first, off by default) long documents
balanced 14–79B models quality per token
small / tiny 3–13B / under 3B models low latency
reliable highest measured success rate unattended scripts
economical recharging free tiers before credit-based ones saving credits
similar the same model family as a reference model consistency
parallel the fastest model of each of the fan_out fastest providers, tried in turn spreading load across providers

Agent profiles bundle a strategy or a pinned model with defaults, so each tool can ask for its own name. The bundled config defines coding, summariser, reliable, long-context and precise:

proxy:
  agents:
    coding:
      strategy: "coding"
      defaults: { temperature: 0.2, max_tokens: 8192 }   # client values win
    summariser:
      strategy: "volume"
      overrides: { max_tokens: 512 }                      # always applied

A pinned model that has left the free catalog falls back to the profile's strategy instead of failing.

Filters drop models that cannot serve a request before the strategy ranks the rest (#13):

proxy:
  filters:
    - name: context-fit      # prompt + max_tokens, times margin, must fit the context window
      margin: 1.2
    - name: tool-calling     # requests with tools skip models known not to support them
      unknown: keep          # keep (default) or drop models without that metadata

Only OpenRouter reports tool support today, so other providers' models are "unknown". If no model is left, the openrouter/free router still runs where unknowns are kept (with require_parameters for tool requests); otherwise the client gets a 400 no_model_fits_request, since a retry would fail the same way. Filters are checked at startup and on reload, so a typo stops the proxy instead of failing requests.

Providers

One key is enough to start, and every extra key adds capacity. The providers that are on by default serve about 440 free models (scan of 22 Nov 2026). FREE_MODELS.md, refreshed every Monday, has the current count: about 480 free-tier models in all, plus about 620 that run on a free monthly credit (Vercel AI Gateway, BazaarLink and others); those providers, and a few smaller free ones, ship disabled. These providers are on by default and stay idle until their key is set:

Provider Free models (scan of 22 Nov 2026) Key env var Get a key
Mistral 50 MISTRAL_API_KEY console.mistral.ai
HuggingFace 50 HF_API_KEY huggingface.co/settings/tokens
GitHub Models 35 GITHUB_TOKEN any GitHub token
NVIDIA NIM 23 NVIDIA_API_KEY build.nvidia.com
Google AI Studio (Gemini) 21 GEMINI_API_KEY aistudio.google.com/app/apikey
OpenRouter 12 OPENROUTER_API_KEY openrouter.ai/settings/keys
Groq 10 GROQ_API_KEY console.groq.com/keys
Cerebras 2 CEREBRAS_API_KEY cloud.cerebras.ai
UnoRouter, LLM7, Api.Airforce, ModelScope, Hetzner see list see .env.example aggregators and smaller free tiers

GITHUB_TOKEN is a common variable: if it is set in your shell, the proxy uses it for GitHub Models.

About 25 more providers ship disabled in configs/config.example.yaml: gateways that also sell paid models, credit-based tiers, keyless endpoints and local servers (Ollama, LM Studio, llama.cpp…). Each has a comment saying why. Review one, then set enabled: true. For a gateway that mixes free and paid models, set discovery.free_markers (an ID suffix such as :free) or discovery.free_detect_field / free_detect_value (a field such as isFree), so that only its free models are cataloged.

Several keys per provider are pooled automatically: add GROQ_API_KEY_2, GROQ_API_KEY_3… and on a 429 the proxy retries the same model with the next key. Free tiers change often, so check each provider's own terms.

Install

Command
Install script (Linux, macOS) curl -fsSL https://raw.githubusercontent.com/kaiser-data/free-llm-proxy-router/main/scripts/install.sh | sh (read it first)
Docker (amd64, arm64) docker run --rm -p 127.0.0.1:8080:8080 -e GROQ_API_KEY=gsk_... ghcr.io/kaiser-data/free-llm-proxy-router:latest
Debian, Fedora, Alpine .deb, .rpm and .apk on the releases page
Archive (Linux, macOS, Windows) .tar.gz / .zip on the releases page; keep configs/ next to the binaries
From source git clone … && make build (binaries land in bin/)
Go go install github.com/kaiser-data/free-llm-proxy-router/cmd/free-llm-proxy@latest (binary only, so pass -c config.yaml)

Every package ships three binaries plus configs/ (the provider definitions and the free-model catalog):

Binary Does
free-llm-proxy the OpenAI-compatible proxy
free-llm-scan discovers free models, probes them, exports FREE_MODELS.md
free-llm-bench benchmarks every strategy across your providers
Package install, step by step
VERSION=0.1.8
# Debian/Ubuntu
curl -LO https://github.com/kaiser-data/free-llm-proxy-router/releases/download/v$VERSION/free-llm-proxy-router_${VERSION}_amd64.deb
sudo dpkg -i free-llm-proxy-router_${VERSION}_amd64.deb      # or: sudo rpm -i …rpm / sudo apk add --allow-untrusted …apk

# macOS on Apple Silicon, from the archive
curl -LO https://github.com/kaiser-data/free-llm-proxy-router/releases/download/v$VERSION/free-llm-proxy-router_${VERSION}_darwin_arm64.tar.gz
tar xzf free-llm-proxy-router_${VERSION}_darwin_arm64.tar.gz && ./free-llm-proxy --help

Keys and config

Keys are read from, first match wins:

  1. environment variables (export GROQ_API_KEY=...)
  2. .env in the working directory (see .env.example for every supported key)
  3. ~/.free-llm-proxy-router/.env or .secrets, which work from any directory

Config is read from -c path, ./config.yaml or ~/.free-llm-proxy-router/config.yaml, and falls back to the bundled configs/config.example.yaml. Start it with -c path/to/config.yaml and most edits apply without a restart (auth_token and host need one). bash scripts/setup.sh writes a starter config to ~/.free-llm-proxy-router/.

proxy:
  strategy: "adaptive"   # default when a request says "auto"
  host: "127.0.0.1"      # "0.0.0.0" to expose it, and then set auth_token too
  port: 8080
  auth_token: ""         # when set, clients must send it as their API key

It spends your quotas, so it listens on 127.0.0.1 by default. To reach it from other machines, use --host 0.0.0.0 and set a token. Without one it refuses to start on a non-loopback host; pass --allow-no-auth (or set proxy.allow_no_auth: true) only if access is already restricted, e.g. by a firewall or VPN. PROXY_AUTH_TOKEN in the environment or .env overrides proxy.auth_token, so the token never has to sit in a config file you might commit (docker run -e PROXY_AUTH_TOKEN=… works the same way). The Docker image listens on all interfaces inside the container, so publish its port to 127.0.0.1 as shown above.

Keep the catalog fresh

./bin/free-llm-scan update        # rescan your providers, write the catalog
./bin/free-llm-scan export-md     # render it as a Markdown list

Or let one machine scan on a schedule and every other machine pull the result: see catalog.git_sync in the config. Before enabling a gateway that also sells paid models, check that its config entry sets free_markers or free_detect_field (see Providers); without one, the scan catalogs every model it lists.

API

Endpoint Does
POST /v1/chat/completions chat, streaming or not, routed through the fallback chain
GET /v1/models auto, strategies, agent profiles and every free model
GET /health liveness check
Response header Means
X-Used-Model the model that actually answered
X-Cache: HIT served from the short response cache (at most 16 MB): non-streaming requests without tools, with temperature 0 or unset and n ≤ 1
X-Proxy-Exhausted + Retry-After every free model failed (503); retry after that many seconds
Architecture
sequenceDiagram
    participant T as Your tool
    participant P as free-llm-proxy
    participant S as Strategy
    participant A as Provider A
    participant B as Provider B
    T->>P: POST /v1/chat/completions {"model":"auto"}
    P->>S: rank the free catalog
    S-->>P: ranked models, cooled-down ones skipped
    P->>A: buffered request
    A-->>P: 429 Too Many Requests
    Note over P: cooldown until the reset time, rotate key
    P->>B: same request, next model
    B-->>P: 200
    P-->>T: 200 (or SSE chunks), X-Used-Model
Loading
cmd/
  free-llm-proxy/   the proxy server
  free-llm-scan/    free-model discovery, probing, FREE_MODELS.md export
  free-llm-bench/   strategy benchmark
pkg/
  proxy/            HTTP handlers, fallback chain, SSE re-emission, cache
  strategy/         the routing strategies
  catalog/          catalog model, persistence, hot reload, git sync
  scan/             one scanner per provider API
  ratelimit/        rate-limit header parsing, cooldowns, daily usage
  reliability/      per-provider success rates
  config/           config loading, key discovery, hot reload
configs/            bundled config and the free-model catalog

Honest limits

  • Free tiers are small, and they change. The proxy makes the most of them. It does not create capacity, and it is not a fit for production traffic with an SLA.
  • A stream that breaks after its first token cannot fall back. The client already has part of the answer, so the stream ends with an SSE error event (stream_interrupted), never with a clean end that would look like a complete answer. That includes a provider that closes its connection cleanly before sending [DONE] or a finish_reason. Gemini is still buffered (its thought blocks are stripped from the full answer) and re-emitted as SSE.
  • The catalog can lag a provider's change by up to a week. Models that vanish are cooled down on the first 404 and skipped.
  • A provider that stalls before its first token costs fallback.first_token_timeout (10 s in the example config) before the fallback starts, or its full timeout (15–30 s) when that is off and for non-streaming requests, which have no first token to watch. After that the model is cooled down and skipped. A free model that is merely queued longer than first_token_timeout is dropped the same way; raise it if that costs you answers. See First-token timeout.
  • Local quota tracking is best-effort. The proxy honours the providers' rate-limit headers, but under heavy concurrency a provider may still send the occasional 429, which simply triggers the fallback.

Development

go test -race ./...    # 184 tests
go vet ./...
make build

Next: Gemini tool-call signatures across turns (#30) · OpenRouter models[] capped at 3 (#33) · ranking only the top candidates instead of the whole catalog.

Contributors

Thank you to everyone who has helped make this better. Every report, review and pull request has shaped how the proxy behaves today.

  • @zedtux:
    • free-model detection for gateways that mix free and paid models (#34);
    • the UnoRouter provider (#36) and its consent and credit errors (#35);
    • PROXY_AUTH_TOKEN (#31) and shorter cooldowns after a daily reset (#32);
    • a private request body for every provider attempt (#25) and max_completion_tokens handling (#18).
    • In progress: Gemini thought signatures for multi-turn tool calls (#30) and a tighter OpenRouter fallback (#33).
  • @BenediktChlopik:
    • model filters for context fit and tool calling (#26, merged in #38), which started with their request for intelligent model routing (#13);
    • empty-completion detection, so a 200 with no content is never passed off as an answer (#14, #16, #17);
    • new free providers (#12, #15);
    • answering other users in the issue tracker (#1).
  • @oomplay: the first UnoRouter integration and the idea of canonical model aliases (#2).
  • @Ludwik900: the first bug report, a scan that found no models (#1). It showed that a scan without a config still reported success with 0 entries.

Acknowledgments

Free-tier limits and change tracking are informed by cheahjs/free-llm-api-resources, the community reference for free LLM APIs.


Built by kaiser-data · MIT licensed · Issues and PRs welcome
Keys stay in your environment or .env; never commit them.

About

One small Go binary that turns every free LLM tier (Groq, Gemini, OpenRouter, Cerebras, GitHub Models…) into a single OpenAI-compatible endpoint with automatic fallback.

Topics

Resources

Stars

29 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages