Melious

Codex is OpenAI's terminal coding agent — one codex binary from npm, configured through TOML, with a provider system that points it at any backend speaking the OpenAI Responses API. That last part is the whole story here. Codex's custom-provider path accepts only wire_api = "responses", so this integration rides on our Responses endpoint rather than the /v1/chat/completions route the rest of this section uses. Both are live, so pointing Codex at us is a provider definition and an API key.

With the Melious CLI

With the Melious CLI installed and signed in, two commands take you from nothing to a session:

melious tools install codex
melious launch codex

For Codex, tools install prints OpenAI's installer command for your OS rather than running it — run that line yourself, then launch from inside your project. The first launch in a project asks Trust this workspace? The agent runs as you, with your Melious key, so Melious asks before handing it over; the answer defaults to no. Workspace trust covers what a grant means and how to revoke it.

Melious configures Codex on its command line alone: --model with your main model, and --config overrides that declare a melious provider on our Responses endpoint, reading the key from MELIOUS_API_KEY. It writes no file, so your ~/.codex config, sessions, and login stay as they are. Codex runs one model, so only the main tier applies — with no main model configured, Melious refuses to launch rather than let Codex fall back to its own default. Models, -- passthrough, and exit status: launching a coding agent.

Manual setup (alternative)

For when you'd rather not use the Melious CLI. The provider block below is the file-based version of what Melious passes on the command line.

Install Codex

OpenAI's installer, for macOS and Linux:

curl -fsSL https://chatgpt.com/codex/install.sh | sh

Windows PowerShell:

irm https://chatgpt.com/codex/install.ps1 | iex

Or npm or Homebrew:

npm install -g @openai/codex
brew install codex             # macOS, Linux

Check it landed:

codex --version

Add Melious as a provider

Codex reads ~/.codex/config.toml (or the one under CODEX_HOME, if you set it). Add a provider block there and select it — Codex ignores model_provider and model_providers in a project's .codex/config.toml, so a repository can't redirect your key:

~/.codex/config.toml
model = "<MODEL_ID>"
model_provider = "melious"
model_context_window = 131072

[model_providers.melious]                               
name = "Melious"
base_url = "https://api.melious.ai/v1"
env_key = "MELIOUS_API_KEY"
env_key_instructions = "Create a key at melious.ai/account/api/keys"
wire_api = "responses"

Exporting OPENAI_BASE_URL does not redirect Codex at us. Current releases ignore that variable and send traffic to api.openai.com regardless — you get a 401 naming OpenAI's host, which reads like an auth problem and isn't one. The provider block is the only way in.

base_url carries /v1, unlike the Anthropic-shape endpoint that Claude Code uses. No trailing slash.

Don't name the provider openai. That ID is reserved, and Codex refuses to load a config that reuses it — you get model_providers contains reserved built-in provider IDs before the session starts. Any other name is fine.

model_context_window is the window Codex plans against. It ships metadata for OpenAI's own models only, so set this from _meta.context_length on GET /v1/models?include_meta=true. Leave it out and Codex warns that it's falling back to default metadata, then plans against that instead of your model's real window.

Run a session

Codex reads the key from the environment variable named in env_key, once, at startup:

export MELIOUS_API_KEY=sk-mel-<YOUR_API_KEY>
codex

Windows PowerShell:

$env:MELIOUS_API_KEY = "sk-mel-<YOUR_API_KEY>"
codex

Codex prints its wiring in the session header. The provider line is the one to check:

model: <MODEL_ID>
provider: melious

If provider says anything else, model_provider didn't take.

Picking a model

Codex defaults to a gpt-5-family model name, and we don't run those. There's no name substitution on the OpenAI-shape endpoints either — only claude-* names map, and only on the Anthropic path — so an unset model fails on the first turn. Set it explicitly and keep it set.

Beyond that, Codex leans hard on long tool-call chains and multi-file edits, so pick something that holds a sequence together without losing the thread. Filter GET /v1/models?include_meta=true on _meta.capabilities.function_calling and _meta.context_length, or browse melious.ai/hub/models.

Append a flavor suffix to the model ID to bias provider selection — <MODEL_ID>:speed, :price, or :eco. See Routing for the decision table.

Profiles

A profile is a whole config file layered over your base one, named <name>.config.toml in your Codex home — not a section inside config.toml:

~/.codex/melious-fast.config.toml
model = "<LIGHTWEIGHT_MODEL_ID>"
model_provider = "melious"
model_context_window = 131072
codex --profile melious-fast
codex -c model_provider="melious" -m "<MODEL_ID>"

There's no --provider flag; -c is how you override any config key from the command line, and it parses values as TOML before falling back to a literal string. Precedence runs CLI flags, then the profile, then project config, then user config.

Non-interactive runs

codex exec is the scripted path — same config, no TUI:

export MELIOUS_API_KEY=sk-mel-<YOUR_API_KEY>
codex exec --skip-git-repo-check "summarize the diff on this branch"
codex exec --json "run the test suite and report failures"

In CI, set MELIOUS_API_KEY in the job environment rather than a dotfile — Codex reads it at launch and never re-reads it. Sandbox policy is a flag — -s read-only, -s workspace-write, or -s danger-full-access. The defaults are Codex's; see OpenAI's Codex docs for the current behavior.

What's different

  • Responses, not Chat Completions. Codex is the one tool in this section that talks to /v1/responses. Everything else here uses /v1/chat/completions. Same key, same base URL, different endpoint — and wire_api = "responses" is what selects it.

  • OPENAI_BASE_URL is ignored. Setting it points nowhere useful. The provider block is mandatory, not a nicety.

  • Streaming is incremental. Our Responses stream emits the standard event lifecycle — response.output_item.added, one response.output_text.delta per chunk, response.output_item.done, then response.completed or response.incomplete. The full sequence is on the Responses page.

  • No environment_impact or billing_cost on the wire. Codex uses our Responses endpoint, which returns neither extension object, streamed or not — among conversational endpoints, only Chat Completions returns them. Usage is still metered and still shows up in your usage dashboard — you can't read it off the response.

  • No explicit cache control. Nothing marks a prefix as cacheable. Transparent prefix caching still happens on the provider side and bills at the cheaper cache-read rate. See Models.

  • Sandboxing is Codex's, not ours. sandbox_mode and approval_policy govern what the agent may touch on your machine. Unrelated to routing, but it's what usually refuses an edit.

When it breaks

  • 401 Unauthorized naming api.openai.com — you exported OPENAI_BASE_URL and expected it to redirect. It doesn't. Add the [model_providers.melious] block and set model_provider = "melious".
  • A stream error or reconnect loop on the first turn — a model ID we don't have. Most often that's an unset model, because Codex then falls back to its own default (a gpt-5-family name). An unknown model is normally refused before the stream opens, with a 404 not_found_error; a failure after the stream has started ends it with response.failed and then an error event. Check the ID with GET /v1/models; a non-streaming call returns the real error, Model not found: <MODEL_ID>.
  • warning: Model metadata for <MODEL_ID> not found — expected, and harmless. Codex ships metadata for OpenAI's own models only. Set model_context_window so its planning is based on your model's real window rather than a fallback.
  • Missing environment variable — Codex reads env_key once, at launch, from the shell that launched it. Export it there, or set it in the CI job environment. Filling in env_key_instructions makes this message tell the reader what to do.
  • model_providers contains reserved built-in provider IDs — your provider is named openai, which Codex reserves. Rename it to melious and point model_provider at the new name.
  • Config edits appear to do nothing — the provider block sits in a project's .codex/config.toml, where Codex ignores provider settings. Move it to ~/.codex/config.toml, or pass -c on the command line.
  • 429 mid-session — per-plan token caps, and a long agent session carries a lot of context per turn. Rate limits covers which plan lifts which limit.

Errors and retry patterns: Errors.

On this page