The free tier is closed for most users.Thank you for every chat along the way. Paid models work as before, and your account, API keys, and balance stay as they are.Read why

Codex CLI API: Use FreeTheAI Models in Codex

Codex CLI talks to FreeTheAI through the OpenAI Responses API. Add FreeTheAI as a model provider in config.toml and keep the key in an environment variable.

WebsiteSource codeAPI reference

Steps

  1. Save your key in an environment variable

    On Windows run the first line and open a new terminal; on macOS and Linux add the second line to your shell profile.

    text
    setx FREETHEAI_API_KEY "ftai_your_key_here"
    export FREETHEAI_API_KEY="ftai_your_key_here"
  2. Edit config.toml

    Open ~/.codex/config.toml (on Windows, %USERPROFILE%\.codex\config.toml) and add:

    toml
    model = "glm-5.3"
    model_provider = "freetheai"
    
    [model_providers.freetheai]
    name = "FreeTheAI"
    base_url = "https://api.freetheai.org/v1"
    env_key = "FREETHEAI_API_KEY"
    wire_api = "responses"
  3. Run Codex

    Start codex. To switch models, change model = "..." to any ID freetheai.org/models lists and restart.

How this guide was checked: Tested with the current Codex CLI on 2026-09-29 (Responses streaming and tool calls through FreeTheAI).

Tips

  • Codex only speaks the Responses API now; wire_api = "chat" is refused by current versions.
  • glm-5.3 and kimi-k3.1-pro handle tool calls well.

Troubleshooting

Does FreeTheAI support the Responses API Codex needs?

Yes. /v1/responses is translated for every chat model, streamed or not. It was tested with Codex on 2026-09-29.

Common errors

  • 401: the key is wrong or incomplete. Paste the whole key.
  • 403: follow a provider of the model, or confirm your email.
  • 404: the model ID or URL is wrong.
  • 429: daily limit reached, or too many requests at once.

More guides: Coding tools

All setup guides

Did this guide work for you?