Codex CLI
Use OpenAI's Codex CLI with FinOps for powerful code generation with any provider.
Codex CLI provides powerful code generation and completion capabilities directly in your terminal.
If your Allowed Headers are already set to *, you can skip this note. If not, and you face issues integrating FinOps with Codex CLI, try switching to * or adding the specific headers required by your client. By default, FinOps whitelists: Content-Type, Authorization, X-Requested-With, X-Stainless-Timeout, and X-Api-Key.
Installing Codex CLI
npm install -g @openai/codexConfiguring Codex CLI with FinOps
Codex CLI always prefers OAuth over custom API keys. Make sure you run /logout before configuring the FinOps gateway with Codex.
Update codex.toml
Add the FinOps base URL and credentials to your global ~/.codex/config.toml or project-specific .codex/config.toml:
export OPENAI_API_KEY=<bifrost_virtual_key>openai_base_url="{AI_GATEWAY_URL}/openai/v1"
env_key="OPENAI_API_KEY"
model = "openai/gpt-5.4"Always run codex from the same terminal session where you exported variables, or restart the terminal after changing your profile. GUI-launched terminals or IDEs may not pick up shell-profile exports unless the environment is configured there as well.
Using Non-OpenAI models
Codex CLI defaults to websocket mode for the Responses API and automatically falls back to HTTPS if the WebSocket connection fails. Non-OpenAI models are not supported in WebSocket mode, because in this mode, the server is expected to maintain the conversation context. If you are using non-OpenAI models, you must enable HTTPS mode.
To enable https for Codex CLI by default, add these settings in your config.toml:
model_provider = "openai_http"
[model_providers.openai_http]
name = "OpenAI HTTP"
wire_api = "responses"
supports_websockets = false
base_url = "{AI_GATEWAY_URL}/openai/v1"Model Configuration
Use the --model flag to start Codex with a specific model:
codex --model openai/gpt-5-codex
codex --model openai/gpt-5.4-proYou can also switch models mid-session with the /model command:
/model openai/gpt-5.4-pro
/model openai/gpt-5-codexUsing Non-OpenAI Models with Codex CLI
FinOps automatically translates OpenAI API requests to other providers, so you can use Codex CLI with models from Anthropic, Google, Mistral, and more. Use the provider/model-name format to specify any FinOps-configured model:
# Start with an Anthropic model
codex --model anthropic/claude-sonnet-4-5-20250929
# Start with a Google model
codex --model gemini/gemini-2.5-pro
# Switch mid-session
/model anthropic/claude-sonnet-4-5-20250929
/model mistral/mistral-large-latestSupported Providers
FinOps supports the following providers with the provider/model-name format:
openai, azure, gemini, vertex, bedrock, mistral, groq, cerebras, cohere, perplexity, xai, ollama, openrouter, huggingface, nebius, parasail, replicate, vllm, sgl
Non-OpenAI models must support tool use for Codex CLI to work properly. Codex CLI relies on tool calling for file operations, terminal commands, and code editing. Models without tool use support will fail on most operations.