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

# Connect Codex to LLMEasy with a custom model

> Connect LLMEasy to Codex with /v1 and OpenAI Responses.

Connecting Codex to LLMEasy requires a custom model provider and API Key. The `base_url` must be `https://www.llmeasy.ru/v1`, and the protocol is `OpenAI Responses`.

<Info>
  If you want to keep the official Codex App login state, plugins, or Remote Control while using a third-party API, use the [login-preserving Codex setup](/en/faq/codex/official-login-third-party-api).
</Info>

## Prerequisites

* Node.js installed
* LLMEasy API Key (<a href={"https://www.llmeasy.ru/register"}>register here</a>)

<Warning>
  Clear OpenAI-related environment variables before setup so they do not override the settings in `config.toml`.

  Clear these variables:

  * `OPENAI_API_KEY`
  * `OPENAI_BASE_URL`

  Run on macOS / Linux:

  ```bash theme={null}
  unset OPENAI_API_KEY
  unset OPENAI_BASE_URL
  ```

  Run in Windows PowerShell:

  ```powershell theme={null}
  Remove-Item Env:OPENAI_API_KEY -ErrorAction SilentlyContinue
  Remove-Item Env:OPENAI_BASE_URL -ErrorAction SilentlyContinue
  [Environment]::SetEnvironmentVariable("OPENAI_API_KEY", $null, "User")
  [Environment]::SetEnvironmentVariable("OPENAI_BASE_URL", $null, "User")
  ```
</Warning>

## Install Codex

```bash theme={null}
npm install -g @openai/codex
```

## Setup

<Tabs>
  <Tab title="Automatic setup">
    You can run the LLMEasy automatic setup script directly. It only writes the LLMEasy provider configuration and does not replace the installation prerequisites above. The script requires `Node.js`. If you do not pass an API Key or model explicitly, the script prompts for them when the tool supports interactive input.

    Follow the step for your operating system. You only need one of them.

    <Steps>
      <Step title="If you use macOS / Linux">
        ```bash theme={null}
        curl -fsSL https://www.llmeasy.ru/install-codex-provider.sh | bash
        ```
      </Step>

      <Step title="If you use Windows">
        ```powershell theme={null}
        iwr https://www.llmeasy.ru/install-codex-provider.ps1 -OutFile "$env:TEMP\install-codex-provider.ps1"; powershell -ExecutionPolicy Bypass -File "$env:TEMP\install-codex-provider.ps1"
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Configure via CC Switch">
    This setup path is maintained in the [CC Switch guide](/en/ai-tools/cc-switch#codex-cli).

    Go straight to [the Codex tab in the CC Switch guide](/en/ai-tools/cc-switch#codex-cli).

    After you finish in CC Switch, come back to this page for the remaining startup, verification, or activation notes.
  </Tab>

  <Tab title="Manual setup">
    <Steps>
      <Step title="Confirm the default models">
        The config below uses `gpt-5.5` as the default model and `gpt-5.4` as the review model. If you need to switch models, open the <a href={"https://www.llmeasy.ru/pricing"}>LLMEasy model plaza</a> and copy a currently available model ID from the **GPT Key group**.
      </Step>

      <Step title="Confirm the config file locations">
        Manual setup requires the Codex `config.toml` file.

        | System        | `config.toml`                           |
        | ------------- | --------------------------------------- |
        | macOS / Linux | `~/.codex/config.toml`                  |
        | Windows       | `C:\Users\YOUR_USER\.codex\config.toml` |
      </Step>

      <Step title="Edit the Codex config file">
        Open `config.toml`. Create it if it does not exist.

        <Warning>
          This config only applies when you manually edit `~/.codex/config.toml`. If you configure Codex through CC Switch, follow the [CC Switch guide](/en/ai-tools/cc-switch#codex-cli) exactly. Do not copy this block to replace configuration managed by CC Switch.
        </Warning>

        Add the following config:

        ```toml theme={null}
        model_provider = "custom"
        model = "gpt-5.5"
        review_model = "gpt-5.4"
        model_reasoning_effort = "high"
        model_context_window = 1000000
        model_auto_compact_token_limit = 900000
        windows_wsl_setup_acknowledged = true

        [model_providers]
        [model_providers.custom]
        name = "LLM Easy"
        base_url = "https://www.llmeasy.ru/v1"
        wire_api = "responses"
        requires_openai_auth = false
        request_max_retries = 4
        stream_max_retries = 8
        stream_idle_timeout_ms = 300000
        supports_websockets = false
        ```
      </Step>

      <Step title="Restart Codex in the terminal">
        After changing `config.toml`, stop the current Codex process and start it again in a new terminal session.
      </Step>

      <Step title="Start Codex">
        ```bash theme={null}
        codex
        ```
      </Step>
    </Steps>

    ### Config parameter reference

    The [official Codex config reference](https://developers.openai.com/codex/config-reference) explains that `model_provider` points to a provider id under `model_providers`, custom providers are defined with `[model_providers.<id>]`, and `wire_api = "responses"` is the supported provider protocol value.

    | Config                           | Meaning                                                                                                                                      | Recommended value             |
    | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
    | `model_provider`                 | Selects the model provider Codex uses. The value must match `[model_providers.custom]`.                                                      | `"custom"`                    |
    | `model`                          | The default main model Codex uses for everyday coding, editing, and agent tasks.                                                             | `"gpt-5.5"`                   |
    | `review_model`                   | The model used by the `/review` command. If unset, Codex uses the current main model.                                                        | `"gpt-5.4"`                   |
    | `model_reasoning_effort`         | Controls reasoning strength for models that support the Responses API. Valid values include `minimal`, `low`, `medium`, `high`, and `xhigh`. | `"high"`                      |
    | `model_context_window`           | Tells Codex the active model context window size in tokens.                                                                                  | `1000000`                     |
    | `model_auto_compact_token_limit` | Automatically compacts conversation history when it reaches this token threshold.                                                            | `900000`                      |
    | `windows_wsl_setup_acknowledged` | A Windows / WSL onboarding acknowledgement flag, mainly used to avoid repeated setup prompts.                                                | `true`                        |
    | `[model_providers]`              | Parent table for custom model provider configuration.                                                                                        | `[model_providers]`           |
    | `[model_providers.custom]`       | Defines a custom provider with the id `custom`; `model_provider = "custom"` references this table.                                           | `[model_providers.custom]`    |
    | `name`                           | Provider display name. It only affects presentation, not request behavior.                                                                   | `"LLM Easy"`                  |
    | `base_url`                       | API base URL. Codex sends model requests to this endpoint.                                                                                   | `"https://www.llmeasy.ru/v1"` |
    | `wire_api`                       | Provider protocol. In Codex provider config, `responses` is the supported value and the default.                                             | `"responses"`                 |
    | `requires_openai_auth`           | Whether to use official OpenAI authentication. This custom proxy provider disables OpenAI auth.                                              | `false`                       |
    | `request_max_retries`            | Maximum retry count for ordinary failed HTTP requests. The official default is `4`.                                                          | `4`                           |
    | `stream_max_retries`             | Maximum retry count for interrupted SSE streams. The official default is `5`; proxy chains can use a higher value.                           | `8`                           |
    | `stream_idle_timeout_ms`         | Idle timeout for SSE streams in milliseconds. `300000` equals 5 minutes.                                                                     | `300000`                      |
    | `supports_websockets`            | Whether this provider declares support for the Responses API WebSocket transport.                                                            | `false`                       |

    Note: The [`gpt-5.5` model page](https://developers.openai.com/api/docs/models/gpt-5.5) shows that it supports `high` reasoning effort and has a `1,050,000` token context window. Setting `model_context_window = 1000000` is a reasonable conservative value, while `model_auto_compact_token_limit = 900000` delays compaction and fits heavy long-running tasks.

    If you write the config through CC Switch, prefer the config generated by CC Switch. Only edit these values yourself for manual setup or troubleshooting.
  </Tab>
</Tabs>

## Related FAQ

* [What is Codex CLI?](/en/faq/codex/what-is-codex-cli)
* [Codex CLI vs Codex App vs Codex Web](/en/faq/codex/codex-cli-vs-app-vs-web)
* [How to configure Codex CLI config.toml](/en/faq/codex/config-toml)
* [What are model\_provider, base\_url, and wire\_api?](/en/faq/codex/model-provider-base-url-wire-api)
* [What do review\_model and reasoning\_effort mean?](/en/faq/codex/review-model-reasoning-effort)
* [What is AGENTS.md and how should you write it?](/en/faq/codex/agents-md)
* [What are Codex CLI sandbox and approval modes?](/en/faq/codex/sandbox-approval)
* [OpenAI-compatible API vs Anthropic-compatible API](/en/faq/concepts/openai-compatible-vs-anthropic-compatible)
* [Claude Code vs Codex CLI](/en/faq/concepts/claude-code-vs-codex-cli)

## Verify the setup

After startup, send a test message. A normal reply means the connection is working.

If something fails, check:

1. `base_url` is `https://www.llmeasy.ru/v1`
2. `wire_api` is still `responses`
3. `model` is a model ID copied from the **GPT Key group**
4. `model_provider` matches the provider id in `[model_providers.custom]`
5. No old `OPENAI_API_KEY` or `OPENAI_BASE_URL` variables are interfering
