A self-hosted proxy that speaks both the OpenAI and Anthropic wire formats, aggregating the free tiers of sixteen LLM providers behind a single API key — with smart routing, automatic failover, encrypted keys, and built-in agent tools.
Same gateway, same unified key. Speak OpenAI, speak Anthropic, or generate an image — it routes to whichever free provider can serve it and fails over when one is rate-limited.
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:3001/v1",
api_key="freellmapi-your-unified-key",
)
resp = client.chat.completions.create(
model="auto", # let the router pick the best free model
messages=[{"role": "user", "content": "Explain MoE routing in one line."}],
)
print(resp.choices[0].message.content)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "http://localhost:3001",
apiKey: "freellmapi-your-unified-key",
});
const msg = await client.messages.create({
model: "claude-sonnet-4-5", // unknown ids fall through to auto-routing
max_tokens: 1024,
messages: [{ role: "user", content: "Say hi from a free provider." }],
});
console.log(msg.content);curl http://localhost:3001/v1/chat/completions \
-H "Authorization: Bearer freellmapi-your-unified-key" \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"stream": true,
"messages": [{"role": "user", "content": "Hello!"}]
}'# OpenAI Images shape — keyless, saved server-side, returns a path + URL
curl http://localhost:3001/v1/images/generations \
-H "Authorization: Bearer freellmapi-your-unified-key" \
-H "Content-Type: application/json" \
-d '{ "prompt": "a neon koi over a circuit-board reef", "aspect": "16:9" }'OpenAI (/v1/chat/completions, /v1/responses) and Anthropic (/v1/messages) over the same routing, retry, and cooldown machinery.
On a 429, 5xx, or timeout the router skips the provider, cools the key down, and retries the next model — up to 20 attempts.
Gateway-run web_search, web_extract, and generate_image turn plain chat into an agent — generated images render inline.
Opt-in TTL cache returns identical requests instantly with X-Cache: HIT and no provider call — streaming replays as SSE.
Provider keys are AES-256-GCM encrypted in SQLite; apps only ever see one unified freellmapi-… bearer token.
Manage keys, drag the fallback chain, watch latency percentiles, cache hit-rate, and a live request log — dark & light.
➕ Point at any OpenAI-compatible endpoint too — llama.cpp, LM Studio, vLLM, a local Ollama, or a remote gateway — straight from the Keys page.




Docker Compose serves the API + dashboard on port 3001, SQLite in a named volume.
Open the dashboard, paste provider keys (many work anonymously), order the fallback chain.
Swap base_url to your gateway and use the one unified key. Done.
git clone https://github.com/Hansade2005/FreeAIGateway.git
cd FreeAIGateway
# generate an at-rest encryption key for your provider keys
ENCRYPTION_KEY="$(openssl rand -hex 32)"
printf "ENCRYPTION_KEY=%s\nPORT=3001\n" "$ENCRYPTION_KEY" > .env
docker compose up -d # → http://localhost:3001Self-hosted, single-user, MIT-licensed. One endpoint, two protocols, ~1.7B free tokens a month.