---
title: "OpenAI Codex CLI Beyond GPT: Switch Between Claude, Gemini, Llama, and More Using Bifrost"
description: OpenAI&#x27;s Codex CLI has earned a strong reputation as a terminal-based coding agent with robust code generation and completion capabilities. It ships with native support for GPT models and ChatGPT OAuth authentication, making it a natural choice for developers already embedded in the OpenAI ecosystem. But modern AI-
image: https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/size/w1200/2026/07/openai-codex-cli-beyond-gpt-switch-between-claude-gemini-lla-bifrost-paper-waves.optimized.png
---

Try Bifrost Enterprise free for 14 days. [Request access](https://www.getmaxim.ai/#enterprise-trial)

OpenAI's Codex CLI has earned a strong reputation as a terminal-based coding agent with robust code generation and completion capabilities. It ships with native support for GPT models and ChatGPT OAuth authentication, making it a natural choice for developers already embedded in the OpenAI ecosystem. But modern AI-assisted development increasingly demands the ability to evaluate and swap models from competing providers without changing tools.

A developer debugging a complex distributed system might want Claude's reasoning depth for one task, then switch to a Groq-hosted Llama model for rapid iteration on unit tests, and finally use Gemini 2.5 Pro for documentation generation. Codex CLI, by default, only communicates with OpenAI's API. Achieving this kind of multi-model workflow requires either juggling separate terminal agents or manually reconfiguring environment variables between sessions.

[Bifrost](https://docs.getbifrost.ai/overview) removes that constraint entirely. As an [open-source AI gateway](https://github.com/maximhq/bifrost) written in Go, Bifrost intercepts Codex CLI's OpenAI-format requests and routes them to any of [23+ supported providers](https://docs.getbifrost.ai/providers/supported-providers/overview), performing API translation on the fly. Combined with [Bifrost CLI](https://docs.getbifrost.ai/quickstart/cli/getting-started), the interactive launcher that automates all configuration, developers gain the ability to benchmark, compare, and switch models inside Codex CLI without touching a single environment variable.

## What Changes When You Route Codex CLI Through Bifrost

Without Bifrost, Codex CLI sends every request directly to OpenAI's servers via the standard `OPENAI_BASE_URL`. The developer is limited to GPT-family models, has no built-in failover if OpenAI's API degrades, and lacks any centralized mechanism for monitoring token spend or enforcing usage policies across a team.

Routing through Bifrost transforms Codex CLI into a provider-agnostic coding agent. Here is what becomes possible:

- **Instant model switching**: Use the `-model` flag or the `/model` command mid-session to hop between providers. Run `codex --model anthropic/claude-sonnet-4-5-20250929` to start with Claude, then type `/model gemini/gemini-2.5-pro` mid-conversation to switch without restarting the session.
- **Transparent API translation**: Bifrost converts Codex CLI's native OpenAI-format requests into the target provider's expected format. Developers interact with Codex CLI identically regardless of whether the backend model is GPT, Claude, Gemini, Mistral, or a self-hosted Llama instance.
- **Automatic provider failover**: Bifrost's [fallback system](https://docs.getbifrost.ai/features/fallbacks) reroutes requests when the primary provider is unavailable. If OpenAI's API experiences rate limiting or downtime, traffic shifts to a configured backup provider without interrupting the active session.
- **Unified observability**: Every request, across every provider, flows through a single gateway with [built-in logging and monitoring](https://docs.getbifrost.ai/features/observability/default) accessible at `http://localhost:8080/logs`. Filter by provider, model, or conversation content to analyze agent performance.

The gateway itself introduces only [11 microseconds of overhead](https://docs.getbifrost.ai/overview) per request at sustained throughput of 5,000 requests per second, so interactive coding latency is unaffected.

## From Install to First Prompt in 90 Seconds

Bifrost CLI eliminates the manual configuration that typically accompanies multi-provider setups. The entire process is interactive and takes two terminal windows.

**Terminal 1: Start the gateway**

```bash
npx -y @maximhq/bifrost
```

This spins up the Bifrost gateway at `http://localhost:8080` with a [web UI for provider management](https://docs.getbifrost.ai/quickstart/gateway/setting-up) and live traffic monitoring.

**Terminal 2: Launch the interactive CLI**

```bash
npx -y @maximhq/bifrost-cli
```

Bifrost CLI walks through four prompts:

- **Gateway URL**: Confirm or change the Bifrost address. The default `http://localhost:8080` works for local development.
- **Virtual key**: Optionally supply a [Bifrost virtual key](https://docs.getbifrost.ai/features/governance/virtual-keys) for authentication and governance. Keys are stored in the OS keyring, never written to disk in plaintext.
- **Agent harness**: Select Codex CLI. If it is not installed, the CLI runs `npm install -g @openai/codex` automatically.
- **Model**: A searchable list pulls every model available on the gateway via the `/v1/models` endpoint. Pick any model from any configured provider.

Press Enter. Codex CLI launches with `OPENAI_BASE_URL` and `OPENAI_API_KEY` preconfigured. On subsequent runs, Bifrost CLI remembers the last configuration and lets developers re-launch immediately or adjust any setting using keyboard shortcuts before starting.

## Practical Multi-Model Workflows Inside Codex CLI

The real value of routing Codex CLI through Bifrost surfaces in day-to-day development workflows where different tasks benefit from different models.

**Scenario 1: Comparing code generation quality**

A developer working on a complex API integration can test how different models approach the same problem. Start a session with OpenAI's latest model, generate the initial implementation, then switch mid-session to evaluate an alternative:

```
codex --model openai/gpt-5
# Generate initial implementation, then switch
/model anthropic/claude-sonnet-4-5-20250929
# Ask the same question and compare output quality
```

The `/model` command in Codex CLI performs an [instant mid-session switch](https://docs.getbifrost.ai/cli-agents/codex-cli#model-configuration). The conversation context carries forward, so the new model can build on or critique the previous output.

**Scenario 2: Cost-optimized iteration loops**

During rapid debug-test-fix cycles where speed matters more than peak reasoning, a developer can route requests to a fast inference provider:

```
codex --model groq/llama-3.3-70b-versatile
```

Groq's LPU-accelerated inference delivers significantly lower latency per token than cloud-hosted models, making it ideal for tight iteration loops. When the debugging session concludes and architectural decisions require deeper analysis, switching to a more capable model takes a single command.

**Scenario 3: Running parallel sessions across providers**

Bifrost CLI maintains a [persistent tabbed terminal interface](https://docs.getbifrost.ai/quickstart/cli/getting-started#tabbed-session-ui) after launching Codex CLI. Developers can open multiple tabs, each running Codex CLI pointed at a different model:

- Tab 1: `openai/gpt-5` for primary development
- Tab 2: `anthropic/claude-sonnet-4-5-20250929` for code review
- Tab 3: `groq/llama-3.3-70b-versatile` for quick utility scripts

Use `Ctrl+B` to enter tab mode, `n` to open new sessions, and `h`/`l` to navigate between active tabs. Each tab displays a status badge showing whether the session is actively processing, idle, or has triggered an alert.

## Authentication: ChatGPT OAuth, API Keys, and Virtual Keys

Codex CLI supports multiple authentication paths, and Bifrost is compatible with all of them.

**ChatGPT OAuth** is the simplest for developers with ChatGPT Plus, Pro, Team, Enterprise, or Edu subscriptions. Set the Bifrost base URL and run Codex:

```bash
export OPENAI_BASE_URL=http://localhost:8080/openai
codex
```

Select "Sign in with ChatGPT" in the CLI prompt, authenticate via the browser, and all traffic automatically routes through Bifrost.

**API key authentication** works with both OpenAI Console keys and Bifrost virtual keys:

```bash
export OPENAI_API_KEY=your-api-key
export OPENAI_BASE_URL=http://localhost:8080/openai
codex
```

When using Bifrost CLI's interactive launcher, these environment variables are configured automatically. The developer never types an `export` statement.

## Supported Providers and the Tool-Use Requirement

Bifrost supports the following providers through the `provider/model-name` format: `openai`, `azure`, `gemini`, `vertex`, `bedrock`, `mistral`, `groq`, `cerebras`, `cohere`, `perplexity`, `xai`, `ollama`, `openrouter`, `huggingface`, `nebius`, `parasail`, `replicate`, `vllm`, and `sgl`.

One essential constraint applies: non-OpenAI models [must support tool-use capabilities](https://docs.getbifrost.ai/cli-agents/codex-cli#using-non-openai-models-with-codex-cli). Codex CLI relies on function calling for file operations, terminal commands, and code editing. Models that lack tool-calling support will fail on most agentic operations. Before routing to a new provider, verify that the target model handles tool calls correctly.

## Governing Codex CLI Usage Across Engineering Teams

When Codex CLI adoption grows beyond individual developers to entire engineering organizations, unmanaged usage creates blind spots around spending, access control, and compliance. Bifrost's governance layer addresses each of these at the gateway level.

- **Virtual keys with scoped permissions**: Each developer or team receives a [virtual key](https://docs.getbifrost.ai/features/governance/virtual-keys) that enforces specific model access rules, spend limits, and rate caps. A senior engineer's key might permit GPT-5 and Claude Sonnet, while a contractor's key is restricted to open-source models on Groq.
- **Hierarchical budget controls**: [Budget and rate limit policies](https://docs.getbifrost.ai/features/governance/budget-and-limits) operate at the virtual key, team, and organization level, preventing cost overruns from runaway scripts or excessive usage.
- **Prometheus and OpenTelemetry integration**: Every Codex CLI request generates [Prometheus metrics](https://docs.getbifrost.ai/features/observability/prometheus) and [OpenTelemetry traces](https://docs.getbifrost.ai/features/observability/otel) that can be shipped to Grafana, Datadog, New Relic, or any OTLP-compatible backend for centralized dashboards.
- **Semantic caching**: Bifrost's [semantic caching](https://docs.getbifrost.ai/features/semantic-caching) identifies semantically equivalent prompts and serves cached responses, reducing both latency and token costs for patterns that recur across team members working on the same codebase.
- **Enterprise compliance**: For regulated environments, Bifrost Enterprise offers [audit logs](https://docs.getbifrost.ai/enterprise/audit-logs) for SOC 2, HIPAA, and GDPR compliance, [vault-based key management](https://docs.getbifrost.ai/enterprise/vault-support) through HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault, and [in-VPC deployments](https://docs.getbifrost.ai/enterprise/invpc-deployments) to ensure data residency.

## Start Using Codex CLI with Any Provider

[Bifrost](https://www.getmaxim.ai/bifrost) is [open source on GitHub](https://github.com/maximhq/bifrost) and connects Codex CLI to any LLM provider in two commands. For engineering teams that require enterprise governance, adaptive failover, identity provider integration through Okta or Entra, and private cloud deployments for their terminal coding workflows, [book a Bifrost demo](https://getmaxim.ai/bifrost/book-a-demo) to see the platform in action.

## Read next

[![Top 5 AI Gateways for Controlling Shadow AI in 2026](https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/size/w720/2026/10/top-5-ai-gateways-for-controlling-shadow-ai-bifrost-isometric.png) Shadow AI is the use of AI tools, models, and MCP servers that security teams have not approved and cannot see. This guide ranks five AI gateways for controlling it, including Bifrost with Bifrost Edge, Kong AI Gateway, Cloudflare AI Gateway, and Gravitee.](https://www.getmaxim.ai/articles/top-5-ai-gateways-for-controlling-shadow-ai/)

[![Top 5 AI Gateways for SSO and RBAC in 2026](https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/size/w720/2026/10/top-5-ai-gateways-for-sso-and-rbac-in-2026-bifrost-isometric.png) AI gateways with SSO and RBAC let enterprises tie every model request and every configuration change to a corporate identity. This guide compares Bifrost, Kong AI Gateway, Azure API Management, Gravitee, and Cloudflare AI Gateway on identity, roles, provisioning, and audit.](https://www.getmaxim.ai/articles/top-5-ai-gateways-for-sso-and-rbac-in-2026/)

[![Semantic Caching: The Top 5 AI Gateways in 2026](https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/size/w720/2026/10/semantic-caching-the-top-5-ai-gateways-in-2026-bifrost-isometric.png) Semantic caching serves a stored LLM response when a new prompt means the same thing as an earlier one. This guide compares Bifrost, Kong AI Gateway, Azure API Management, and Cloudflare AI Gateway on match modes, vector stores, thresholds, TTLs, and cache scoping.](https://www.getmaxim.ai/articles/semantic-caching-the-top-5-ai-gateways-in-2026/)

```json
{
    "@context": "https://schema.org",
    "@type": "Article",
    "publisher": {
        "@type": "Organization",
        "name": "Maxim Articles",
        "url": "https://www.getmaxim.ai/articles/",
        "logo": {
            "@type": "ImageObject",
            "url": "https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/size/w256h256/2025/08/thumbnail.png",
            "width": 60,
            "height": 60
        }
    },
    "author": {
        "@type": "Person",
        "name": "Kuldeep Paul",
        "image": {
            "@type": "ImageObject",
            "url": "https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/2025/08/1727978381919.jpeg",
            "width": 800,
            "height": 800
        },
        "url": "https://www.getmaxim.ai/articles/author/kuldeep/",
        "sameAs": []
    },
    "headline": "OpenAI Codex CLI Beyond GPT: Switch Between Claude, Gemini, Llama, and More Using Bifrost",
    "url": "https://www.getmaxim.ai/articles/openai-codex-cli-beyond-gpt-switch-between-claude-gemini-llama-and-more-using-bifrost/",
    "datePublished": "2026-03-17T19:42:36.000Z",
    "dateModified": "2026-07-03T13:20:23.000Z",
    "image": {
        "@type": "ImageObject",
        "url": "https://storage.ghost.io/c/84/03/8403f2f6-141c-411a-8f55-a32d4291533e/content/images/size/w1200/2026/07/openai-codex-cli-beyond-gpt-switch-between-claude-gemini-lla-bifrost-paper-waves.optimized.png",
        "width": 1200,
        "height": 630
    },
    "keywords": "AI Gateway",
    "description": "OpenAI's Codex CLI has earned a strong reputation as a terminal-based coding agent with robust code generation and completion capabilities. It ships with native support for GPT models and ChatGPT OAuth authentication, making it a natural choice for developers already embedded in the OpenAI ecosystem. But modern AI-assisted development increasingly demands the ability to evaluate and swap models from competing providers without changing tools.\n\nA developer debugging a complex distributed system m",
    "mainEntityOfPage": "https://www.getmaxim.ai/articles/openai-codex-cli-beyond-gpt-switch-between-claude-gemini-llama-and-more-using-bifrost/"
}
```
