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

# Codex

> Configure Codex CLI with a custom derestricted.ai Responses API provider.

Codex CLI can connect to derestricted.ai through a custom model provider using the [Responses API](/api/responses).

## Before you start

[Install Codex CLI](https://learn.chatgpt.com/docs/codex/cli), then create a key in the [console](https://derestricted.ai/console/). New verified accounts receive \$5 in starting credit.

Set your key in the terminal that will launch Codex:

```bash theme={"system"}
export DERESTRICTED_API_KEY="glmk_YOUR_API_KEY"
```

## Add the provider

Merge this configuration into your **user** `~/.codex/config.toml`. Keep the first four settings above any TOML table headers. Provider settings in a project's `.codex/config.toml` are ignored by current Codex versions. See the [official configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference).

```toml theme={"system"}
model = "derestricted-llm"
model_provider = "derestricted"
web_search = "disabled"
model_supports_reasoning_summaries = false

[model_providers.derestricted]
name = "derestricted.ai"
base_url = "https://api.derestricted.ai/v1"
env_key = "DERESTRICTED_API_KEY"
wire_api = "responses"
requires_openai_auth = false
supports_websockets = false
```

This uses your derestricted key instead of OpenAI authentication. The endpoint speaks HTTP with streamed responses; hosted web search is unavailable. The provider fields follow OpenAI's [custom provider documentation](https://learn.chatgpt.com/docs/config-file/config-advanced#custom-model-providers).

## Start Codex

Open a project directory and run:

```bash theme={"system"}
codex
```

Start with a small request, such as “Explain this repository's entry point.” Keep Codex's normal approval settings for commands and file edits.

<Note>
  This is a compatibility endpoint, not the OpenAI service. Responses are
  stateless, and hosted tools, image input, reasoning controls, and server-side
  conversation storage are unavailable. Custom tool formats depend on the Codex
  version. See [Responses compatibility](/api/responses) before relying on a
  specific agent feature.
</Note>

## If something fails

* **Missing key:** launch Codex from the terminal where `DERESTRICTED_API_KEY` is set.
* **Wrong provider:** check your user configuration and any selected configuration profile. Use the custom `derestricted` provider ID.
* **Invalid `wire_api`:** current Codex supports `responses`; do not change it to `chat`.
* **Unsupported tools or oversized requests:** use a smaller task and review [API compatibility](/api/introduction) and the [error guide](/api/errors).
