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

# Codex

> Use OpenAI's Codex with Routeway by adding a custom provider that points to Routeway's OpenAI-compatible API.

Codex is OpenAI's open-source local coding agent and desktop application. You can connect it to Routeway by defining a custom provider in your config file and using your **Routeway API key**.

<Note>
  Requires a valid Routeway API key. Get yours from the [dashboard](https://routeway.ai/dashboard/api-keys).
</Note>

***

## Setup

<Steps>
  <Step title="Install Codex">
    Follow the [official installation instructions](https://github.com/openai/codex) for your platform. Both the CLI and desktop app use the same settings file.
  </Step>

  <Step title="Configure Codex to use Routeway">
    Open (or create) `~/.codex/config.toml` and add a custom provider pointing to Routeway:

    ```toml theme={null}
    model_provider = "routeway"
    model_reasoning_effort = "high"
    model = "o4-mini"

    [model_providers.routeway]
    name = "routeway"
    base_url = "https://api.routeway.ai/v1"
    env_key = "ROUTEWAY_API_KEY"
    ```

    <Info>
      `o4-mini` is one example starter model. You can use any model that supports tools — browse available options at [routeway.ai/models](https://routeway.ai/models).
    </Info>
  </Step>

  <Step title="Set your API key">
    Codex reads the API key from the environment variable named in `env_key`.

    <CodeGroup>
      ```bash Shell (macOS / Linux / WSL) theme={null}
      export ROUTEWAY_API_KEY="YOUR_ROUTEWAY_API_KEY"
      ```

      ```powershell Windows PowerShell theme={null}
      $env:ROUTEWAY_API_KEY="YOUR_ROUTEWAY_API_KEY"
      ```
    </CodeGroup>

    <Warning>
      Keep real API keys out of version control and shell history.
    </Warning>
  </Step>

  <Step title="Start Codex">
    In your project directory, run:

    ```bash theme={null}
    codex
    ```

    Your requests will be sent through Routeway using the provider defined in `config.toml`.
  </Step>
</Steps>

***

## Reference

| Setting         | Value                        |
| --------------- | ---------------------------- |
| Config file     | `~/.codex/config.toml`       |
| Base URL        | `https://api.routeway.ai/v1` |
| API key env var | `ROUTEWAY_API_KEY`           |
| Example model   | `o4-mini`                    |

***

## Example Prompts

Try these once you're connected:

* *"Summarize this repository: structure, build system, and entry points."*
* *"Find where feature X is implemented and list the relevant files."*
* *"Run tests and fix the first failing test."*
* *"Refactor module Y and update all call sites."*
