A familiar interface.
Use the native FreeLLM client, the OpenAI compatibility shim, or freelm serve: a local OpenAI-compatible endpoint for any tool.
A Python and Node.js LLM client that pools multiple providers, rotates keys, and handles failover behind an OpenAI-compatible interface.
pip install freelmimport freelm
llm = freelm.FreeLLM.from_env()
print(llm.text("Explain black holes."))npm install freelmimport { FreeLLM } from "freelm";
const llm = FreeLLM.fromEnv();
console.log(await llm.text("Explain black holes."));The package is MIT licensed. Provider eligibility, model availability, quotas, and pricing depend on your account and can change. Set only the providers you want to use.
Use the native FreeLLM client, the OpenAI compatibility shim, or freelm serve: a local OpenAI-compatible endpoint for any tool.
Key rotation, cross-provider failover, circuit breakers, quota guards, and retired models set aside automatically.
A slow or hung provider is raced against the next one, and smart routing sends later calls to the fastest. freelm doctor checks every key live; no keys falls back to keyless endpoints.
freelm is a free, open-source LLM client and gateway for Python (pip install freelm) and Node.js/TypeScript (npm install freelm). It pools the free tiers of Google AI Studio (Gemini), Groq, OpenRouter, Cloudflare Workers AI, Mistral, NVIDIA NIM, Z.ai, Cohere and Kilo behind a single OpenAI-compatible call, and can also run as a local OpenAI-compatible endpoint (freelm serve) for tools that only speak HTTP. It handles API-key rotation, cross-provider failover, circuit breaking, quota-aware routing, retired-model handling and live free-model discovery automatically. You supply whichever free keys you have and freelm keeps your application talking to an LLM even when one provider rate-limits, retires a model or goes down. It is MIT-licensed and maintained by Shahriar Labs.
Yes. Run freelm serve (or npx freelm serve, or the ghcr.io/shihabshahrier/freelm Docker image) to get a local OpenAI-compatible endpoint at http://127.0.0.1:4000/v1 with /v1/chat/completions (including streaming) and /v1/models. Point any OpenAI-compatible tool at that base URL with model auto. Tools that call the endpoint from their own servers need a public URL and an API key set with --api-key.
For trying things out, yes: with no keys configured, the freelm CLI (freelm chat, freelm serve) falls back to documented keyless public endpoints, Kilo Gateway's free routes and OVHcloud AI Endpoints' anonymous tier, and says so. Their limits are low and free routes may log prompts. In code, keyless mode is opt-in (FREELM_KEYLESS=1). One free Gemini or Groq key is far more capable, and freelm doctor checks every key you set.
The freelm package is MIT licensed and free to install. It connects directly to the providers you configure. Access to free tiers, model availability, quotas, and any charges depend on each provider and your account. Check their current terms and billing before use; freelm does not guarantee free or unlimited inference.
Install freelm from PyPI with: pip install freelm (requires Python 3.9 or later). Then set one or more provider API keys as environment variables — for example OPENROUTER_API_KEY, GEMINI_API_KEY, GROQ_API_KEY — and call freelm.FreeLLM.from_env() to create a client. The client auto-detects which keys are present and builds a pool from them. You can also pass providers explicitly: FreeLLM([OpenRouter('sk-or-...'), GoogleAIStudio('AIza...')]) for full control over which providers are used and in what order. No further configuration is required to start making chat completions.
Install the npm package with: npm install freelm (requires Node.js 20 or later). Import and use it as: import { FreeLLM } from 'freelm'; const llm = FreeLLM.fromEnv(); console.log(await llm.text('Hello')). The Node.js port has zero runtime dependencies — it uses the built-in fetch API. It supports the same API surface as the Python version: chat(), text(), stream(), health(), and the drop-in OpenAI shim via import { OpenAI } from 'freelm/compat'. TypeScript types are bundled. The same environment variables (OPENROUTER_API_KEY, GEMINI_API_KEY, etc.) are used for key loading.
freelm ships a compatibility shim that mirrors the OpenAI Python SDK and JS SDK interfaces exactly. In Python, replace 'from openai import OpenAI' with 'from freelm.compat import OpenAI' and your existing client.chat.completions.create(...) calls will work unchanged — backed by FreeLLM.from_env() instead of the OpenAI API. In Node.js, replace 'import OpenAI from openai' with 'import { OpenAI } from freelm/compat'. Use model='auto' (or any virtual model alias) to let freelm pick the best available free model. No other code changes are required, making migration instantaneous.
An error such as a 429 or a 500 moves to the next provider at the cost of one round trip. A provider that hangs or answers slowly is raced: after a few seconds (three times that provider's usual latency, clamped) the next provider starts in parallel and the first answer wins. In the published simulation (2026-10-10, benchmarks/failover.py in the repository) a hung provider cost 6.3 seconds and a stalled stream 3.3 seconds, where freelm 0.4 failed after its 60 second deadline. The slow provider is ranked lower, so later calls do not wait at all.
No single provider error ends a call. A 429 rate limit cools that key (or, where quotas are per model, as on Gemini and Groq, sets aside just that model for that key) and freelm moves on. A 5xx error or timeout trips that key's circuit breaker, which half-opens after a cooldown. A 401/402 disables the key. A retired model (404/410) is set aside for an hour. A request that one provider rejects is tried on the next provider, and only one that several providers reject is reported as a caller error. Failover is interleaved across providers, so every provider is reached quickly, and max_attempts (default 12) caps total tries per call. When everything fails, the error explains each provider's state and points to freelm doctor.
Because model names differ across providers (e.g. 'gemini-2.5-flash-lite' on Google vs 'openai/gpt-oss-120b' on Groq) and free models are retired often, freelm lets you request by intent rather than exact model ID. The built-in aliases are: 'auto' or 'chat' (any available chat model), 'chat:large' or 'large' (a larger/stronger model), 'chat:fast' or 'fast' (a fast/cheap model), 'chat:small' or 'small' (the smallest model), 'chat:tools' and 'vision' (only models with that capability), and any 'vendor/model-id' passthrough, routed only to the providers that list it. freelm resolves each alias to a concrete model per provider. Free model IDs change constantly, so it discovers them live via each provider's /models API and caches results to disk.
freelm supports five routing strategies set at client construction: smart (the default since 0.5: priority tiers first, then the fastest measured provider, with unknown providers tried and old measurements expiring after ten minutes), priority (ascending priority integer, deterministic), round_robin (rotates which provider goes first each call), quota_aware (ranks providers by remaining quota headroom) and latency (lowest observed latency only). Within any strategy, failover is interleaved across providers so no single provider monopolizes retries, and a slow attempt is raced against the next provider (hedge=False turns that off).