To change the Codex CLI Base URL for an OpenAI-compatible API, set openai_base_url in your config file or add a model_providers entry with base_url. For RutaAPI, use https://api.rutaapi.com/v1 as the Base URL, enter your RutaAPI API key, then run /v1/models to verify the key and get a model ID. The API key, Base URL, and model must belong to the same provider — do not mix keys and URLs across platforms.
Do not use the dashboard URL or a full /v1/chat/completions endpoint as the Base URL. Test with a small /v1/models call before running larger Codex tasks.
Codex CLI setup values for RutaAPI
| Field | Value |
|---|---|
| Endpoint / Base URL | https://api.rutaapi.com/v1 |
| API Key | YOUR_RUTAAPI_KEY |
| Model ID | YOUR_ENABLED_MODEL_ID |
| Test endpoint | /v1/models |
What Codex CLI needs
When you configure Codex CLI with a custom OpenAI-compatible API provider, Codex CLI needs three things:
- Base URL — The root address of the API gateway. The correct value is
https://api.rutaapi.com/v1. Always include/v1. - API key — A secret token that identifies your RutaAPI account. Create one from the dashboard.
- Model — The identifier of the model that handles your requests. Must be enabled in your RutaAPI account.
Depending on your Codex CLI version, the exact config field or environment variable name may vary. Verify the current Codex CLI documentation for your installed version before configuring a custom provider.
Codex CLI version caveat Codex CLI UI labels and config behaviour can change by version. Depending on your Codex CLI version, the exact config field name or environment variable may differ. Users should verify the current Codex CLI config format in their installed version before setting up a custom provider.
RutaAPI values for Codex CLI
Base URL: https://api.rutaapi.com/v1
API key: Create one from the RutaAPI dashboard at app.rutaapi.com. Keys are shown only once at creation — copy and store them securely.
Model: Choose a model enabled in the RutaAPI app pricing page. Run GET /v1/models to see which models are available in your account.
openai_base_url vs custom provider base_url
Codex CLI supports changing the Base URL in two main ways, depending on how you want to configure the provider:
openai_base_urlchanges the Base URL used by the built-in OpenAI provider. Use this when you want Codex CLI to use a different route for the default OpenAI-compatible configuration.- A custom provider
base_urlis better when you want a separate provider profile for an OpenAI-compatible gateway. This lets you label the provider distinctly and manage it separately from the built-in provider.
Some Codex CLI versions may handle config keys differently, so check your installed version and start with a small /v1/models test before running larger tasks. Codex CLI configuration can change across versions — verify the current format for your release.
For RutaAPI, the endpoint value is https://api.rutaapi.com/v1 in both cases.
openai_base_url example
openai_base_url = "https://api.rutaapi.com/v1"
Custom provider example (config.toml style)
model_provider = "rutaapi"
[model_providers.rutaapi]
name = "RutaAPI"
base_url = "https://api.rutaapi.com/v1"
env_key = "RUTAAPI_API_KEY"
Note: Codex CLI config syntax may vary by version. Verify your version's documentation before applying provider config. If model_providers or openai_base_url are not recognised, try the other approach or test with /v1/models first.
Environment variable caveat
Some users search for OPENAI_BASE_URL or provider-specific environment variables when configuring Codex CLI. Codex CLI behaviour may vary by version and provider mode — some versions map env vars directly to config fields, others require explicit config file entries.
If environment variables do not work as expected, use a user-level config file and test the connection with a small /v1/models request first. Do not assume a particular env var name will be honoured without checking your version.
Test your key before using Codex CLI
Before running any Codex CLI tasks, verify that your API key and Base URL work together:
curl https://api.rutaapi.com/v1/models \
-H "Authorization: Bearer YOUR_RUTAAPI_KEY"
If the response returns a model list, your Base URL and API key are working. Use one of the returned model IDs in your Codex CLI configuration.
First request example
Once your key is verified, send a chat completions request to confirm end-to-end connectivity:
curl https://api.rutaapi.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_RUTAAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_ENABLED_MODEL_ID",
"messages": [
{"role": "user", "content": "Say hello from RutaAPI"}
]
}'
Replace YOUR_ENABLED_MODEL_ID with one of the model IDs from the /v1/models response. Do not hardcode a model name you have not verified.
How to pick a model
Model IDs are returned by the GET /v1/models endpoint. Copy one of the model id values from the response and use it in your Codex CLI config.
Model availability is per-account. If a model ID is not in your /v1/models response, it is not active in your account — add credits or check the app pricing page for enabled models.
Common Codex CLI setup mistakes
| Problem | Likely cause | Fix |
|---|---|---|
| 401 / invalid API key | Wrong key, missing Bearer, expired or disabled key | Create a new key in RutaAPI and test /v1/models |
| Wrong Base URL | Used dashboard URL or homepage URL instead of API endpoint | Use https://api.rutaapi.com/v1 |
| 404 / endpoint not found | Missing /v1 in the Base URL | Always include /v1: https://api.rutaapi.com/v1 |
| Model not found | Model ID is not enabled or typed incorrectly | Check app pricing page for enabled model IDs |
| 429 rate limit | Too many concurrent requests or limited route | Slow down requests or choose another enabled route |
| 503 upstream unavailable | Upstream route, gateway, or provider temporarily unavailable | Retry, switch model route, or check dashboard for status |
| Environment variable not loaded | Shell session not restarted after export | Restart the terminal or re-export the variables |
| Shell session not restarted | Config changes not picked up by Codex CLI | Restart Codex CLI or reload the config |
Cost and usage tracking
RutaAPI uses prepaid credits. Check the app pricing page for model rates and enabled routes. After test calls, check the usage logs and remaining balance in the dashboard.
FAQ
How do I change the Codex CLI Base URL?
To change the Codex CLI Base URL, set either openai_base_url in your config file for the built-in provider, or add a custom provider entry with base_url in a model_providers section. For RutaAPI, the Base URL is https://api.rutaapi.com/v1. Codex CLI configuration can vary by version, so check your installed release for the current config format.
Which environment variables does Codex CLI use for custom API providers?
Codex CLI maps environment variables to config fields based on your version and config format. For a custom provider, you typically declare env_key in your model_providers section — for example env_key = "RUTAAPI_API_KEY" — then export that variable before running Codex CLI. Some versions may also honour OPENAI_BASE_URL directly. If env vars do not work as expected, use an explicit config file entry instead.
How do I test whether the Base URL works?
Call GET /v1/models with your API key before running any Codex tasks:
curl https://api.rutaapi.com/v1/models -H "Authorization: Bearer YOUR_RUTAAPI_KEY"
A 200 response with a model list means the Base URL and API key are working. A 401 response means the key is wrong or mismatched. Fix smaller requests first — they give clearer error messages than full Codex runs.
Why does Codex CLI return invalid API key or model not found?
HTTP 401 or "invalid API key" usually means the API key does not match the Base URL, or it was sent to the wrong endpoint. Verify that both the key and Base URL come from the same platform. "Model not found" means the model ID is not enabled or typed incorrectly — run /v1/models and copy an exact model id from the response. Do not guess the model name.
Should I use openai_base_url or a custom provider base_url?
Use openai_base_url when you want to replace the default OpenAI provider route with an OpenAI-compatible gateway. Use a custom provider base_url when you want a separate, named provider profile. Some Codex CLI versions may not support both options — test with a small /v1/models request to confirm your version works with the approach you choose.
What Base URL should I use with Codex CLI?
For an OpenAI-compatible provider, use https://api.rutaapi.com/v1 as the Base URL. Always include /v1.
What API key should I use with Codex CLI?
Use a RutaAPI API key created from the dashboard at app.rutaapi.com. Keys are shown only once at creation — copy and store them securely. The key must match the Base URL — using a key from another provider will cause a 401 error.
What model ID should I use?
Use a model ID returned by GET /v1/models. Do not guess — copy the exact id from the response. If the model ID is not in your /v1/models response, it is not active in your account — check the app pricing page or add credits.
Why does Codex CLI say model not found?
The model ID may be unavailable, disabled, or typed incorrectly. Check your enabled models in the app pricing page and verify with /v1/models. Model availability can change, so re-check if a previously available model no longer appears.
Why does Codex CLI return 401 or invalid API key?
HTTP 401 means the API key is missing, incorrect, or sent to the wrong Base URL. Verify the key and Base URL both come from RutaAPI. Run /v1/models to confirm the key is valid. Do not use a key from one provider with a URL from another.
Why does Codex CLI return 503?
HTTP 503 means the upstream route is temporarily unavailable. Retry, switch model route, or check the RutaAPI dashboard for status.
Is RutaAPI an official Codex CLI provider?
No. RutaAPI is an OpenAI-compatible API gateway that can be configured through custom or compatible provider settings. It is not an official Codex CLI, OpenAI, Anthropic, Google or Microsoft service. Codex CLI can work with compatible providers when the Base URL, API key, model ID, and installed Codex CLI version support the configuration.
Change Codex CLI Base URL to use an OpenAI-compatible API. For RutaAPI, set the Base URL to https://api.rutaapi.com/v1, paste your RutaAPI API key, and test /v1/models before running Codex tasks. Use openai_base_url for the built-in provider or a custom provider base_url for a separate profile. Model availability can change — check app pricing/dashboard for enabled models. RutaAPI is not an official Codex CLI, OpenAI, Anthropic, Google or Microsoft service.