How to Get Free AI Tokens with FreeLLMAPI and Use Them to Code with Bun, Codex or Claude Code
Stack dozens of free tiers into one OpenAI- and Anthropic-compatible endpoint with FreeLLMAPI, then code for free with Bun, Codex CLI and Claude Code.
Table of Contents
- → What FreeLLMAPI actually is
- → How many tokens can you really get?
- → 1. Collect free provider keys
- → 2. Install FreeLLMAPI
- → 3. Add keys & grab unified key
- → 4. Use it from Bun
- → 5. Use it with Claude Code
- → 6. Use it with Codex CLI
- → Making free tokens last
- → Limits and trade-offs
- → Frequently asked questions
- → Quick-start checklist
What FreeLLMAPI actually is
- OpenAI-compatible API. It serves the usual chat completions endpoint, plus the Responses endpoint that Codex CLI needs.
- Anthropic Messages API. It also speaks Anthropic’s wire format, so Claude Code and the official Anthropic SDKs can run against your free pool.
- Smart routing and failover. You can use
model: "auto"and let the router choose, or pick a strategy such as fast or smart. - Per-key usage tracking. It counts requests and tokens per provider key so you stay under each cap.
- Local-first. Your provider keys are stored encrypted in a local database, and requests go from your machine straight to the providers you enabled.
How many tokens can you really get?
| Providers with keys | Realistic expectation |
|---|---|
| 2 to 3 big names (for example Google AI Studio and Groq) | Low hundreds of millions of tokens a month |
| 8 to 10 providers | Approaching the billion-token range |
| 20+ providers | Billions on paper, but more accounts to manage |
- Monthly token budget: 135.0M
- Used: 59.5M (56 percent of the budget)
- Remaining: 75.5M
- Chat models in the pool: 19, plus more with no published quota
- Coding agents are token-hungry. An agent resends large chunks of context on every turn, so a single session can burn through far more tokens than a chat does. A budget that feels huge for chatting can drain quickly under an agent.
- Quotas move. Providers launch, retire and re-tier models without warning. When a provider tightens a limit, you will see 429 errors until the catalog catches up.
Step 1: Collect your free provider keys
- One account per provider. Do not create multiple accounts to multiply a quota.
- Do not resell or share access. Your unified key is for you.
- Do not power a production service on free tiers. This setup is for learning, prototyping and personal projects.
- Mind your data. Free tiers differ in how they treat your prompts, and some may use them to improve their products. Check each provider’s policy, and avoid sending secrets, customer data or proprietary code through free endpoints. If privacy is the priority, a fully local model is the safer choice.
Step 2: Install FreeLLMAPI
Option A: Docker one-liner (macOS, Linux, Windows with Docker).
curl -fsSL https://freellmapi.co/install.sh | bashThis sets up a folder in your home directory, generates an encryption key, pulls the image and starts the container.
Option B: Desktop app (the easiest on Windows). The project ships a signed desktop app on the Microsoft Store and a macOS build on its GitHub releases page. It runs the router and dashboard from your tray, and you only need the unified API key from the tray popover.
Option C: From source (Node.js 20 or newer).
git clone https://github.com/tashfeenahmed/freellmapi.git
cd freellmapi
npm install
cp .env.example .env
printf "ENCRYPTION_KEY=$(openssl rand -hex 32)\nPORT=3001" >> .env
npm run devhttp://localhost:3001. The desktop app serves its dashboard on a different local port, so open it from the tray icon instead.Step 3: Add keys and grab your unified key
- Open the dashboard and go to the Keys page.
- Click Add key, choose a provider, and paste its key. FreeLLMAPI checks each key and shows a status indicator.
- Copy your unified API key from the Keys page header. This single
freellmapi-key is the only credential your tools will ever see. - Open the Models page. Choose a routing strategy (Balanced is a sensible default) and check the monthly token budget bar at the top. This is your real number.
auto:<profile>.Step 4: Use it from Bun
.env loading. Because FreeLLMAPI looks like the OpenAI API, any Bun project can use it with a one-line change.bun init -y
bun add openai.env file. Bun loads it automatically, and you should add .env to .gitignore:FREELLMAPI_URL=http://localhost:3001/v1
FREELLMAPI_KEY=freellmapi-your-unified-keyindex.ts:import OpenAI from "openai";
const client = new OpenAI({
baseURL: process.env.FREELLMAPI_URL,
apiKey: process.env.FREELLMAPI_KEY,
});
const { data, response } = await client.chat.completions
.create({
model: "auto", // let the router choose; try "auto:fast" or "auto:smart"
messages: [
{ role: "system", content: "You are a careful senior TypeScript engineer." },
{ role: "user", content: "Write a Bun function that debounces an async callback." },
],
})
.withResponse();
console.log(data.choices[0].message.content);
console.log("Served by:", response.headers.get("x-routed-via"));bun run index.tsx-routed-via header tells you which provider and model actually answered, which is handy for seeing failover in action. If you would rather avoid a dependency, plain fetch works too, since the endpoint is standard JSON over HTTP.- Use streaming for anything interactive. Free providers vary in speed, and streaming makes slower ones feel fine.
- Handle 429s gracefully. The router retries across providers, but a short retry with backoff in your own code is cheap insurance.
- Use
auto:smartfor hard prompts andauto:fastfor quick ones. Strategy names are documented in the project's API reference. - Use Bun's test runner (
bun test) to have the model write tests, then run them immediately to check its work.
Step 5: Use it with Claude Code
Zero-persistence launcher (recommended). This starts Claude Code with the credentials injected into that process only, so nothing is written to your config files:
npx freellmapi launchConfig generator. This reads your live model catalog, backs up your existing Claude Code settings and merges in the new ones:
npx freellmapi setup-claude --url http://localhost:3001 --api-key <your-unified-key>--dry-run flag, so preview the changes before applying them. If you use Bun as your package runner, bunx generally runs npm packages too, but the project documents npx, so use that if anything misbehaves.Step 6: Use it with Codex CLI
npx freellmapi launch-codexnpx freellmapi setup-codex--dry-run first if you want to see what will change. Once connected, Codex sends its requests to your local router, which spreads them across your free providers.http://localhost:3001/v1 and the API key to your unified key.Making your free tokens last
- Match the model to the job. Use fast, small models for boilerplate and renames, and save the strongest ones for design and debugging.
- Keep context small. Work in focused folders, ask for diffs instead of whole files, and start fresh sessions rather than letting context balloon. Using progressive disclosure with custom AI agent skills (SKILL.md) also avoids repeating long instructions on every turn.
- Turn on prompt compression if you want it. FreeLLMAPI has an opt-in pipeline that deduplicates prompts and trims stale context.
- Watch the budget bar. Check the Models page now and then so you know when you are close to the cap.
- Expect a late-day dip. The router's own docs note that effective model quality can drop later in the day as top models hit daily caps, then recover after the UTC reset.
- Add more providers over time rather than all at once. Each one is more headroom and more redundancy.
Limits and trade-offs
- No frontier models. You get capable open and free-tier models, not the very best cloud models.
- Variable speed and quality. Failover can move you to a slower or weaker model mid-session.
- No guarantees. Free tiers have no SLA, and quotas change without notice.
- Not for production. If a project grows real users, move to a paid, supported API.
- Security basics. Keep the router bound to your own machine unless you know what you are doing, keep your unified key private, and never commit
.envfiles. - Catalog freshness. Free installs receive the model catalog on a monthly snapshot, so new models arrive about 30 days after they appear in the live feed. The project offers a paid option for same-day updates, but the router itself is free and fully usable without it.
Frequently asked questions
Quick-start checklist
- Sign up for a few free provider tiers and create API keys.
- Install FreeLLMAPI (Docker, desktop app or from source).
- Add your keys on the Keys page and copy the unified key.
- Check the monthly token budget on the Models page.
- Point a Bun script at
http://localhost:3001/v1withmodel: "auto". - Connect Claude Code with
npx freellmapi launch, or Codex withnpx freellmapi launch-codex. - Add providers gradually, and keep sensitive code off free endpoints.
Using a different coding agent or a provider I did not cover? Get in touch and it might become the next guide in the Observatory.