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

# Codex CLI

> Use models provided through ApiGo in Codex CLI for AI coding.

## Install Codex CLI

Install Codex CLI globally with `npm`:

```bash theme={null}
# Version 0.57.0 is recommended
npm i -g @openai/codex@0.57.0
```

## Configure ApiGo API

> **Important: clear OpenAI environment variables before use**
>
> Before configuring, clear the following OpenAI-related environment variables so they do not override your ApiGo settings:
>
> * `OPENAI_BASE_URL`
> * `OPENAI_API_KEY`

## Choose an integration method

<Tabs>
  <Tab title="@apigo/vibe-coding">
    `@apigo/vibe-coding` corresponds to the interactive terminal tool **Agent CLI Switch**. This flow writes and switches Codex config for you directly.

    Follow the flow shown in the screenshots:

    1. Open **Agent CLI Switch v0.1.0**.
    2. In the **Main menu**, choose **Configure tools**.

    <Frame>
      <img src="https://mintcdn.com/apigo/ooezceiFlVzP_oNP/images/coding-plan/vibe-coding/main-menu.png?fit=max&auto=format&n=ooezceiFlVzP_oNP&q=85&s=43f9a32685ab9f5dfa59217798a10ae0" alt="Agent CLI Switch main menu with Configure tools selected." style={{ borderRadius: '0.5rem' }} width="1238" height="956" data-path="images/coding-plan/vibe-coding/main-menu.png" />
    </Frame>

    3. In **Select tool**, choose **Codex**.

    <Frame>
      <img src="https://mintcdn.com/apigo/ooezceiFlVzP_oNP/images/coding-plan/vibe-coding/select-tool.png?fit=max&auto=format&n=ooezceiFlVzP_oNP&q=85&s=d53ff51f4047b809ce1482fec80b7ea1" alt="Agent CLI Switch tool selection screen for switching between Claude Code and Codex." style={{ borderRadius: '0.5rem' }} width="1354" height="824" data-path="images/coding-plan/vibe-coding/select-tool.png" />
    </Frame>

    4. In **Codex edit config**, enter:
       `API URL`: `https://maas.apigo.ai/v1`
       `API Key`: your ApiGo key
    5. After you see the config-saved prompt, choose to apply the configuration immediately.

    After that, run `codex` directly. Before you use it, confirm the currently supported Token Plan model IDs in the [Model Catalog](https://www.apigo.ai/models), then choose the model you need.
  </Tab>

  <Tab title="Manual configuration (Current)">
    1. Edit Codex's config file at `.codex/config.toml` and add:

    ```toml theme={null}
    [model_providers.apigo]
    name = "Chat Completions API"
    base_url = "https://maas.apigo.ai/v1"
    env_key = "APIGO_API_KEY"
    wire_api = "chat"
    requires_openai_auth = false
    request_max_retries = 4
    stream_max_retries = 10
    stream_idle_timeout_ms = 300000

    [profiles.apigo]
    model = "your-model-id"
    model_provider = "apigo"
    ```

    2. Set `APIGO_API_KEY` to your platform key, then replace `your-model-id` with a model ID that is still supported in the [Model Catalog](https://www.apigo.ai/models).

    3. Launch Codex CLI with the configured profile:

    ```bash theme={null}
    codex --profile apigo
    ```
  </Tab>
</Tabs>
