Pi API setup: configuration and troubleshooting
Pi is an open-source terminal coding agent with a small core that grows through extensions. Custom endpoints go in `models.json`; no extension is needed.
Updated:
Set up FlyRouter
Set the API key
Terminal
export FLYROUTER_API_KEY="sk-..."Add a provider
Edit ~/.pi/agent/models.json, creating it if it does not exist:
~/.pi/agent/models.json
{
"$schema": "https://pi.dev/schemas/models.schema.json",
"providers": {
"flyrouter": {
"baseUrl": "https://api.flyrouter.ai/v1",
"api": "openai-completions",
"apiKey": "$FLYROUTER_API_KEY",
"models": [
{ "id": "claude-sonnet-5-5", "name": "Claude Sonnet 5.5", "input": ["text", "image"] },
{ "id": "gpt-6.1-sol", "name": "GPT-6.1 Sol", "input": ["text", "image"] }
]
}
}
}An apiKey written as $NAME is read from the environment; a literal key also works. The id in models is the model ID sent to the API.
Choose a model
Type /model in Pi and pick a FlyRouter model. The file is re-read every time /model opens, so no restart is needed after an edit.
Model parameters
Without them, Pi assumes a 128,000-token context window and 16,384 output tokens. If a model's real limits differ, add contextWindow and maxTokens to its entry, and "reasoning": true for models that support thinking.
Troubleshooting
- 404:
baseUrlmust include/v1. - 401: the environment variable is not set, or the name in
apiKeyis wrong. - Cost shows $0.00: Pi estimates cost from the
costblock inmodels.jsonand shows 0 without one. The FlyRouter console usage records are what you are actually charged.