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

# Codex

> Connect Codex to Novita's OpenAI-compatible LLM API endpoint.

Codex is an AI coding tool that runs in your terminal. You can connect Codex to Novita's OpenAI-compatible LLM API endpoint and use Novita models for code understanding, generation, refactoring, and debugging tasks.

<Warning>
  Codex currently supports the Responses API only. Configure `wire_api = "responses"` as shown below, and do not switch this integration to Chat Completions mode.
</Warning>

## Prerequisites

Before you begin, prepare the following values:

* **API key**: Create or copy an API key from [Key Management](https://novita.ai/settings/key-management).
* **Base URL**: `https://api.novita.ai/openai/v1`
* **Model ID**: Copy the model ID you want to use from the Model Hub, such as `deepseek/deepseek-v3.1`.

<Tip>
  Keep your API key private. Use it only in your local Codex configuration and never commit it to a Git repository.
</Tip>

## Install Codex

Before installing Codex, make sure [Node.js 18 or higher](https://nodejs.org/en/download/) is installed on your machine.

On macOS, if you use Homebrew, you can install Node.js with:

```bash theme={"system"}
brew install node
```

Check your Node.js and npm versions:

```bash theme={"system"}
node -v
npm -v
```

Install the Codex CLI:

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

Check the Codex version:

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

## Configure your API key

Open your shell configuration file, for example `~/.zshrc`:

```bash theme={"system"}
nano ~/.zshrc
```

Add the following environment variable:

```bash theme={"system"}
export NOVITA_API_KEY="<your-novita-api-key>"
```

Reload your shell configuration and confirm the variable is available:

```bash theme={"system"}
source ~/.zshrc
echo $NOVITA_API_KEY
```

## Configure Codex

Open the Codex configuration file:

```bash theme={"system"}
mkdir -p ~/.codex
nano ~/.codex/config.toml
```

Add the following configuration, and replace `model` with the Novita model ID you want to use:

```toml theme={"system"}
model_provider = "novita"
model = "deepseek/deepseek-v3.1"

[model_providers]
[model_providers.novita]
name = "Novita"
wire_api = "responses"
requires_openai_auth = true
base_url = "https://api.novita.ai/openai/v1"
env_key = "NOVITA_API_KEY"
```

## Start Codex

Go to your project directory and start Codex:

```bash theme={"system"}
cd <your-project-directory>
codex
```

You can now enter a coding task, for example:

```text theme={"system"}
Read this project and summarize the main modules.
```

If Codex returns an authentication or model error, check that:

* `NOVITA_API_KEY` is available in the current terminal session.
* `model` exactly matches the Model ID in Novita's Model Hub.
* `base_url` is set to `https://api.novita.ai/openai/v1`.
