{
  "id": 3915256,
  "title": "Configure LiteLLM as a gateway for a custom model provider for Codex",
  "url": "https://urgent.news/2026/08/28/configure-litellm-as-a-gateway-for-a-custom-model-provider-for-codex",
  "topic": "ai",
  "section": "AI",
  "published": "2026-08-28T07:02:59.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/juliashevchenko/configure-litellm-as-a-gateway-for-a-custom-model-provider-for-codex-2e3f"
  },
  "original_language": "en",
  "account": "In my recent exploration, I encountered a requirement to utilize an LLM model via a gateway. The tool I chose for this purpose was LiteLLM. LiteLLM serves as an AI gateway that allows for the management of LLM setups, cost tracking, and observability tools. Being a daily user of Codex for coding, I sought a solution that offers custom model provider support and maintains a similar user interface to Codex. After evaluating OpenCode, Goose, and other alternatives, I found the UI, speed, and overall functionality to be unsatisfactory. Consequently, I contemplated the possibility of configuring Codex to meet my specific needs.\n\nUpon investigation, LiteLLM provides an OpenAI-compatible interface, suggesting it should be feasible. However, Codex itself was unable to configure it. Therefore, I adopted a manual approach. To begin, I exposed the LiteLLM API key as an OS environment variable. For Windows users (PowerShell), the command was [Environment]::SetEnvironmentVariable(\"LITELLM_API_KEY\", \"sk-1234\", \"User\"). Upon restarting the terminal session, I validated the setup by checking $env:LITELLM_API_KEY. For MacOS and Linux users, the command export LITELLM_API_KEY=sk-1234 was used. It is important to note that apps launched from Finder or the Dock on MacOS may not inherit variables set in the shell profile, potentially causing the LITELLM_API_KEY to be missing even if Codex functions correctly in the terminal. To address this, launching the app from a terminal or setting the variable at the login session level and restarting the app (using launchctl setenv LITELLM_API_KEY sk-1234) is recommended.\n\nFollowing the environment variable setup, I proceeded to update the Codex configuration. This involved adding the necessary configuration at the beginning of .codex/config.toml, ensuring a backup of the original config was made beforehand. Within the configuration, I set the required model and effort parameters. The model of choice was gpt-5.6-sol, and I configured model_provider to litellm. Additionally, I specified model_reasoning_effort as xhigh.\n\nNext, I added the provider-specific configurations. The env_key needed to match the environment variable set earlier, in this case, LITELLM_API_KEY. The base_url pointed to the deployed instance of LiteLLM. For a local instance, localhost with the appropriate port number would be used. The configuration also allowed for the setting of custom HTTP headers. In my scenario, access headers were required to bypass Cloudflare security guards, which were added as part of the http_headers configuration. It is worth noting that, when using a custom provider, there is no UI within the app for changing the session model as seen in OpenAI's configuration (as referenced in openai/codex#15364). A session will utilize the model specified in the config.toml at the time of its creation. To switch to a different LiteLLM model, the model parameter in config.toml should be updated, and a new session initiated. Finally, I verified the successful configuration by restarting Codex and opening a new chat session, then checking the LiteLLM dashboard logs for confirmation.\n\nFor further details, I refer to LiteLLM's documentation on OpenAI Codex integration and the Codex documentation regarding advanced configuration settings.",
  "summary": "Recently, I've faced a need to use an LLM model through a gateway. In my case, it was LiteLLM. LiteLLM is an AI gateway where you can manage your LLMs setup in one place, track the costs, and enjoy observability tools. I've started investigating possible options. My go-to agent for daily coding is Codex, so I was trying to find a tool that supports custom model providers and which usability is…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}