Coding agents
Set up Pi with Router
Add Router to Pi as a custom provider in models.json. Nothing to install and no installer to run.
Pi can use any provider that speaks the OpenAI Responses API, so all you have to do is add Router as a provider in your models.json. This page shows how to do that by hand. We also offer automated setup using the Router installer, which makes the same changes.
Requirements: Pi and a Router API key from the API keys page.
The installer offers a richer experience: the Router installer adds an extension to Pi that refreshes the model list automatically as Router adds models, fills in each model's limits, pricing, and thinking levels, and shows a status line with the model that served your last prompt and your savings. With manual setup, you add and update models yourself.
Open API keys, create a key, and copy it. The secret is shown only once. Add it to your shell profile (for example ~/.zshrc) so Pi can read it:
export RAMP_ROUTER_API_KEY="your-router-key"Pi reads custom providers from ~/.pi/agent/models.json, or from the directory named by PI_CODING_AGENT_DIR if you have set it. Create the file if it doesn't exist, or add the ramp-router entry to the providers object of your existing one.
{
"providers": {
"ramp-router": {
"name": "Ramp Router",
"baseUrl": "https://api.router.com/v1",
"api": "openai-responses",
"apiKey": "$RAMP_ROUTER_API_KEY",
"models": [
{
"id": "gpt-5.6-sol",
"name": "GPT 5.6 Sol",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1000000,
"maxTokens": 128000
}
]
}
}
}Here is what the entry does:
Setting | What it does |
|---|---|
baseUrl | Router's address. Keep /v1 at the end. |
api | openai-responses makes Pi call the Responses API, which is what Router serves. |
apiKey | $RAMP_ROUTER_API_KEY makes Pi read your key from the environment, so it never sits in the file. |
models | The models that appear in Pi's picker. You list each one you want. |
contextWindow and maxTokens tell Pi how much a model can read and write, and reasoning turns on thinking levels. Take these from GET /v1/models, which reports each model's limits and capabilities.
You choose which models Pi offers, so add an entry under models for each one you want. List the models your key can use:
curl https://api.router.com/v1/models \
-H "Authorization: Bearer $RAMP_ROUTER_API_KEY"To generate the whole list instead of typing it, this jq command prints a complete models.json with every model your key can use through the Responses API. It prints to the terminal, so merge the ramp-router entry into your own file, or redirect it to ~/.pi/agent/models.json if you don't have one yet:
curl -fsS https://api.router.com/v1/models \
-H "Authorization: Bearer $RAMP_ROUTER_API_KEY" | jq '
{
providers: {
"ramp-router": {
name: "Ramp Router",
baseUrl: "https://api.router.com/v1",
api: "openai-responses",
apiKey: "$RAMP_ROUTER_API_KEY",
models: [
.data[]
| select(.router.surfaces | index("responses"))
| {
id,
name: .display_name,
reasoning: .router.capabilities.reasoning.supported,
input: [.router.capabilities.modalities.input[] | select(. == "text" or . == "image")],
contextWindow: .router.limits.context_window,
maxTokens: .router.limits.max_output_tokens
}
| with_entries(select(.value != null))
]
}
}
}'Router adds models over time, so run the command again to refresh the list.
Start Pi and run /model to pick a Router model, or press Ctrl+S on a model to make it the default for new sessions. To check the setup first:
pi --list-models ramp-routerYou can also name the model when you start Pi:
pi --provider ramp-router --model gpt-5.6-solRouter serves Claude models over the Responses API like any other model, so the provider above is enough. The Messages API gives more precise control over caching for Claude models, so you may prefer to have Pi talk to them through its Anthropic adapter. To do that, add a second provider that uses Router's Messages endpoint. Note that the base URL has no /v1, because Pi's Anthropic adapter adds the path itself:
"ramp-router-claude": {
"name": "Ramp Router (Claude)",
"baseUrl": "https://api.router.com",
"api": "anthropic-messages",
"apiKey": "$RAMP_ROUTER_API_KEY",
"models": [{ "id": "claude-opus-5-5", "reasoning": true }]
}Remove the ramp-router entries from models.json. Pi then goes back to your other providers.
What you see | What to check |
|---|---|
Router models don't appear in /model | RAMP_ROUTER_API_KEY isn't set in the shell that started Pi, or models.json isn't valid JSON. Run pi --list-models ramp-router. |
401 | The key is wrong or was revoked. Check it on the API keys page. |
404 | baseUrl is missing /v1 (for the Responses provider), or the model isn't available for your key. |
If a failure persists, report it to the Router team with the x-request-id from the response. See Support and feedback.