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

# Connect pi

> Set up the pi coding agent with the Fortytwo API: install pi, add Fortytwo to models.json, sign in with your API key and select qwen/qwen3.8-27b.

[pi ](https://pi.dev/) is a coding agent for the terminal.

> [!NOTE]
>
> **Before you start:** create a Fortytwo API key and buy credits — see [Quickstart, step 1](https://docs.fortytwo.network/docs/quickstart.md#1-create-an-api-key). Give each agent its own key with a **Spend limit**.
>
> | Setting | Value |
> | - | - |
> | Base URL | `https://api.fortytwo.network/v1` |
> | Model ID | `qwen/qwen3.8-27b` |

**1. Install pi**

On macOS or Linux:

```bash theme={null}
curl -fsSL https://pi.dev/install.sh | sh
```

On Windows, in PowerShell:

```powershell theme={null}
powershell -c "irm https://pi.dev/install.ps1 | iex"
```

The installer adds Node.js if it is missing.

**2. Add Fortytwo to models.json**

Create `~/.pi/agent/models.json` with this content:

> [!NOTE]
>
> `~` is your home folder. Folders that start with a dot, such as `.pi`, `.config` or `.codex`, are hidden. To show them: **Cmd+Shift+.** in Finder on macOS, **View** → **Show** → **Hidden items** in File Explorer on Windows, **Ctrl+H** in most Linux file managers.

```json ~/.pi/agent/models.json theme={null}
{
  "providers": {
    "fortytwo": {
      "name": "Fortytwo",
      "baseUrl": "https://api.fortytwo.network/v1",
      "api": "openai-completions",
      "models": [
        {
          "id": "qwen/qwen3.8-27b",
          "name": "Qwen3.8 27B",
          "reasoning": true,
          "input": ["text", "image"],
          "contextWindow": 262144,
          "maxTokens": 16384
        }
      ]
    }
  }
}
```

If the file already exists, add the `fortytwo` entry inside its `providers` object.

**3. Enter your API key**

1. Start pi in your project folder:

```bash theme={null}
pi
```

2. Type `/login`
3. Choose **Sign in with an API key**, then **Fortytwo**, and paste your key. pi saves it in `~/.pi/agent/auth.json`.

pi then reports that no default model is configured for `fortytwo`. The next step sets it.

![pi: Fortytwo in the provider list of /login](https://mintcdn.com/fortytwo-f43ac997/HbC5gKcbcuN88RH4/resources/illustrations/agents/pi-1.png?fit=max\&auto=format\&n=HbC5gKcbcuN88RH4\&q=85\&s=f7071aa623a0ce86809982d396b74f7e)

**4. Select the model**

1. Type `/model`, then `qwen3.8`, and choose `qwen/qwen3.8-27b [fortytwo]`.
2. Press **Ctrl+S** to make it the default for new sessions.

   ![pi: /model with qwen/qwen3.8-27b from the fortytwo provider](https://mintcdn.com/fortytwo-f43ac997/HbC5gKcbcuN88RH4/resources/illustrations/agents/pi-2.png?fit=max\&auto=format\&n=HbC5gKcbcuN88RH4\&q=85\&s=a4365f41a08b16353ba2e991e6f519b1)

**5. Set reasoning to medium**

pi starts with thinking **off** and sends no reasoning level. Set the level to **medium**, so every request asks for it:

1. Type `/thinking` and choose **medium**.
2. Press **Ctrl+S** to make it the default for new sessions.

   ![pi: Thinking Level list with medium selected](https://mintcdn.com/fortytwo-f43ac997/HbC5gKcbcuN88RH4/resources/illustrations/agents/pi-3.png?fit=max\&auto=format\&n=HbC5gKcbcuN88RH4\&q=85\&s=825f3b83b2802174844e4ec07a7aa0aa)

**6. Start a task**

Type a task and press **Enter**. The status line shows `qwen/qwen3.8-27b • medium`.

![pi: task running on qwen/qwen3.8-27b with thinking medium](https://mintcdn.com/fortytwo-f43ac997/HbC5gKcbcuN88RH4/resources/illustrations/agents/pi-4.png?fit=max\&auto=format\&n=HbC5gKcbcuN88RH4\&q=85\&s=b0bb10b5498274003c1a1817afec558b)

More options: [pi compatible endpoints ](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/models.md#configure-a-compatible-endpoint).

***

Something not working with your agent, or using one we have not listed? Tell us in the platform: [Feedback](https://docs.fortytwo.network/docs/support.md#ideas-feedback-and-small-bugs) for ideas and small bugs, [Contact support](https://docs.fortytwo.network/docs/support.md#support-account-api-billing-credits-errors) if it blocks your work, or [Report a security issue](https://docs.fortytwo.network/docs/support.md#security-issue).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.