> For the complete documentation index, see [llms.txt](https://docs.cortecs.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cortecs.ai/integration-examples/coding/pi.md).

# Pi

[Pi](https://pi.dev/) is a terminal-based coding agent that supports custom OpenAI-compatible providers. Cortecs can be added directly through Pi's model configuration.

{% hint style="info" %}
Before you begin, create a Cortecs API key by following the [Quickstart](/quickstart.md) and choose a tool-calling model from the [model catalog](https://cortecs.ai/serverlessModels).
{% endhint %}

## 1. Install Pi

Install Pi with Node.js and npm:

```bash
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
```

## 2. Add Cortecs

Create or update `~/.pi/agent/models.json`:

```json
{
  "providers": {
    "cortecs": {
      "baseUrl": "https://api.cortecs.ai/v1",
      "api": "openai-responses",
      "apiKey": "$CORTECS_API_KEY",
      "models": [
        { "id": "<MODEL_ID>" }
      ]
    }
  }
}
```

{% hint style="info" %}
The Cortecs [Responses API](https://docs.cortecs.ai/api-overview/responses-beta) is recommended for Pi's agent workflows. Change `api` to `openai-completions` only if a model or workflow requires Chat Completions.
{% endhint %}

Replace `<MODEL_ID>` with the exact ID from the model catalog. Add more entries to `models` if you want to use several models.

## 3. Start Pi

Set your API key and launch Pi:

```bash
export CORTECS_API_KEY="<API_KEY>"
pi
```

Run `/model` inside Pi and select the model listed under **cortecs**.

For additional model options, see Pi's [custom model documentation](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/models.md).
