# How to integrate RouterLink in Codex CLI

{% hint style="info" %}
This documentation is provided for informational purposes only and demonstrates how to configure and use our API with third-party AI chat interfaces. Any third-party software, websites, or services mentioned are not operated, controlled, or endorsed by us.
{% endhint %}

## Overview

This tutorial guides you through integrating **RouterLink**—WORLD3's decentralized AI model routing infrastructure—with **Codex**, a personal AI assistant you run on your own devices.

### Purpose

RouterLink provides a unified API endpoint that routes requests to multiple AI model providers through a decentralized network. By integrating RouterLink with Codex, you gain access to a diverse range of large language models (LLMs) without managing multiple API keys or provider-specific configurations.

### What You Will Learn

By completing this tutorial, you will:

* **Configure Codex** to connect with RouterLink's API endpoint
* **Authenticate** using your RouterLink API credentials with custom headers
* **Add and manage AI models** available through the RouterLink network
* **Execute inference requests** through Codex's conversational interface

### Prerequisites

Before proceeding, ensure you have:

* A RouterLink API key (obtain one from the [Quick Start Guide](https://docs.world3.ai/world3/how-to-guides/routerlink/quick-start-guide))
* A web browser with internet access
* Basic familiarity with API configuration concepts

## Introduction to Codex

<figure><img src="/files/oxY7XibCDk6q6d91wzOW" alt=""><figcaption></figcaption></figure>

Codex CLI is OpenAI’s coding agent that you can run locally from your terminal. It can read, change, and run code on your machine in the selected directory. It’s [open source](https://github.com/openai/codex) and built in Rust for speed and efficiency.**Codex** Key Features:

* Terminal-based AI coding assistant
* Natural language → code generation
* Local execution with privacy
* Multiple automation modes
* Multi-language support
* Debugging, refactoring & testing automation
* Interactive workflow in CLI

### Step 1: Install Codex

Install [the newest LTS version of Node.js](https://nodejs.org/en/download/)

After installation is complete, open the terminal (Windows users use PowerShell) and check the version number.

* macOS, Linux, Windows:

```bash
npm i -g @openai/codex
```

Verify the installation.

```
codex --version
```

If the version number is displayed correctly, the installation is successful.

### Step 2: Configure Codex

Codex uses the `config.toml` file to parse provider parameters. Please locate and create/edit this file according to your operating system.

Edit or create `config.toml` file&#x20;

On macOS & Linux: \~/.codex/config.toml&#x20;

On Windows: C:\Users\\\<USERNAME>\\.codex\config.toml

Delete the previous content and replace it with the following.Configuration file:

```toml
model_provider = "routerlink"
model = "world3-router-north-america/openai/gpt-5.3-codex"

[model_providers.routerlink]
name = "RouterLink"
base_url = "https://router-link.world3.ai/api/v1"
env_key = "ROUTERLINK_API_KEY"
```

You can replace the "model" field with any model that is compatible with the OpenAI format.

### Step 3: Codex Loading and Validation

Open the terminal (Windows users use PowerShell). Replace **${API\_KEY}** below with your key (obtain one from the [Quick Start Guide](https://docs.world3.ai/world3/how-to-guides/routerlink/quick-start-guide)).

* macOS, Linux,

```toml
export ROUTERLINK_API_KEY="${API_KEY}"
```

* Windows PowerShell:

```toml
$env:ROUTERLINK_API_KEY = "${API_KEY}"
```

Launch codex

```toml
codex
```

Select "Yes" to trust this folder.

<figure><img src="/files/vXyLk0aaoZEOK98OBUJJ" alt=""><figcaption></figcaption></figure>

Now you can use Codex.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.world3.ai/world3/how-to-guides/routerlink/tutorials/how-to-integrate-routerlink-in-codex-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
