Observatory
Build Logs·Nov 22, 2026·9 min read

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.

free AI tokensfree AI API keyhow to use Claude Code for freefree AI coding assistantfree LLM APIFreeLLMAPIfree AI codingClaude Code freeCodex CLI freeBunOpenAI APIlocal AI setup
One local endpoint, dozens of free tiers stacked together, and a coding setup that costs nothing to try.
Every serious AI lab now hands out a free tier: a few million tokens a month, a few thousand requests a day. On its own, each one is a toy. Stacked together, they become something you can actually build with.
That is the idea behind FreeLLMAPI, an open-source, self-hosted router that puts many free tiers behind a single OpenAI-compatible endpoint on your own machine. In this guide you will set it up, see what a realistic token budget looks like (it is not always the headline number), and point three coding tools at it: a Bun project, Codex CLI and Claude Code.
A quick honesty note before we start. FreeLLMAPI does not create tokens out of thin air. It combines the free allowances you already have across providers, using your own keys. The impressive totals on the project page assume you have signed up with a lot of providers. Most people will have less, and that is fine. (If you prefer to run entirely offline models directly on your hardware without keys or quotas, check out my guide on how to run AI locally on PC.)

What FreeLLMAPI actually is

FreeLLMAPI is a local router with a dashboard. You add API keys from providers that offer free tiers, and it gives you one endpoint and one unified key. When your tool sends a request, the router picks a healthy model that is still under its rate limits, calls the provider, and if that provider returns a rate-limit or server error, it fails over to the next model in your chain.
The parts that matter for coding:
  • 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.
It is built for personal experimentation, and its own documentation says so. Keep that in mind; we come back to it in the ground rules below.

How many tokens can you really get?

The project’s headline figure has grown over time as more providers were added. Different write-ups in 2026 quote anywhere from several hundred million to billions of tokens a month, depending on the version and on how many providers they counted. The current README lists roughly 10 billion tokens a month of listed free capacity across 87 providers. Treat all of those as theoretical ceilings.
What you get is the sum of the free allowances on the providers you personally sign up for. A useful way to think about it:
Providers with keysRealistic expectation
2 to 3 big names (for example Google AI Studio and Groq)Low hundreds of millions of tokens a month
8 to 10 providersApproaching the billion-token range
20+ providersBillions on paper, but more accounts to manage
For a real data point, here is a dashboard reading with just two providers configured, Google AI Studio and Groq:
  • 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
The pool included several Gemini and Gemma models with around 3M tokens each, a couple of Gemma 4 entries at 30M each, and Groq models such as GPT-OSS 20B and 120B and a Qwen model at 6M each. So with only two providers, the budget landed in the low hundreds of millions, which is plenty for a lot of coding. Reaching about 1 billion a month means adding more providers, such as Cerebras, Mistral, OpenRouter, Cloudflare, NVIDIA, Cohere and others, each with its own free key.
Two things to keep in mind about the numbers:
  1. 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.
  2. 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

Sign up for the free tiers you want and create an API key on each. Good starting points are the ones with generous, reliable free access: Google AI Studio, Groq, Cerebras, Mistral, OpenRouter, Cloudflare Workers AI and NVIDIA’s hosted models. The FreeLLMAPI catalog at freellmapi.co/models lists current free models, limits and context windows, and flags the ones that need extra steps (some providers need regional account binding or have restrictive terms).
A few ground rules that keep you on the right side of provider terms:
  • 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

Pick whichever install suits your machine.

Option A: Docker one-liner (macOS, Linux, Windows with Docker).

curl -fsSL https://freellmapi.co/install.sh | bash

This 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 dev
For Docker and source installs, open http://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

  1. Open the dashboard and go to the Keys page.
  2. Click Add key, choose a provider, and paste its key. FreeLLMAPI checks each key and shows a status indicator.
  3. Copy your unified API key from the Keys page header. This single freellmapi- key is the only credential your tools will ever see.
  4. 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.
You can also drag models into a custom order in manual mode, or create named fallback chains, for example a coding chain, and call them with auto:<profile>.

Step 4: Use it from Bun

Bun is a fast JavaScript and TypeScript runtime with a built-in package manager, test runner and automatic .env loading. Because FreeLLMAPI looks like the OpenAI API, any Bun project can use it with a one-line change.
Create a project and add the OpenAI SDK:
bun init -y
bun add openai
Put your settings in a .env file. Bun loads it automatically, and you should add .env to .gitignore:
FREELLMAPI_URL=http://localhost:3001/v1
FREELLMAPI_KEY=freellmapi-your-unified-key
Then write index.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"));
Run it with:
bun run index.ts
The x-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.
A few practical tips for Bun projects:
  • 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:smart for hard prompts and auto:fast for 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

Claude Code talks to an Anthropic-style API, and FreeLLMAPI exposes one. The project provides two ways to connect.

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 launch

Config 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>
Every generator supports a --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.
What to expect: you are running the Claude Code interface, but the model doing the thinking is whatever free model the router picked, not a Claude model. Quality will be a step below the frontier, and agent loops that depend on reliable tool calling can wobble on weaker models. The router tries to rescue tool calls that come back as plain text, but it is not magic.

Step 6: Use it with Codex CLI

Codex CLI needs the Responses API, which FreeLLMAPI supports. The same two options apply:
npx freellmapi launch-codex
or, to write the configuration:
npx freellmapi setup-codex
Again, run the generator with --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.
If you use other agents, the project lists setup commands for many of them, including Cline, Roo Code, Aider, OpenCode, Continue, Gemini CLI and Cursor, plus any tool that accepts an OpenAI-compatible base URL. The universal recipe is the same everywhere: set the base URL to http://localhost:3001/v1 and the API key to your unified key.

Making your free tokens last

Coding agents can burn a month of free quota in a few sessions. A few habits stretch the budget:
  • 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

Be clear-eyed about what this is:
  • 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 .env files.
  • 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

  1. Sign up for a few free provider tiers and create API keys.
  2. Install FreeLLMAPI (Docker, desktop app or from source).
  3. Add your keys on the Keys page and copy the unified key.
  4. Check the monthly token budget on the Models page.
  5. Point a Bun script at http://localhost:3001/v1 with model: "auto".
  6. Connect Claude Code with npx freellmapi launch, or Codex with npx freellmapi launch-codex.
  7. 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.