How to Use Codex CLI for Free
Codex CLI reads OPENAI_BASE_URL and OPENAI_API_KEY from environment variables. Point them at a free OpenAI-compatible backend and Codex works the same — without the paid OpenAI tier. Pick a free backend below.
1. Pick your tool
2. Pick your free backend
inclusionAI: Ring-2.6-1T (free) OpenRouter
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://openrouter.ai
# Then run:
codex --model "inclusionAI: Ring-2.6-1T (free)" Baidu Qianfan: CoBuddy (free) OpenRouter
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://openrouter.ai
# Then run:
codex --model "Baidu Qianfan: CoBuddy (free)" Owl Alpha OpenRouter
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://openrouter.ai
# Then run:
codex --model "Owl Alpha" NVIDIA: Nemotron 3 Nano Omni (free) OpenRouter
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://openrouter.ai
# Then run:
codex --model "NVIDIA: Nemotron 3 Nano Omni (free)" Poolside: Laguna XS.2 (free) OpenRouter
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://openrouter.ai
# Then run:
codex --model "Poolside: Laguna XS.2 (free)" Poolside: Laguna M.1 (free) OpenRouter
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://openrouter.ai
# Then run:
codex --model "Poolside: Laguna M.1 (free)" Baidu: Qianfan-OCR-Fast (free) OpenRouter
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://openrouter.ai
# Then run:
codex --model "Baidu: Qianfan-OCR-Fast (free)" Google: Gemma 4 26B A4B (free) OpenRouter
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://openrouter.ai
# Then run:
codex --model "Google: Gemma 4 26B A4B (free)" Google: Gemma 4 31B (free) OpenRouter
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://openrouter.ai
# Then run:
codex --model "Google: Gemma 4 31B (free)" Google: Lyria 3 Pro Preview OpenRouter
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://openrouter.ai
# Then run:
codex --model "Google: Lyria 3 Pro Preview" Google: Lyria 3 Clip Preview OpenRouter
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://openrouter.ai
# Then run:
codex --model "Google: Lyria 3 Clip Preview" NVIDIA: Nemotron 3 Super (free) OpenRouter
# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>" # Get at https://openrouter.ai
# Then run:
codex --model "NVIDIA: Nemotron 3 Super (free)"