Quick answer
Install Free-LLM Router, then give OpenAI SDK (Python and JavaScript) its address. Where: Two constructor arguments, or two environment variables. Model: auto.
Why OpenAI SDK (Python and JavaScript) and free plans need a go-between
If your code already uses the OpenAI SDK, two arguments change and nothing else: the base URL and the key. The model becomes auto, or a specific free model when you need the same one every time.
Option 1: through Free-LLM Router
The router is a small open-source program that runs on your computer. Tools talk to one local address; behind it, 397 free models from 69 providers are available, depending on the free keys you add.
1. Install Free-LLM Router
One line, no admin rights, and no Node.js to set up first: the installer brings a private copy if you have none. The first run sends a real question to a free model and shows the answer before asking you for anything.
Windows (PowerShell)
irm https://free-llm.com/install.ps1 | iex
macOS / Linux
curl -fsSL https://free-llm.com/install.sh | sh
2. Add two or three free keys
Optional to start: guest mode answers with no key, slowly. For real work, add free keys in the dashboard at http://localhost:4000 (Google AI Studio, Groq and OpenRouter need no card). Each key is tested when you paste it. The API keys page shows where to click for each provider.
3. Change the base URL and the key
In Python, OpenAI(base_url=..., api_key=...); in JavaScript, new OpenAI({ baseURL, apiKey }). Both are shown below with a complete request.
4. Or use environment variables
Export OPENAI_BASE_URL and OPENAI_API_KEY: code and tools that read them need no edit at all.
The exact settings
Replace YOUR_ROUTER_KEY with the router key shown on the first screen of the dashboard (or by free-llm config). It is created on your computer at install; there is nothing to sign up for.
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:4000/v1", api_key="YOUR_ROUTER_KEY")
r = client.chat.completions.create(
model="auto", # or auto:coding, auto:fast, deepseek-v4-flash, …
messages=[{"role": "user", "content": "Hello!"}],
)
print(r.choices[0].message.content)
JavaScript (OpenAI SDK)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "http://127.0.0.1:4000/v1", apiKey: "YOUR_ROUTER_KEY" });
const r = await client.chat.completions.create({
model: "auto",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(r.choices[0].message.content);
curl
curl http://127.0.0.1:4000/v1/chat/completions \
-H "Authorization: Bearer YOUR_ROUTER_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"auto","messages":[{"role":"user","content":"Hello!"}]}'
Environment variables
export OPENAI_BASE_URL=http://127.0.0.1:4000/v1
export OPENAI_API_KEY=YOUR_ROUTER_KEY
export ANTHROPIC_BASE_URL=http://127.0.0.1:4000
export ANTHROPIC_AUTH_TOKEN=YOUR_ROUTER_KEY
The same text is printed on your machine, with your real address and key filled in, by free-llm connect and on the dashboard's Connect your tools page.
Good to know
- The model can be a profile (
auto,auto:coding,auto:fast) or a model id such asdeepseek-v4-flash.
What happens when a free plan runs out
Free plans are small: a few requests per minute, a daily cap, sometimes a size limit per request. When a provider answers with a rate limit, an exhausted quota, an error or a timeout, the router sends the same request to the next free model that is up. OpenAI SDK (Python and JavaScript) receives a normal answer and never sees the error. The Activity page of the dashboard shows which model answered each request and what was skipped on the way.
Option 2: one free provider, directly
The same two arguments point the SDK at one provider: its base URL from the table and your key, with one of its model ids.
| Provider | Sign-up | Free limits | Free models | Base URL |
|---|---|---|---|---|
| Google AI Studio | No card | 5-30 RPM (varies by model) | 8 | https://generativelanguage.googleapis.com/v1beta/openai |
| Groq | No card | 30 RPM, 1,000 requests/day | 6 | https://api.groq.com/openai/v1 |
| OpenRouter | No card | 20 requests/minute | 14 | https://openrouter.ai/api/v1 |
| NVIDIA NIM | Phone check | 40 requests/minute | 16 | https://integrate.api.nvidia.com/v1 |
| Cloudflare Workers AI | No card | Varies by model | 16 | https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1 |
| Cohere | No card | 20 requests/minute | 10 | https://api.cohere.ai/compatibility/v1 |
| Kilo AI Gateway | No card | 200 requests/hour per IP on free models (works without an account) | 11 | https://ai-gateway.kilo.ai/api/v1 |
Live from the Free-LLM directory, December 5, 2026. Limits change often: the provider page has the details and the sources. All free APIs
The trade-off is simple. One provider means one set of limits: when it says "too many requests", you wait. The router keeps several of these plans behind the same address, so the wait becomes a switch.
OpenAI SDK (Python and JavaScript): common questions
Do I need a different library for free models?
openai package for Python or JavaScript is enough: only the base URL and the key change.Can I ask for one specific model instead of auto?
deepseek-v4-flash, or provider/model. By default the router may still answer with another free model if that one is unavailable.Does streaming work?
stream=True behaves as it does with OpenAI.Other tools on free models
Anthropic SDK
Two constructor arguments, or two environment variables.
MCP server
One command in Claude Code, or a JSON block in any MCP client.
Claude Code
One command writes the settings into ~/.claude/settings.json.
Codex CLI
A provider and a profile in ~/.codex/config.toml.
OpenCode
A provider entry in OpenCode's opencode.json.
Aider
Three flags on the command line, or ~/.aider.conf.yml.