{"slug": "run-claude-code-and-the-openai-sdk-on-free-llm-tiers-with-freellmapi", "title": "Run Claude Code and the OpenAI SDK on free LLM tiers with FreeLLMAPI", "summary": "A developer released FreeLLMAPI, a self-hosted server that aggregates the free tiers of 34 LLM providers behind a single OpenAI-compatible /v1 API, with Anthropic wire-format support so Claude Code and the Anthropic SDKs can run against the pooled free quota. The router stores provider keys AES-256-GCM encrypted in SQLite, routes each request to the highest-priority healthy model, and fails over to the next provider on 429 or 5xx errors while tracking per-key usage against free-tier caps. The README claims the stacked total reaches roughly 7.4 billion tokens a month across 635 free model endpoints.", "body_md": "Almost every AI lab now has a free tier: a few million tokens a month, a few thousand requests a day. One tier on its own is a toy. Stacked together behind one endpoint, they are enough to run side projects, experiments and even a coding agent without a bill. That is the idea behind FreeLLMAPI.\n\n[tashfeenahmed/freellmapi](https://github.com/tashfeenahmed/freellmapi) is a self-hosted server that aggregates the free tiers of 34 LLM providers behind a single OpenAI-compatible `/v1` API. Per the README it stores your provider keys encrypted, routes each request to the best available model, falls over to the next provider when one is rate-limited, and tracks per-key usage so you stay under every free-tier cap. The README puts the stacked total at roughly 7.4 billion tokens a month across 635 free model endpoints.\n\nThis post covers the install, connecting Claude Code, and calling it from Python.\n\nYou add keys for the providers you want (Google, Groq, Cerebras, Mistral, OpenRouter, Cloudflare, Cohere, NVIDIA, Hugging Face and more) and order them in a fallback chain. For each request the router picks the highest-priority model with a healthy key that is under all its rate limits, decrypts the key in memory and calls the provider. On a 429 or 5xx it cools that key down and retries the next model in your chain.\n\nA few details make it practical for agents:\n\n`/v1/responses` (what Codex CLI needs), `/v1/embeddings`, image, speech and transcription endpoints, and `/v1/models`.`/v1/messages` speaks Anthropic's wire format, so Claude Code and the Anthropic SDKs can run against the free pool.`freellmapi-` bearer key. Provider keys are AES-256-GCM encrypted in SQLite.\nWith Docker, the one-liner sets up `~/freellmapi`, generates an encryption key, pulls the image and starts the container:\n\n```\ncurl -fsSL https://freellmapi.co/install.sh | bash\n```\n\nRead the script first if you prefer; the README links it. Re-running it keeps your `.env` and encryption key and updates the container.\n\nOn Windows or macOS there is also a desktop tray app on the Releases page, which runs the router and dashboard locally with no account to set up. From source:\n\n```\nnpm install && npm run dev\n```\n\nThat gives you the server on port 3001 and the dashboard on 5173.\n\nOpen [http://localhost:3001](http://localhost:3001), add provider keys on the **Keys** page, reorder the **Fallback Chain**, and copy the unified API key from the Keys page header. The Playground shows which provider served each test message, with model ID and latency, which is a quick way to confirm your keys work.\n\nThe README gives a setup command that reads your live catalog, backs up the existing config and merges into it:\n\n```\nnpx freellmapi setup-claude --url http://localhost:3001 --api-key <unified-key>\n```\n\nEvery generator supports `--dry-run` so you can see the change first. If you would rather keep credentials out of config files, `npx freellmapi launch` starts Claude Code against the router and `launch-codex` does the same for Codex. The supported list also covers Gemini CLI, Cursor, Cline, Roo Code, OpenCode, Aider, Goose, Crush, Zed and more.\n\nAny OpenAI client works. Set the base URL to your server:\n\n``` python\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"http://localhost:3001/v1\",\n    api_key=\"freellmapi-your-unified-key\",\n)\n\nresp = client.chat.completions.create(\n    model=\"auto\",  # or \"auto:fast\", \"auto:smart\", a profile, or a model id\n    messages=[{\"role\": \"user\", \"content\": \"Summarise the fall of Rome in one sentence.\"}],\n)\nprint(resp.choices[0].message.content)\n```\n\nEvery response carries an `X-Routed-Via: <platform>/<model>` header, so you can log which provider actually answered.\n\nFrom the builds tracked on the [FreeLLMAPI page](https://dedupedai.com/use-cases/tashfeenahmed-freellmapi/?utm_source=devto&utm_medium=article&utm_campaign=howto_freellmapi):\n\nThey overlap but aim at different jobs. [LiteLLM](https://dedupedai.com/use-cases/berriai-litellm/?utm_source=devto&utm_medium=article&utm_campaign=howto_freellmapi) is an AI gateway and Python SDK for calling 100+ providers through one OpenAI-format interface, with cost tracking, guardrails and load balancing, and it is the usual pick when you are paying for production traffic. FreeLLMAPI is local-first and single-user by design, and its catalog and router are built specifically around free-tier quotas.\n\nSource repo: [tashfeenahmed/freellmapi](https://github.com/tashfeenahmed/freellmapi). License: MIT.\n\nWant the setup commands for 50 AI repos people actually ship with? Get the free AI Repos That Actually Ship pack: [https://dedupedai.com/ship-pack/?utm_source=devto&utm_medium=article&utm_campaign=shippack](https://dedupedai.com/ship-pack/?utm_source=devto&utm_medium=article&utm_campaign=shippack)", "url": "https://wpnews.pro/news/run-claude-code-and-the-openai-sdk-on-free-llm-tiers-with-freellmapi", "canonical_source": "https://dev.to/dedupedai/run-claude-code-and-the-openai-sdk-on-free-llm-tiers-with-freellmapi-3ek1", "published_at": "2026-11-04 04:10:12+00:00", "updated_at": "2026-11-04 04:22:16.628460+00:00", "lang": "en", "topics": ["ai-tools", "large-language-models", "ai-agents", "developer-tools", "ai-infrastructure"], "entities": ["FreeLLMAPI", "tashfeenahmed", "Claude Code", "OpenAI", "Anthropic", "Google", "Groq", "LiteLLM"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/run-claude-code-and-the-openai-sdk-on-free-llm-tiers-with-freellmapi", "markdown": "https://wpnews.pro/news/run-claude-code-and-the-openai-sdk-on-free-llm-tiers-with-freellmapi.md", "text": "https://wpnews.pro/news/run-claude-code-and-the-openai-sdk-on-free-llm-tiers-with-freellmapi.txt", "jsonld": "https://wpnews.pro/news/run-claude-code-and-the-openai-sdk-on-free-llm-tiers-with-freellmapi.jsonld"}}