← CookbookView source on GitHub ↗

pi coding agent + Nebius Token Factory

pi is a terminal coding agent with a built-in custom-provider configuration path. Nebius Token Factory works through pi's existing openai-completions API mode, so no provider adapter or extension is required.

This recipe uses OpenAI-compatible Chat Completions. It does not select pi's separate openai-responses mode.

Prerequisites

1. Install pi

npm install -g --ignore-scripts @earendil-works/pi-coding-agent

2. Configure the provider

Pi reads custom providers from ~/.pi/agent/models.json. On a fresh setup, copy models.example.json there. If the file already exists, merge the nebius-token-factory entry into its existing providers object instead of replacing the file.

mkdir -p ~/.pi/agent
cp models.example.json ~/.pi/agent/models.json

The important fields are:

The compatibility overrides keep the baseline request aligned with Token Factory's Chat Completions schema: use system rather than developer, send max_tokens rather than max_completion_tokens, and do not request OpenAI long-cache retention.

3. Set the API key

export NEBIUS_API_KEY=your_key_here

Keep the key in your shell or secret manager. Do not paste a working key into models.json or commit one to source control.

4. Select the model

Confirm pi loaded the custom entry:

pi --list-models "GLM-5.1"

Then start pi in the project you want it to work on:

pi --provider nebius-token-factory --model zai-org/GLM-5.1

You can also select the model from /model in an interactive pi session.

The sample keeps pi's extended-thinking controls off and declares text input only. That is the conservative coding-agent baseline validated by this recipe. Tool calling remains available because pi's normal coding tools use the Chat Completions tools field. Enable model-specific reasoning controls or image input only after validating the exact current model and route.

Validate the sample offline

The included test checks the provider schema, canonical URL, environment-key reference, current model entry, compatibility overrides, and absence of Responses mode without making an API request:

cd integrations/pi
python3 -m unittest -v test_recipe.py

Troubleshooting

Resources