---
url: https://docs.freetheai.org/guides/codex.md
description: >-
  Configure OpenAI Codex CLI to use free models through FreeTheAI's Responses
  API. A tested config.toml with a custom model provider.
---

# Codex CLI

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.

Category: [Coding tools](/guides/#coding-tools). Before you start, you need a FreeTheAI account, an API key, and today's [check-in](/getting-started/check-in).

## Settings

| Setting | Value |
| --- | --- |
| base_url | `https://api.freetheai.org/v1` |
| wire_api | `responses` |
| env_key | `FTAI_KEY` |

## Steps

### 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.

```sh
setx FTAI_KEY "ftai_your_key_here"
export FTAI_KEY="ftai_your_key_here"
```

### Edit config.toml

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

```toml
model = "fta/zai/glm-5.3"
model_provider = "freetheai"

[model_providers.freetheai]
name = "FreeTheAI"
base_url = "https://api.freetheai.org/v1"
env_key = "FTAI_KEY"
wire_api = "responses"
```

### Run Codex

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

## Tips

* Codex only speaks the Responses API now; wire_api = "chat" is refused by current versions.
* `fta/zai/glm-5.3` and `fta/kimi/k3` handle tool calls well.

## Common questions

### Does FreeTheAI support the Responses API Codex needs?

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

## More help

* [Every API error and its fix](/errors)
* [Limits and the daily reset](/concepts/limits)
* [Codex CLI website](https://developers.openai.com/codex) and [source code](https://github.com/openai/codex)

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