How to Use Claude Code, Cursor & Codex for Free

Free alternative to paid Anthropic and OpenAI APIs. Pick a tool, pick a free LLM backend, copy the config — done in 30 seconds.

Claude Code, Cursor, Codex, and Gemini CLI all accept custom API endpoints via environment variables like ANTHROPIC_BASE_URL or OPENAI_BASE_URL. That means you can swap the paid official API for a free, OpenAI-compatible backend — NVIDIA NIM, OpenRouter, Groq, Cerebras, Mistral — without changing a single line of code. This generator produces the exact config snippet for each tool + backend combination. No credit card required.

Claude Code with a Free LLM API

Point ANTHROPIC_BASE_URL at an OpenAI-compatible free backend and set ANTHROPIC_AUTH_TOKEN to that provider's API key. Claude Code keeps working — you just pay nothing.

Config Template — replace <BASE_URL>, <MODEL_NAME>, <API_KEY> with values from the table below
# Claude Code works via OpenRouter's Anthropic-compatible API.
# Note: Only paid Anthropic Claude models are supported (e.g. claude-sonnet-4.6, claude-opus-4).
# Browse available Claude models at: https://openrouter.ai/models?q=anthropic
# Add to ~/.zshrc or ~/.bashrc
export OPENROUTER_API_KEY="<your-openrouter-api-key>" # Get at https://openrouter.ai/settings/keys
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
export ANTHROPIC_API_KEY="" # Must be explicitly empty to avoid conflicts
# Optional: pin specific models for each role
# export ANTHROPIC_DEFAULT_SONNET_MODEL="anthropic/claude-sonnet-4.6"
# export ANTHROPIC_DEFAULT_HAIKU_MODEL="anthropic/claude-haiku-4.5"
# Then simply run: claude

Recommended Free Models for Claude Code

Google: Lyria 3 Pro Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-pro-preview
https://openrouter.ai/api/v1
Google: Lyria 3 Clip Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-clip-preview
https://openrouter.ai/api/v1
deepseek-ai/deepseek-v4-flash NVIDIA NIM · 1.0M ctx · text
deepseek-ai/deepseek-v4-flash
https://integrate.api.nvidia.com/v1
qwen/qwen3.5-122b-a10b NVIDIA NIM · 262K ctx · text, image
qwen/qwen3.5-122b-a10b
https://integrate.api.nvidia.com/v1
@cf/meta/llama-4-scout-17b-16e-instruct Cloudflare Workers AI · 10.0M ctx · text
cf-meta-llama-4-scout-17b-16e-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run
@cf/meta/llama-3.2-11b-vision-instruct Cloudflare Workers AI · 131K ctx · text, image
cf-meta-llama-3-2-11b-vision-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run

Browse all free models for more options.

Cursor with a Free LLM API

Go to Settings → Models → Add Model, paste a free provider's base URL and API key, and Cursor routes completions through it.

Config Template — replace <BASE_URL>, <MODEL_NAME>, <API_KEY> with values from the table below
# Cursor → Settings () → Models → Add Model
# Enter the model name exactly as shown, then fill in:
# Override OpenAI Base URL: https://api.example.com/v1
# OpenAI API Key: <your-api-key> # Get at https://example.com/keys
# Click "Verify" to confirm the connection, then enable the model.
#
# Model name to add: model-name

Recommended Free Models for Cursor

Google: Lyria 3 Pro Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-pro-preview
https://openrouter.ai/api/v1
Google: Lyria 3 Clip Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-clip-preview
https://openrouter.ai/api/v1
deepseek-ai/deepseek-v4-flash NVIDIA NIM · 1.0M ctx · text
deepseek-ai/deepseek-v4-flash
https://integrate.api.nvidia.com/v1
qwen/qwen3.5-122b-a10b NVIDIA NIM · 262K ctx · text, image
qwen/qwen3.5-122b-a10b
https://integrate.api.nvidia.com/v1
@cf/meta/llama-4-scout-17b-16e-instruct Cloudflare Workers AI · 10.0M ctx · text
cf-meta-llama-4-scout-17b-16e-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run
@cf/meta/llama-3.2-11b-vision-instruct Cloudflare Workers AI · 131K ctx · text, image
cf-meta-llama-3-2-11b-vision-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run

Browse all free models for more options.

Codex CLI with a Free LLM API

Codex CLI reads OPENAI_BASE_URL and OPENAI_API_KEY from environment variables. Point them at a free OpenAI-compatible backend.

Config Template — replace <BASE_URL>, <MODEL_NAME>, <API_KEY> with values from the table below
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://api.example.com/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://example.com/keys
# Then run:
codex --model "model-name"

Recommended Free Models for Codex

Google: Lyria 3 Pro Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-pro-preview
https://openrouter.ai/api/v1
Google: Lyria 3 Clip Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-clip-preview
https://openrouter.ai/api/v1
deepseek-ai/deepseek-v4-flash NVIDIA NIM · 1.0M ctx · text
deepseek-ai/deepseek-v4-flash
https://integrate.api.nvidia.com/v1
qwen/qwen3.5-122b-a10b NVIDIA NIM · 262K ctx · text, image
qwen/qwen3.5-122b-a10b
https://integrate.api.nvidia.com/v1
@cf/meta/llama-4-scout-17b-16e-instruct Cloudflare Workers AI · 10.0M ctx · text
cf-meta-llama-4-scout-17b-16e-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run
@cf/meta/llama-3.2-11b-vision-instruct Cloudflare Workers AI · 131K ctx · text, image
cf-meta-llama-3-2-11b-vision-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run

Browse all free models for more options.

Gemini CLI with a Free API Key

Gemini CLI connects directly to Google's Gemini API — get a free key from Google AI Studio (no credit card) and add it to ~/.gemini/settings.json.

Config Template — replace <BASE_URL>, <MODEL_NAME>, <API_KEY> with values from the table below
# ~/.gemini/settings.json
{
 "apiKey": "<your-api-key>",
 "model": "model-name"
}
# Get API key at https://example.com/keys

Recommended Free Models for Gemini CLI

Google: Lyria 3 Pro Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-pro-preview
https://openrouter.ai/api/v1
Google: Lyria 3 Clip Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-clip-preview
https://openrouter.ai/api/v1
deepseek-ai/deepseek-v4-flash NVIDIA NIM · 1.0M ctx · text
deepseek-ai/deepseek-v4-flash
https://integrate.api.nvidia.com/v1
qwen/qwen3.5-122b-a10b NVIDIA NIM · 262K ctx · text, image
qwen/qwen3.5-122b-a10b
https://integrate.api.nvidia.com/v1
@cf/meta/llama-4-scout-17b-16e-instruct Cloudflare Workers AI · 10.0M ctx · text
cf-meta-llama-4-scout-17b-16e-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run
@cf/meta/llama-3.2-11b-vision-instruct Cloudflare Workers AI · 131K ctx · text, image
cf-meta-llama-3-2-11b-vision-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run

Browse all free models for more options.

OpenCode with a Free LLM API

OpenCode supports custom LLM providers through @ai-sdk/openai-compatible. Edit ~/.config/opencode/opencode.json with a free backend.

Config Template — replace <BASE_URL>, <MODEL_NAME>, <API_KEY> with values from the table below
// ~/.config/opencode/opencode.json
{
 "$schema": "https://opencode.ai/config.json",
 "provider": {
 "free-llm": {
 "npm": "@ai-sdk/openai-compatible",
 "name": "Free LLM",
 "options": {
 "baseURL": "https://api.example.com/v1",
 "apiKey": "<your-api-key>"
 },
 "models": {
 "model-name": { "name": "model-name" }
 }
 }
 }
}
// Get API key at https://example.com/keys

Recommended Free Models for OpenCode

Google: Lyria 3 Pro Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-pro-preview
https://openrouter.ai/api/v1
Google: Lyria 3 Clip Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-clip-preview
https://openrouter.ai/api/v1
deepseek-ai/deepseek-v4-flash NVIDIA NIM · 1.0M ctx · text
deepseek-ai/deepseek-v4-flash
https://integrate.api.nvidia.com/v1
qwen/qwen3.5-122b-a10b NVIDIA NIM · 262K ctx · text, image
qwen/qwen3.5-122b-a10b
https://integrate.api.nvidia.com/v1
@cf/meta/llama-4-scout-17b-16e-instruct Cloudflare Workers AI · 10.0M ctx · text
cf-meta-llama-4-scout-17b-16e-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run
@cf/meta/llama-3.2-11b-vision-instruct Cloudflare Workers AI · 131K ctx · text, image
cf-meta-llama-3-2-11b-vision-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run

Browse all free models for more options.

Hermes with a Free LLM API

Set the provider to "custom" in config.yaml. Add your API key and base URL to the .env file.

Config Template — replace <BASE_URL>, <MODEL_NAME>, <API_KEY> with values from the table below
# Step 1 — Edit config.yaml
# Windows: C:\Users\<you>\AppData\Local\hermes\config.yaml
# macOS/Linux: ~/.config/hermes/config.yaml
model:
 default: model-name
 provider: custom
 base_url: ${CUSTOM_BASE_URL}
 api_key: ${CUSTOM_API_KEY}
 model_aliases:
 model-name:
 model: "model-name"
 provider: "custom"
# Step 2 — Edit .env (same directory as config.yaml)
# Windows: C:\Users\<you>\AppData\Local\hermes\.env
# macOS/Linux: ~/.config/hermes/.env
# ========================
# Custom API (OpenAI-compatible)
# ========================
CUSTOM_API_KEY=<your-api-key> # Get at https://example.com/keys
CUSTOM_BASE_URL=https://api.example.com/v1

Recommended Free Models for Hermes

Google: Lyria 3 Pro Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-pro-preview
https://openrouter.ai/api/v1
Google: Lyria 3 Clip Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-clip-preview
https://openrouter.ai/api/v1
deepseek-ai/deepseek-v4-flash NVIDIA NIM · 1.0M ctx · text
deepseek-ai/deepseek-v4-flash
https://integrate.api.nvidia.com/v1
qwen/qwen3.5-122b-a10b NVIDIA NIM · 262K ctx · text, image
qwen/qwen3.5-122b-a10b
https://integrate.api.nvidia.com/v1
@cf/meta/llama-4-scout-17b-16e-instruct Cloudflare Workers AI · 10.0M ctx · text
cf-meta-llama-4-scout-17b-16e-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run
@cf/meta/llama-3.2-11b-vision-instruct Cloudflare Workers AI · 131K ctx · text, image
cf-meta-llama-3-2-11b-vision-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run

Browse all free models for more options.

OpenClaw with a Free LLM API

OpenClaw supports custom API backends through ~/.openclaw/openclaw.json. Add a free backend with the openai-completions API type.

Config Template — replace <BASE_URL>, <MODEL_NAME>, <API_KEY> with values from the table below
// ~/.openclaw/openclaw.json (JSON5 format)
{
 "agents": {
 "defaults": {
 "model": {
 "primary": "model-name",
 },
 },
 },
 "models": {
 "providers": {
 // Option A — Built-in provider (OpenAI, Anthropic, Google…)
 // Just add apiKey; OpenClaw handles the baseUrl automatically
 // "openai": { "apiKey": "<your-api-key>" },
 // Option B — Custom OpenAI-compatible base URL (e.g. OpenRouter, NVIDIA)
 "free-llm": {
 "baseUrl": "https://api.example.com/v1",
 "apiKey": "<your-api-key>", // Get at https://example.com/keys
 "api": "openai-completions", // openai-completions | anthropic-messages | …
 "models": [
 { "id": "model-name", "name": "model-name" },
 ],
 },
 },
 },
}
// Apply: openclaw gateway restart
// Verify: openclaw doctor --fix

Recommended Free Models for OpenClaw

Google: Lyria 3 Pro Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-pro-preview
https://openrouter.ai/api/v1
Google: Lyria 3 Clip Preview OpenRouter · 1.0M ctx · text, image
google/lyria-3-clip-preview
https://openrouter.ai/api/v1
deepseek-ai/deepseek-v4-flash NVIDIA NIM · 1.0M ctx · text
deepseek-ai/deepseek-v4-flash
https://integrate.api.nvidia.com/v1
qwen/qwen3.5-122b-a10b NVIDIA NIM · 262K ctx · text, image
qwen/qwen3.5-122b-a10b
https://integrate.api.nvidia.com/v1
@cf/meta/llama-4-scout-17b-16e-instruct Cloudflare Workers AI · 10.0M ctx · text
cf-meta-llama-4-scout-17b-16e-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run
@cf/meta/llama-3.2-11b-vision-instruct Cloudflare Workers AI · 131K ctx · text, image
cf-meta-llama-3-2-11b-vision-instruct
https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run

Browse all free models for more options.

How This Works — Swap the Backend, Keep Your Tool

Every AI coding tool needs an LLM API behind it. By default, Claude Code connects to api.anthropic.com, Codex connects to api.openai.com, Cursor uses OpenAI models. But every one of these tools lets you point it at a custom API endpoint — the key insight that makes free backends work.

The configuration always comes down to three things:

  1. Base URL — The API endpoint address. Each provider has one (e.g., https://integrate.api.nvidia.com/v1 for NVIDIA NIM).
  2. API key — Your authentication token. Get one free from the provider's signup page. Most require no credit card.
  3. Model name — The specific model to use (e.g., deepseek-ai/deepseek-v4-pro). This tells the provider which model to route your request to.

Each tool stores these differently — some use environment variables, others use JSON config files, a few use both. Select a tool above to get the exact syntax.

Which Backend Should You Pick?

There is no single "best" free backend — it depends on what you're optimizing for:

  • No credit card, no phone, instant? → Groq (30 RPM, 14,400 RPD). Fast inference via custom LPU hardware. Hosts Llama, Qwen, DeepSeek-R1.
  • No daily token cap? → NVIDIA NIM (40 RPM, no daily limit). 100+ models including DeepSeek V4, Qwen3.5, MiniMax M2.7. Phone verification required.
  • One key for everything? → OpenRouter (35+ free models, single endpoint). Unified API with fallback routing. Some free models have low rate limits.
  • Largest context window? → Google AI Studio with Gemini 2.5 Flash (1M context, multimodal). 10 RPM, 250 RPD. Credit card verification required for billing account.
  • Best for Europe / GDPR? → Mistral AI (256K context, ~1 RPS, 500K TPM). French-hosted, no credit card on free tier. Also mirrored on Cloudflare.

Which AI Coding Tool to Choose — Claude Code, Cursor, or Codex?

All support custom backends, but they serve different workflows:

Claude Code (cc)

Terminal-native agent from Anthropic. Lives in your terminal — no IDE required. Reads your entire project, runs commands, edits files, and manages git. Best for developers who live in the terminal.

  • Uses ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN
  • Requires Anthropic Messages API format (OpenRouter provides this)
  • Can use any Anthropic-compatible endpoint

Cursor

AI-first code editor (VS Code fork). Adds custom models in Settings → Models. Supports inline completion, chat sidebar, and agent mode. Best for developers who prefer a GUI IDE.

  • Add custom model via Settings UI (no config file editing)
  • Requires OpenAI-compatible endpoint
  • Supports multiple custom models simultaneously

Codex CLI

OpenAI's open-source terminal agent. Similar to Claude Code but designed for OpenAI models. Works with any OpenAI-compatible backend by setting environment variables.

  • Uses OPENAI_BASE_URL + OPENAI_API_KEY
  • Open source (Apache 2.0)
  • Works out of the box with most free backends

Gemini CLI

Google's open-source terminal agent (Apache 2.0). Designed for Gemini models but can be adapted. Free API key from Google AI Studio — no credit card.

OpenCode

Open-source coding agent that supports custom providers via @ai-sdk/openai-compatible. JSON config, works with most free backends.

Hermes & OpenClaw

Both support custom endpoints. Hermes uses YAML + .env files. OpenClaw uses JSON5 with flexible provider configuration. Select the tool tab above for exact configs.

Common Questions About Free AI Coding Tool Configs

Does Claude Code work without paying Anthropic?

Claude Code (the CLI tool) is free and open source. You only pay if you use Anthropic's API. By pointing ANTHROPIC_BASE_URL at OpenRouter's Anthropic-compatible endpoint, you can use Claude Code with any model OpenRouter hosts. Note: Claude Code works best with actual Claude models (available via OpenRouter with a paid key). For truly free use, other tools like Codex and Cursor work better with free backends.

Will Cursor know I'm using a free backend?

No. Cursor sends API requests to whatever base URL you configure. It doesn't validate whether the endpoint belongs to OpenAI or a third party. As long as the endpoint speaks the OpenAI API format (which NVIDIA NIM, Groq, OpenRouter, Mistral, and Cerebras all do), Cursor works normally.

Is this against the terms of service?

Using a custom API endpoint is a documented feature of every tool listed here — not a hack. Claude Code's official docs describe ANTHROPIC_BASE_URL. Cursor's settings UI has an "Add Model" button for custom providers. Codex is open source and explicitly supports custom backends via environment variables. You are using the tools as designed.

What if my free model hits a rate limit?

Free tiers have rate limits — that's the trade-off. If you hit a limit, you have several options: (1) switch to another free provider (NVIDIA NIM has no daily cap, just 40 RPM); (2) add a second API key and round-robin between providers; (3) upgrade to a paid plan on the same provider for higher limits. Most developers find 30-40 RPM is enough for solo work.

Free vs Paid: When Should You Upgrade?

For students, testers, and agent users, free tiers cover the vast majority of real-world usage. But there's a clear line where free stops making sense. Here's how we think about it.

Stay on the free tier when…

  • You're a student learning AI. Free RPMs (10-40) are more than enough for coursework, research projects, and learning prompt engineering. No credit card, no budget approval, no friction.
  • You're testing models for a project. Before committing to a paid API, test 5 different models across 3 providers for free. Check coding ability, latency, and tool calling compatibility — the free tier is the evaluation sandbox every paid API should offer.
  • You're running an AI agent (Claude Code, OpenClaw, Hermes). At 30 RPM, interactive coding — one request every 2 seconds — stays well within free limits. A single developer working iteratively rarely hits the throttle.
  • You just want to experience LLMs. No production app, no deadlines. You want to try the latest models, compare outputs, or explore what a 1M context window feels like. Free APIs make this accessible without a subscription.

Upgrade to paid when…

  • You're shipping a production app with real users. Free tiers have no SLA. If the provider throttles your key during peak usage, your users get errors. Paid tiers include guaranteed throughput and support.
  • Your agent needs sustained high throughput. If Claude Code or OpenClaw is running batch operations across a large codebase — not just interactive edits — 30 RPM becomes a bottleneck. Paid plans offer 5-50× higher limits.
  • You need data privacy guarantees. Google AI Studio's free tier may use prompts for product improvement. Enterprise tiers include data processing agreements (DPAs). If you're sending proprietary code or user data, don't use a free key.

Our rule of thumb: students and testers stay free, production apps go paid. Use our model directory to find the right free model, then upgrade on the same provider when you actually need to — not before.

7 AI Coding Tools
145 Free Models
20 Providers
30s Average Config Time
Browse All 145 Free Models →