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

# Use LithosAI with Pi

> Connect Pi directly to LithosAI through the OpenAI Chat Completions API.

## Before you begin

Create a key on the [API Keys](https://console.lithosai.cloud/keys) page, confirm the model ID
on the [Models](https://console.lithosai.cloud/models) page, and export the key in the shell where you start Pi.

```bash theme={null}
export LITHOSAI_API_KEY="your-key"
```

Pi reaches LithosAI directly through Chat Completions. Install Pi, then add a provider to
`~/.pi/agent/models.json`.

```bash theme={null}
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
```

```json ~/.pi/agent/models.json theme={null}
{
  "providers": {
    "lithosai": {
      "baseUrl": "https://api.lithosai.cloud/v1",
      "api": "openai-completions",
      "apiKey": "$LITHOSAI_API_KEY",
      "models": [
        {
          "id": "moonshotai/Kimi-K3",
          "name": "Kimi K3 on LithosAI"
        },
        {
          "id": "moonshotai/Kimi-K3-fast",
          "name": "Kimi K3 fast on LithosAI"
        }
      ]
    }
  }
}
```

Start Pi with a LithosAI model. You can also run `/model` inside Pi to switch between the
configured models.

```bash theme={null}
pi --provider lithosai --model moonshotai/Kimi-K3
```

Pi uses default context and output limits when they are omitted from `models.json`. Check the
[Models](https://console.lithosai.cloud/models) console page and add `contextWindow` and
`maxTokens` to each entry when you need Pi's context meter and compaction behavior to match the
selected model exactly.

<Note>
  This connection uses Pi's OpenAI Chat Completions implementation. Provider-specific reasoning
  controls require additional Pi compatibility settings and are not enabled by this minimal
  configuration.
</Note>

## Troubleshooting

| Symptom                                       | Cause                                                                                                                  |
| --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| The LithosAI models do not appear in `/model` | `LITHOSAI_API_KEY` is unset, or `apiKey` does not include the `$` environment-variable prefix.                         |
| The context meter is inaccurate               | Add the model's `contextWindow` and `maxTokens` values from the LithosAI console.                                      |
| `invalid 'parameters' schema`                 | An enabled tool or MCP server declares parameters that are not a JSON Schema object. Disable it or correct its schema. |

Issues common to every agent are listed under [Common issues](/coding-agents#common-issues).
