Skip to main content
Codex CLI speaks only the OpenAI Responses API. The Fortytwo API serves Chat Completions, so Codex connects through a local LiteLLM proxy that translates between the two. This setup needs Python and a terminal.
Before you start: create a Fortytwo API key and buy credits — see Quickstart, step 1. Give each agent its own key with a Spend limit.
1

Install LiteLLM and Codex

2

Configure LiteLLM

Create litellm.yaml:
litellm.yaml
Use the custom_openai/ prefix: it makes LiteLLM translate Responses requests to Chat Completions.The master key is a password for your local LiteLLM proxy; LiteLLM does not start without it. You do not get it anywhere: make up any string that starts with sk-, or let the command in the next step create a random one. Codex sends it to LiteLLM; LiteLLM sends your Fortytwo key to Fortytwo.
3

Start LiteLLM

The echo line prints the master key: copy it for the last step. Keep this terminal open while you use Codex.
4

Configure Codex

Add this to ~/.codex/config.toml. The first three lines go at the top of the file, before any [section]; replace any model or model_provider lines already there.
~ is your home folder. Folders that start with a dot, such as .pi, .config or .codex, are hidden. To show them: Cmd+Shift+. in Finder on macOS, View → Show → Hidden items in File Explorer on Windows, Ctrl+H in most Linux file managers.
~/.codex/config.toml
5

Start Codex

In a second terminal, set the same master key and start Codex in your project folder:
Codex warns Model metadata for qwen/qwen3.8-27b not found. The warning does not affect requests.
More options: Codex custom model providers , LiteLLM OpenAI-compatible endpoints .
Something not working with your agent, or using one we have not listed? Tell us in the platform: Feedback for ideas and small bugs, Contact support if it blocks your work, or Report a security issue.
Last modified on October 26, 2026