Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Each guide walks through installation, configuration, and model selection so you
| OpenClaw | [openclaw.md](./openclaw.md) | [YouTube](https://youtu.be/HxIAYOQT90Q) | [edenai.co/integrations/openclaw](https://www.edenai.co/integrations/openclaw) |
| OpenCode | [opencode.md](./opencode.md) | [YouTube](https://youtu.be/OYHRY5rblz0) | [edenai.co/integrations/opencode](https://www.edenai.co/integrations/opencode) |
| Cline | [cline.md](./cline.md) | [YouTube](https://youtu.be/_M8PwHSwgMQ) | [edenai.co/integrations/cline](https://www.edenai.co/integrations/cline) |
| Codex | [codex.md](./codex.md) | [YouTube](https://youtu.be/sVLPbencnnM) | [edenai.co/integrations/codex](https://www.edenai.co/integrations/codex) |

More integrations are added regularly. Open an issue if there's a tool you'd like us to cover.

Expand Down
148 changes: 148 additions & 0 deletions codex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Codex + Eden AI

Connect [OpenAI Codex CLI](https://github.com/openai/codex) to Eden AI and route your terminal coding agent through **500+ models** with smart routing, automatic fallbacks, and a single API key.

> Get your Eden AI key at [app.edenai.run](https://app.edenai.run/) → **API Keys**.

Follow this tuto in the same time with our video tuto on [Youtube](https://youtu.be/sVLPbencnnM)

---

## 1. System dependencies

On a fresh Linux machine (Ubuntu / Debian / WSL):

```bash
sudo apt update
sudo apt install -y curl git
```

## 2. Install Node.js

Codex CLI requires **Node.js 22+**.

```bash
sudo apt install -y nodejs npm

# Verify
node --version # v22.x or newer
```

If the packaged version is too old, install via [nvm](https://github.com/nvm-sh/nvm) or [nodesource](https://github.com/nodesource/distributions).

## 3. Install Codex CLI

```bash
# Via npm
npm install -g @openai/codex

# Or via Homebrew (macOS)
brew install codex
```

Verify the binary is on your PATH:

```bash
codex --version
```

## 4. Add Eden AI as a custom provider

Codex stores its config at `~/.codex/config.toml`. Open it and add the Eden AI provider, then set it as the default with the `@edenai` smart-router model:

```bash
nano ~/.codex/config.toml
```

```toml
model = "@edenai"
model_provider = "edenai"

[model_providers.edenai]
name = "Eden AI"
base_url = "https://api.edenai.run/v3"
env_key = "EDENAI_API_KEY"
wire_api = "chat"
```

Codex reads the API key from the environment variable named in `env_key`. Export your Eden AI key (add this to `~/.bashrc` or `~/.zshrc` to make it permanent):

```bash
export EDENAI_API_KEY="YOUR_EDEN_AI_API_KEY"
```

### Why `@edenai`?

`@edenai` is Eden AI's **smart router**. For every request, it automatically picks the best-performing model based on quality, latency, cost and live provider health, so your Codex agent always uses the right model without a config change.

[How smart routing works →](https://www.edenai.co/docs/v3/llms/smart-routing)

## 5. Start Codex

Launch the agent in any project:

```bash
codex
```

That's it. Every LLM call now flows through Eden AI, with built-in fallbacks, unified billing, and per-request cost visibility.

---

## Using specific models

`@edenai` handles routing automatically, but you can target a specific model by changing the top-level `model` value to a `provider/model` string:

```toml
model = "anthropic/claude-sonnet-4-5"
model_provider = "edenai"
```

You can also override the model for a single run from the command line:

```bash
codex -c model='"anthropic/claude-sonnet-4-5"'
```

Common choices:

| Model | Best for |
|---|---|
| `@edenai` | **Default** — smart routing across all providers |
| `anthropic/claude-sonnet-4-5` | Balanced reasoning |
| `anthropic/claude-opus-4-7` | Maximum capability |
| `anthropic/claude-haiku-4-5` | Fast and cheap |
| `openai/gpt-5` | OpenAI's frontier model |
| `google/gemini-2.5-pro` | Long context, multimodal |

Browse the full catalog at [app.edenai.run/models](https://app.edenai.run/models).

## Troubleshooting

### `401 Unauthorized`
Verify your Eden AI key, and confirm the `EDENAI_API_KEY` environment variable is exported in the same shell you launched Codex from. Grab a fresh key at [app.edenai.run → API Keys](https://app.edenai.run/).

### `model not found`
Ensure the model uses the `provider/model` format (or `@edenai` for the smart router). No bare model names.

### Provider not used
Confirm both `model_provider = "edenai"` at the top level and the `[model_providers.edenai]` table are present, and that `wire_api` is set to `"chat"`.

### Connection issues
Confirm the base URL is exactly `https://api.edenai.run/v3` and check Eden AI status at [app-edenai.instatus.com](https://app-edenai.instatus.com/).

## Uninstall

```bash
npm uninstall -g @openai/codex
rm -rf ~/.codex
```

---

## Next steps

- [Smart routing](https://www.edenai.co/docs/v3/llms/smart-routing)
- [Fallbacks](https://www.edenai.co/docs/v3/llms/fallback)
- [Eden AI pricing](https://www.edenai.co/pricing)
- [Codex CLI GitHub](https://github.com/openai/codex)
Loading