# Codex CLI

> Connecting Codex CLI to the gateway through a provider in config.toml.

Codex CLI works through `/v1/responses` in the OpenAI Responses format.

## Quick start

Codex reads the key from the environment variable named in `env_key`:

```bash
export AI_SELLER_API_KEY=$AISELLER_API_KEY
```

Add the provider to `~/.codex/config.toml` (the `aiseller` provider name is
arbitrary — it lives only in your config):

```toml
model_provider = "aiseller"
model = "gpt-5.6-sol"

[model_providers.aiseller]
name = "aiseller"
base_url = "https://ai-seller.vibe-codes.ru/v1"
env_key = "AI_SELLER_API_KEY"
wire_api = "responses"
```

Then run `codex`. Switch models with `codex -m <id>`; take IDs from the
[catalog](https://ai-seller.vibe-codes.ru/en/docs/models).

## How it works

- `wire_api = "responses"` — Codex sends requests to `/v1/responses`.
- The gateway keeps no provider-side state (`store: false`), and Codex sends
  the whole history with every request — exactly as needed.
- The provider's built-in tools (web search) are stripped; Codex's local tools
  (`shell`, `apply_patch`) work.

## Troubleshooting

| Symptom | Cause and fix |
| --- | --- |
| `Missing environment variable: AI_SELLER_API_KEY` | The variable is not exported in this terminal — run the `export` from the quick start or add it to your shell profile. |
| `401 invalid_api_key` | Wrong or revoked key. |
| `404 model_not_found` | The model ID has a typo or the model is not a text model — check `GET /v1/models`. |
| `400 unsupported_parameter` with `previous_response_id` | A provider-side state mode is on — it is not supported; Codex does not use it by default. |
| The stream breaks off midway | The provider failed after the response started — retry; see [Streaming](https://ai-seller.vibe-codes.ru/en/docs/streaming). |
