How to Use a Third-Party Relay API Key in Codex: Complete Setup and Protocol Conversion Guide
To connect Codex (CLI or Desktop) to a third-party relay API key—and run non-OpenAI models like Claude or Gemini—you can route your client through a local AI gateway. Using Little Mungbean, you can inject custom provider models directly into Codex and translate API protocols locally without writing manual mapping rules.
Prerequisites
- Little Mungbean: Download the application from the Little Mungbean Official Website or inspect the source code on the GitHub Repository.
- Third-Party Relay Credentials: A valid API endpoint URL and API key from your relay provider.
- Codex Client: Codex CLI or Codex Desktop. If not yet installed, you can use the one-click installation feature inside Little Mungbean to set up Codex CLI or Codex Desktop directly.

Step 1: Add the Relay Endpoint and Fetch Models
Select Codex as your target Agent client in Little Mungbean, then enter your third-party relay's API endpoint and API key. You can also select a provider preset to populate the endpoint URL automatically.

Click Fetch Models to verify the credentials and retrieve the provider's available models. Once fetched, click individual model cards to enable or disable which models will be injected into Codex.

If fetching models fails, either the endpoint URL or API key is invalid, or your local machine cannot reach the relay provider. Configure your system network proxy and retry before proceeding.
Step 2: Select the Model Injection Mode
Unlike tools such as CCswitch that rely on manual model mapping, Little Mungbean injects the model configuration directly into the Agent client. Before starting the gateway, choose one of the two injection modes based on the models you plan to run:
- Default model list: Populates only Codex's built-in model slots for its native OpenAI model family, excluding cross-family models.
- Gateway model list: Injects the full list of enabled gateway models into Codex, including cross-family models such as Claude, Gemini, or Grok.

If you want to use non-OpenAI models provided by your third-party relay inside Codex, select Gateway model list.
Step 3: Configure Local Protocol Conversion
Codex communicates using OpenAI API formats, while upstream models on a relay may require different formats. Protocol conversion translates requests and responses—including streaming responses—bidirectionally between four supported formats:
OpenAI Chat CompletionsOpenAI ResponsesAnthropic MessagesGemini GenerateContent

Little Mungbean provides automatic recommendations for the toggle, which you can verify using these rules:
| Scenario in Codex | Local Protocol Conversion Setting | Reason |
|---|---|---|
| Using Claude, Gemini, or other cross-family models | Enable | Translates Codex requests into the upstream model's native API format. |
| Using only native OpenAI models | Disable | Both client and upstream model use the same protocol. |
| Using Grok models | Disable (usually) | Grok natively supports OpenAI Responses, so conversion is generally unnecessary. |
| Relay already performs server-side conversion | Disable | Prevents redundant double conversion between the local gateway and the relay server. |
Step 4: Connect the Gateway and Switch Models in Codex
Click Start • Connect. Little Mungbean will automatically launch or restart your Codex client and inject the selected model list. When the client status indicator turns green, Codex is actively routing requests through the local gateway.

If the connection fails, verify your local network proxy settings to ensure your computer can reach the relay endpoint.
Once connected, open Codex and switch between your injected relay models directly from the client's native model selector.

If Codex prompts for an account login instead of using the gateway configuration, click the account sign-in mode button in Little Mungbean to switch modes with one click.
Step 5: Verify Routing and Protocol Translation
Send a test prompt in Codex and open the Request log in Little Mungbean to confirm the setup is working as expected.

The Request log displays the target provider, model, HTTP status code, token usage (input, cache, and output), time to first token, request endpoint, and active protocol conversion details in real time. If an error occurs during routing, check the Runtime log for detailed operation steps and error messages.
Updated