Codex CLI
Run OpenAI's Codex CLI on Nebul models through a custom model provider in config.toml.
Codex is OpenAI's open-source coding agent for the terminal. It supports custom model providers, so you can run it on any model in your Nebul project instead of OpenAI's hosted models.
Prerequisites
- A Nebul AI Studio account with API access
- An API key for your active project
- A model ID from the Model Catalog. Pick one that supports tool calling; Codex needs it.
Installation
npm install -g @openai/codexConfigure the provider
Codex keeps provider definitions in ~/.codex/config.toml. A provider is a named connection: where to send requests, which key to use, and which request format to speak. Define Nebul as one and select it as the default:
# ~/.codex/config.toml
model = "zai-org/GLM-5.3"
model_provider = "nebul"
[model_providers.nebul]
name = "Nebul"
base_url = "https://api.inference.nebul.io/v1"
env_key = "NEBUL_API_KEY"
wire_api = "responses"What these fields do:
env_keynames the environment variable Codex reads the key from. Export it before launching:export NEBUL_API_KEY=sk-your-api-key-herewire_apiselects the request format. Nebul supports both options:"responses"is Codex's native format and the one to prefer, and"chat"switches to plain Chat Completions.- Provider IDs
openai,ollama, andlmstudioare reserved by Codex, which is why this guide usesnebul.
Set model to any Nebul model ID your project can access. To switch models for a single session, run codex -m provider/model-id, for example codex -m nebul/openai/gpt-oss-120b.
Where these settings live
Custom provider keys must be set in your user-level ~/.codex/config.toml. Codex deliberately ignores model_providers and model_provider in project-level .codex/config.toml files, so a repository can't redirect your requests.
Run it
From your project directory:
codexRequests now go to Nebul, and usage is attributed to the API key's project in AI Studio. For the full command surface (codex exec, approval modes, profiles), see the Codex CLI docs.
Verify the connection
A quick smoke test before starting an interactive session:
codex exec "Reply with the single word OK"The run ends with the model's reply, OK. If you see that, the provider, key, and model are wired correctly. Common failures:
401 Unauthorized:NEBUL_API_KEYis unset or revoked in the terminal where you launchedcodex.model not found: the model ID inmodelmust exactly match a catalog ID available to your project.- Reserved provider errors: Codex rejects provider configs that reuse
openaias the ID. Keepnebul.
Data and telemetry
Codex is open source and self-contained. With a custom provider, inference traffic goes only to your Nebul endpoint. The usage data OpenAI collects applies when you sign in with a ChatGPT account. With API-key or custom-provider auth, no OpenAI account session is involved.
If you previously signed in to Codex with ChatGPT, run codex logout to clear the cached credentials before switching fully to the Nebul provider.
Nebul-side handling of prompts and completions is described in Privacy & Security.