How to manually configure LiteLLM as a custom model gateway in Codex
A developer has shared a step-by-step guide for manually connecting LiteLLM, an OpenAI-compatible AI gateway, to the Codex coding assistant after finding built-in configuration options insufficient. The setup requires setting a LiteLLM API key as an environment variable on Windows, macOS, or Linux, with a special note that macOS apps launched outside the terminal may not inherit shell variables. Users must then edit the .codex/config.toml file to specify LiteLLM as the model provider, along with the base URL, API key reference, and streaming parameters. Custom HTTP headers can also be added, which is useful for bypassing security layers such as Cloudflare Access. A current limitation means there is no in-app UI for switching models mid-session, so any model change requires editing the config file and starting a new session.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in