Quick answer: To use RutaAPI with Codex CLI, create a RutaAPI key, set the provider Base URL to https://api.rutaapi.com/v1, choose an enabled model ID, and verify available models with /v1/models.

Need the full setup guide?

Read the complete Codex CLI custom API Base URL guide for a step-by-step walkthrough with troubleshooting.

Start with RutaAPI

Create an API key — includes $1 trial credit, then test /v1/models before sending a larger Codex CLI request.

Create API key View model pricing

Start in 5 minutes

  1. Create a RutaAPI account.
  2. Add prepaid credits.
  3. Create an API key in the dashboard.
  4. Check available models with /v1/models.
  5. Use one returned model id as YOUR_ENABLED_MODEL_ID.
  6. Send your first chat/completions request.

Before you start

Step 1: Create or edit config.toml

Open your Codex configuration file. This is typically located at ~/.codex/config.toml.

~/.codex/config.toml
model_provider = "rutaapi"
model = "YOUR_ENABLED_MODEL_ID"
model_reasoning_effort = "high"

[model_providers.rutaapi]
name = "RutaAPI"
base_url = "https://api.rutaapi.com/v1"
wire_api = "responses"
requires_openai_auth = true

Note: If your selected model or Codex version expects Chat Completions instead of Responses, check the current Codex documentation and your RutaAPI model compatibility. Model availability depends on your account settings and upstream model compatibility.

Step 2: Create or edit auth.json

Create or update ~/.codex/auth.json with your RutaAPI API key. This file stores your authentication credentials.

~/.codex/auth.json
{
  "OPENAI_API_KEY": "YOUR_RUTAAPI_KEY"
}

Security: Do not paste your real API key into public screenshots, GitHub issues, logs or chat messages. Rotate the key immediately if it is exposed.

Step 3: Verify available models

Before starting Codex, verify that your API key works and check which models are available.

curl https://api.rutaapi.com/v1/models \
  -H "Authorization: Bearer YOUR_RUTAAPI_KEY"

Look for the model name you specified in config.toml in the returned list. If the model is not listed, it may not be enabled on your account.

Step 4: Start Codex

Once both files are configured, start Codex CLI:

codex

Codex will use your rutaapi provider configuration and route requests through your RutaAPI API key.

Common issues

401 Unauthorized

Invalid API key. Verify the key in auth.json matches your RutaAPI key.

403 Forbidden

No credits or no model permission. Check your account balance.

404 Not Found

Model not available. Verify the model name in /v1/models response.

Responses API not supported

Check wire_api setting. Try "chat_completions" if Responses is not supported by your model.

Config file not found

Ensure config.toml and auth.json are in the correct path (typically ~/.codex/).

Key exposed in screenshot

Rotate your key immediately in the RutaAPI dashboard and update auth.json.

Important: Do not write OpenAI official authorization for RutaAPI. Model availability depends on your account settings and upstream routes — not all models are always available.

Create RutaAPI key →
Ready to test RutaAPI? Use one OpenAI-compatible base URL, prepaid credits, and API keys from the dashboard.