pi
pi is a coding agent for the terminal. It can work with any provider, so Waibee connects through a single config file, with no extension to write.
Install pi (see its documentation):
npm install -g --ignore-scripts @earendil-works/pi-coding-agent1. API key
Section titled “1. API key”export WAIBEE_API_KEY="sk_live_..."2. Provider in models.json
Section titled “2. Provider in models.json”pi reads custom providers from ~/.pi/agent/models.json. Create the file if it does not exist. A minimal working config has the address, the protocol, the key, and at least one model ID:
{ "providers": { "waibee": { "baseUrl": "https://api.waibee.com", "api": "anthropic-messages", "apiKey": "$WAIBEE_API_KEY", "models": [ { "id": "anthropic/claude-sonnet-4.6" }, { "id": "waibee/auto" } ] } }}This is enough to start working. The other model fields are optional and affect what pi shows and allows: without them, it assumes a context window of 128,000 tokens, an output limit of 16,384, zero cost, and no reasoning or image input.
pi does not request a catalog for a custom provider, so the model list lives in the config. Take the IDs, context windows, and prices from GET /v1/models; see Models.
Generate the config from the catalog
Section titled “Generate the config from the catalog”To avoid copying models by hand, build the file from the catalog. The script converts prices from per token to per million, which is what pi expects:
curl -s https://api.waibee.com/v1/models \ -H "Authorization: Bearer $WAIBEE_API_KEY" -o /tmp/waibee-models.json
jq '{providers: {waibee: { baseUrl: "https://api.waibee.com", api: "anthropic-messages", apiKey: "$WAIBEE_API_KEY", models: [ .data[] | { id: .id, name: .name, reasoning: (((.capabilities.features // []) | index("reasoning")) != null), input: ([(.capabilities.modality_input // [])[] | select(. == "text" or . == "image")] | if length == 0 then ["text"] else . end), contextWindow: (.context_length // 128000), maxTokens: (.max_completion_tokens // 16384), cost: { input: ((.pricing.prompt // "0") | tonumber * 1000000), output: ((.pricing.completion // "0") | tonumber * 1000000), cacheRead: ((.pricing.input_cache_read // "0") | tonumber * 1000000), cacheWrite: ((.pricing.input_cache_write // "0") | tonumber * 1000000) } } ] } } }' \ /tmp/waibee-models.json > /tmp/waibee-provider.jsonOpen /tmp/waibee-provider.json and move the providers.waibee object into ~/.pi/agent/models.json, keeping the other providers and settings. If the file does not exist yet, create the ~/.pi/agent/ directory and copy the result there as models.json. When new models appear, you can run the generation again and update only providers.waibee.
Describe models by hand
Section titled “Describe models by hand”This works if you need a short list with exact parameters. The values below only show the shape: query the catalog yourself for context windows and prices instead of copying them from here.
{ "providers": { "waibee": { "name": "Waibee Router", "baseUrl": "https://api.waibee.com", "api": "anthropic-messages", "apiKey": "$WAIBEE_API_KEY", "models": [ { "id": "anthropic/claude-sonnet-4.6", "name": "Claude Sonnet 4.6", "reasoning": true, "input": ["text", "image"], "contextWindow": 1000000, "maxTokens": 128000, "cost": { "input": 3, "output": 15, "cacheRead": 0.3, "cacheWrite": 3.75 } } ] } }}api: "anthropic-messages" sends requests to POST /v1/messages, so baseUrl goes without /v1: the client adds the path itself. A model being in the catalog does not guarantee that it supports Messages.
3. Run
Section titled “3. Run”pi --list-models | grep waibee # check that the provider was picked uppi --provider waibee --model anthropic/claude-sonnet-4.6In interactive mode, switch models with the /model command. To avoid passing the flags every time, set defaults:
{ "defaultProvider": "waibee", "defaultModel": "anthropic/claude-sonnet-4.6" }A one-off run with no interface:
pi -p --provider waibee --model anthropic/claude-sonnet-4.6 "which endpoints are declared in this repository?"Config fields
Section titled “Config fields”| Field | Value |
|---|---|
baseUrl | https://api.waibee.com for anthropic-messages, https://api.waibee.com/v1 for openai-completions |
api | Protocol: anthropic-messages or openai-completions |
apiKey | "$WAIBEE_API_KEY" reads the environment variable, !command runs a command that returns the key, and a plain string is used as the key |
models[].id | Required. An ID from the catalog, strictly <provider>/<model> |
models[].cost | Prices per million tokens. The field is optional, but if it is present, all four keys are required: input, output, cacheRead, cacheWrite |
models[].reasoning | true enables the --thinking levels for the model. Without it, only off is available |
models[].input | ["text"] or ["text", "image"] |
models[].contextWindow, models[].maxTokens | Context window and output limit |
To look up IDs, context windows, and prices quickly:
curl -s https://api.waibee.com/v1/models \ -H "Authorization: Bearer $WAIBEE_API_KEY" | jq -r '.data[] | "\(.id)\t\(.context_length)\t\(.pricing.prompt)"'Catalog prices are per token, and pi expects them per million: multiply by 1,000,000. See Tokens and usage.
Using the OpenAI-compatible endpoint
Section titled “Using the OpenAI-compatible endpoint”If you prefer Chat Completions, define the same provider like this:
{ "providers": { "waibee-openai": { "baseUrl": "https://api.waibee.com/v1", "api": "openai-completions", "apiKey": "$WAIBEE_API_KEY", "models": [ { "id": "anthropic/claude-haiku-4.5" } ] } }}One file can hold several providers, and they do not interfere with each other.
Both options work. anthropic-messages is preferable: prompt caching for Claude models works natively on it.
Reasoning level
Section titled “Reasoning level”pi --provider waibee --model anthropic/claude-sonnet-4.6 --thinking highThe values are off, minimal, low, medium, high, xhigh, and max. pi sends xhigh and max only to models that have a thinkingLevelMap in models.json. Without it, pi lowers the level to one the model supports. Details: Reasoning.
Troubleshooting
Section titled “Troubleshooting”The provider is missing from --list-models, and --provider waibee returns Unknown provider.
The file failed schema validation, and pi dropped every provider in it. pi names the reason: in interactive mode with a models.json error message, and in the --list-models output with the warning Warning: errors loading models.json. A common cause is an incomplete cost: all four keys are required, even when they are zero.
401 unauthorized.
WAIBEE_API_KEY is not exported in the same shell where pi runs. Without the key, pi does not show the provider’s models in /model either. Check that the variable is set without printing the key itself: test -n "$WAIBEE_API_KEY" && echo "key is set".
422 validation_error or 404 model_not_found.
models[].id has a name without the provider. On openai-completions, the router rejects such a name with 422. On anthropic-messages, it treats the name as an Anthropic model, and models from other families return 404. Use the full ID from the catalog, for example anthropic/claude-sonnet-4.6.
The cost in the interface looks implausible.
pi calculates it from the cost block in your config, not from the router’s data. Update the numbers from the catalog.