> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nemu.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Codex

> Point the Codex CLI at Nemu as a custom model provider

Codex talks to OpenAI's API, so it uses Nemu's OpenAI-compatible surface. You
add Nemu as a custom provider in Codex's config and select a model by its
gateway name.

## 1. Create a gateway key

In the console, open **API keys** and create one. It belongs to the workspace
you are in, and can reach the providers and models enabled there.

## 2. Add Nemu as a provider

Edit `~/.codex/config.toml`:

```toml theme={null}
model = "openrouter/nemotron"
model_provider = "nemu"

[model_providers.nemu]
name = "Nemu"
base_url = "https://api.nemu.cc/v1"
env_key = "NEMU_API_KEY"
wire_api = "responses"
```

`model` takes a gateway name exactly as `GET /v1/models` reports it. Run this to
see yours:

```bash theme={null}
curl https://api.nemu.cc/v1/models -H "Authorization: Bearer $NEMU_API_KEY"
```

## 3. Run it

```bash theme={null}
export NEMU_API_KEY="YOUR_NEMU_GATEWAY_KEY"
codex
```

## Choosing a wire API

| `wire_api`  | Nemu endpoint               | When to use it                                       |
| ----------- | --------------------------- | ---------------------------------------------------- |
| `responses` | `POST /v1/responses`        | Default. Streaming, tool calls, reasoning summaries  |
| `chat`      | `POST /v1/chat/completions` | Fall back here if a model behaves oddly on Responses |

Nemu implements the Responses API for every model, including ones whose upstream
provider only speaks chat completions, so `responses` is safe even when the
target is not an OpenAI model.

## Notes

* Nemu accepts the key as `Authorization: Bearer` or `x-api-key`; Codex sends the
  bearer header, which is what `env_key` wires up.
* The base URL must include `/v1`. Codex appends `/responses` itself.
* If you want a short name in config, create a mapping in the console and use the
  mapped name as `model`.
* Reasoning effort passes through. Nemu translates it into whatever the target
  model supports rather than rejecting the request.

## Silencing the model metadata warning

Codex prints this on every turn when it does not recognise the model slug:

```
⚠ Model metadata for openrouter/nemotron not found. Defaulting to fallback
metadata; this can degrade performance and cause issues.
```

It is not an error from Nemu. Codex resolves context window, reasoning levels and
compaction thresholds from a catalog compiled into the binary, which only contains
OpenAI's own models, so any gateway model falls back to a generic 272k context
window and no reasoning levels. Codex does not read this from `GET /v1/models`
for a normal `env_key` provider, so the gateway cannot supply it over the wire.

Set the context window yourself, at the top level of `~/.codex/config.toml`:

```toml theme={null}
model_context_window = 1000000
model_auto_compact_token_limit = 900000
```

That fixes the numbers Codex actually uses. To also stop the warning, point Codex
at your own catalog file:

```toml theme={null}
model_catalog_json = "/home/you/.codex/catalog.json"
```

The catalog replaces Codex's built-in one, so it must list every model you use,
and its schema is internal to Codex and can change between releases. Copy an
entry out of `codex-rs/models-manager/models.json` in the Codex repository and
change `slug`, `display_name`, `context_window`, `max_context_window` and
`supported_reasoning_levels`. Set `visibility` to `"list"` for it to appear in
`/models`.

<Note>
  `model_max_output_tokens` and `model_supports_reasoning_summaries` were removed
  from Codex. Setting them today does nothing.
</Note>
