Set up Pi with Divyam
Use Pi for coding while sending its model requests through the demo Divyam endpoint. Pi reads files and runs tools locally. Divyam receives the model requests and returns model responses.
You need access to your email and a terminal with Node.js and npm. The steps below cover Divyam signup, API key creation, Pi configuration, and request verification.
This method uses Pi’s configuration file. For a menu-driven alternative, use the Provider Hub guide. You only need one setup method.
1 Sign up or sign in to Divyam
- Open the Divyam demo console.
- Choose signup for a new account, or sign in if you already have one.
- Enter your email and complete verification using the code sent to your inbox.
- Open Getting Started after signing in.
- Check the available credit in Credits & Billing.
If access is restricted, contact the demo administrator with your email address. Keep this console open. You will return to it to check requests sent by Pi.
2 Create a key and copy connection settings
- Open API Keys in the left navigation.
- Create a key with a recognizable name, such as
pi-demo. - Copy the complete key when it appears and store it privately. It is shown once.
- Open Getting Started and copy the API base URL from the example request.
- Open Models & Pricing and copy an available model ID exactly.
| Setting | Value used in this guide |
|---|---|
| API base URL | https://api.demo.divyam.ai/v1 |
| Model ID | divyam-as/gpt-5.6-sol |
| API key | Your complete Divyam key, beginning with divyam-sw-v1- |
Use the values shown in your own console if they differ. Keep the full URL path and model prefix. Use the API key for Pi. The email verification code and browser session token are separate credentials. If you lose the key, create a replacement in API Keys.
Choose the Pi version
Use the latest stable Pi release from pi.dev.
Its npm package is @earendil-works/pi-coding-agent. Run the tool check below after installation or an upgrade.
3 Install Pi
Pi currently requires Node.js 22.19 or newer. Check your Node.js version:
node --version
Install the latest stable package and check the installed version:
npm install --global --ignore-scripts @earendil-works/pi-coding-agent
pi --version
Pi uses fd to find files and ripgrep to search their contents while working on your code.
Pi normally downloads missing search utilities automatically, so a separate installation is optional.
If an automatic download fails, you can install them yourself. On macOS with Homebrew:
brew install fd ripgrep
On other systems, use the system package manager. The executable names are fd and rg.
Sources: official installation and current package requirements.
4 Create a separate Divyam profile
Use a separate configuration directory to keep this connection independent of your normal Pi profile. Run the following in Bash:
export PI_CODING_AGENT_DIR="$HOME/.pi-divyam-switch/agent"
mkdir -p "$PI_CODING_AGENT_DIR"
chmod 700 "$PI_CODING_AGENT_DIR"
Run the commands below in Bash. At the prompt, paste the key you created in step 2 and press Enter. The key stays hidden while you enter it:
read -rsp 'Divyam API key: ' DIVYAM_API_KEY
printf '\n'
export DIVYAM_API_KEY
read sets DIVYAM_API_KEY. export makes it available to Pi launched from this terminal.
Keep using this terminal for the remaining commands. A new terminal needs the key entered again.
Create $PI_CODING_AGENT_DIR/models.json with this content:
{
"providers": {
"divyam-switch": {
"baseUrl": "https://api.demo.divyam.ai/v1",
"api": "openai-completions",
"apiKey": "$DIVYAM_API_KEY",
"models": [
{
"id": "divyam-as/gpt-5.6-sol",
"name": "Divyam demo",
"reasoning": false,
"input": ["text"],
"contextWindow": 128000,
"maxTokens": 4096
}
]
}
}
}
Copy your own console’s base URL into baseUrl. Replace the example model if your catalog differs.
Keep the full model prefix: divyam-as/gpt-5.6-sol differs from the Router’s backing name gpt-5.6-sol.
openai-completions is Pi’s name for Chat Completions, including /chat/completions.
The key comes from the launching shell. Do not replace it with a Router service-account key or provider credential.
This starter profile uses text input and does not request reasoning controls from Pi.
Reasoning settings are not verified for this demo route. --thinking off does not guarantee the backing model performs no reasoning.
The context and output numbers are conservative local settings, rather than declarations of every routed model’s capacity.
Pi’s default custom-model cost estimates do not establish Divyam charges. Read billing in the Divyam console.
No Pi extension or local proxy is required for this connection pattern. The current model documentation describes custom endpoints and environment-backed keys.
5 Check model discovery
In the same terminal, run:
pi --list-models divyam-switch
Confirm that the configured model appears under divyam-switch.
This checks configuration loading. It does not make a successful model request.
If no model appears, check the file’s JSON, configuration directory, and whether DIVYAM_API_KEY is set in this terminal.
Source: Pi environment variables.
6 Verify a real tool exchange
Use a disposable workspace for the first check:
mkdir -p "$HOME/w/divyam-switch-pi-demo"
cd "$HOME/w/divyam-switch-pi-demo"
printf '%s\n' 'switch-pi-check-4827' > acceptance.txt
Run a task that can read files, with extensions and project context disabled:
pi \
--no-extensions --no-skills --no-prompt-templates --no-context-files \
--no-session --tools read \
--provider divyam-switch --model divyam-as/gpt-5.6-sol \
--thinking off --print \
'Read acceptance.txt using the read tool. Return only its exact content. Do not modify files.'
The final answer should be switch-pi-check-4827.
The test file and marker above are deliberately created examples. Note when you ran the command.
Check the tool exchange in Divyam Logs
- Return to the Divyam demo console. Sign in again if your session has expired.
- Select Logs in the left navigation.
- Set Model to the model used by Pi, such as
divyam-as/gpt-5.6-sol. - Set Period to include the test time. Leave Status at All statuses to include failures.
- Find the requests near the time you ran the command. Logs lists the newest request first.
- Check their outcome, token counts, and latency. A successful request should show HTTP status 200.
- Open View request on the later request containing the continuation.
- In
messages, find an assistant message with atool_callsentry asking to readacceptance.txt. - Find the following message with
roleset totool. Itstool_call_idshould match the assistant tool call. - Confirm that the tool result contains the marker you wrote into
acceptance.txt. Compare Pi’s terminal answer with that marker.
Pi can make additional requests. Follow the matching tool-call ID rather than assuming two adjacent rows form the exchange. The inspected demo displays request times in UTC. Compare them with your local test time using that timezone. If no matching requests appear, check the account and filters, then refresh after the records arrive.
Pi streams its responses. The console may show Streamed; not stored instead of a View response button. The continuation request includes both the earlier assistant tool call and the submitted result, so use View request for verification.
If request content is unavailable, metadata alone cannot confirm the tool call or submitted result. Use Pi tool events or ask the demo administrator to inspect the exchange. An answer alone is insufficient evidence of tool execution.
7 Start a coding session
After the read check passes, start an interactive session in the same disposable workspace:
pi --provider divyam-switch --model divyam-as/gpt-5.6-sol --thinking off
Try these tasks sequentially:
- Ask Pi to create a small text file with content you specify. Inspect the file.
- Ask Pi to change one line. Inspect the resulting difference.
- Ask Pi to read the file and explain its contents.
- Once the session has enough history, run
/compact, then request another small edit and verify it. If Pi reports that the session is too small, skip this check until the conversation is longer. - Type
/quitin Pi and press Enter. This returns you to the terminal. From the same directory, run the command below to resume the session.
pi --continue --provider divyam-switch --model divyam-as/gpt-5.6-sol --thinking off
Re-export PI_CODING_AGENT_DIR and enter the key again when opening a new terminal.
The initial --no-session check saves no session; the interactive session is the one you can resume.
Keep the first editable workflow in this disposable workspace. Pi’s tool permissions belong to Pi’s local environment. A Divyam key does not limit which local files Pi can edit.
Optional features to verify
| Feature | How to enable or check it |
|---|---|
| Another model | Add its exact Divyam catalog ID to models, then use /model. Repeat the tool check. |
| Reasoning settings | Not verified for this demo route. This guide does not enable Pi reasoning controls. |
| Image input | Confirm image support through the deployed route. Add image to input, then test an attachment separately. |
| Local files | Pi reads files through local tools and sends relevant content in model requests. |
| Web search | Configure an appropriate Pi tool or extension. Basic Divyam Chat Completions setup does not supply a search tool. |
| Session continuation | Resume a saved session and verify another tool exchange. Local history does not itself prove server-side session attribution. |
Do not enable compatibility flags based solely on an OpenAI-compatible label. Use a flag only when the actual endpoint needs it.
Optional session attribution
Pi saves its session locally. To correlate a demo session with Divyam records, create your own session label before launch:
export DIVYAM_SESSION_ID="$(python3 -c 'import uuid; print(uuid.uuid4())')"
Add this headers object alongside apiKey in the provider configuration:
{
"headers": {
"x-session-id": "$DIVYAM_SESSION_ID",
"x-flow-id": "pi-demo"
}
}
Generate a fresh label for each new conversation. Retain the same label when continuing that conversation.
This is manual correlation, rather than automatic synchronization with Pi’s session ID.
Do not set one fixed x-eval-request-id for an entire conversation; it identifies a single turn’s calls.
Divyam forwards the supported attribution headers in the inspected source. The older direct-Router guide’s traffic-allocation override header is not part of this Divyam setup. Header acceptance does not guarantee that every field is visible in the console.
Troubleshooting and cleanup
| Symptom | Action |
|---|---|
pi command missing |
Check installation and the npm executable directory on PATH. |
Missing fd or rg |
Let Pi download the utilities, or install them through your system package manager if the download fails. |
| Configured model missing | Check models.json, the profile directory, and the key environment variable. |
| HTTP 401 or authentication failure | Check the complete Divyam key and whether it remains active. |
| Model not found | Use the exact Divyam catalog ID, including divyam-as/. |
| HTTP 402 | Open Credits & Billing and resolve the credit or billing restriction before retrying. |
| HTTP 403 | Check account access and whether the plan includes the requested model. |
| HTTP 429 | Reduce request volume and retry after the reported delay. |
| HTTP 502 or 503 | Retry later. Report the test time, model ID, request ID if available, and redacted error. |
| No matching log entry | Check the signed-in account, model filter, and period. Refresh after ingestion. |
| Prose appears without a tool call | Inspect the model response and tool declaration. Repeat the read check before attempting coding. |
| A continuation or stream fails | Report Pi version, model ID, request times, and redacted errors. Ask the operator to inspect endpoint tool support. |
| Pi returns a Divyam stub response | The deployment needs real inference enabled before tool workflows can pass. |
| Resume selects a different provider | Check the profile directory and launch with explicit provider and model arguments. |
When finished, exit Pi, unset DIVYAM_API_KEY, and revoke the dedicated demo key if it is no longer needed.
Unsetting a key does not revoke it.