Pi Coding Agent Integration
Pi Coding Agent supports two ways to connect to 开桥:
| Method | Extension required | Best for |
|---|---|---|
| Standard API key configuration | No | Users who already have a 开桥 API key and want to configure specific models manually |
| OAuth PKCE | @openqiao/pi-openqiao-oauth | Users who prefer browser sign-in, automatic token refresh, and dynamic model discovery |
Install Pi Coding Agent
Pi now uses the official @earendil-works/pi-coding-agent package and requires Node.js 22.19.0 or later:
npm install -g @earendil-works/pi-coding-agentVerify the installation:
pi --versionMigrating from the old package
The former @mariozechner/pi-coding-agent package is deprecated. If it is still installed, uninstall it before installing the current package:
npm uninstall -g @mariozechner/pi-coding-agent
npm install -g @earendil-works/pi-coding-agentConfigure a standard API key
This method uses Pi's native custom-provider support and does not install the 开桥 OAuth extension.
First, set your 开桥 API key:
export OPENQIAO_API_KEY="sk-ai-v1-xxx"Then add a openqiao provider to ~/.pi/agent/models.json:
{
"providers": {
"openqiao": {
"baseUrl": "https://openqiao.com/api/v1",
"api": "openai-completions",
"apiKey": "$OPENQIAO_API_KEY",
"models": [
{
"id": "deepseek-v4-flash",
"name": "DeepSeek V4 Flash"
}
]
}
}
}If models.json already contains other providers, merge the openqiao entry into the existing providers object instead of replacing the file. Add more entries to models when you want to use other 开桥 model IDs.
Start Pi, run /model, and select openqiao/deepseek-v4-flash. You can also select it at startup:
pi --provider openqiao --model deepseek-v4-flashapiKey contains an environment-variable reference, not the API key itself. For persistent use, add the export command to the startup file for your active shell, such as ~/.zshrc or ~/.bashrc, and then open a new terminal.
Why models must be listed here
Pi's standard custom-provider configuration does not automatically import the 开桥 model catalog. Each model used through this method must be present in models.json. Use the OAuth method below if you want Pi to discover the current catalog automatically.
Use OAuth PKCE
The official @openqiao/pi-openqiao-oauth extension opens 开桥 in your browser for authorization. It does not require a 开桥 API key and refreshes OAuth tokens automatically.
Install the extension with Pi:
pi install npm:@openqiao/pi-openqiao-oauthStart Pi and sign in:
/login openqiaoApprove the request in the browser. After the callback page confirms the connection, return to Pi, run /model, and select a 开桥 model.
The extension:
- Discovers the current 开桥 model catalog and caches the last valid catalog at
~/.pi/agent/models-store.json. - Selects Anthropic Messages, OpenAI Responses, or Chat Completions for each model according to the protocols advertised by 开桥.
- Stores access and refresh tokens in Pi's provider credential store and saves rotated refresh tokens.
- Requests only
inference:invokeandoffline_accessscopes.
To sign out, run /logout in Pi and select 开桥. You can also revoke the authorization from 开桥 Authorized Apps.
For details about the authorization flow and credential security, see OAuth PKCE Integration Guide.
Choose between the two methods
| Capability | Standard API key | OAuth PKCE |
|---|---|---|
| Authentication | OPENQIAO_API_KEY | Browser authorization |
| Extra extension | Not required | @openqiao/pi-openqiao-oauth |
| Model setup | Add model IDs to models.json | Discover models automatically |
| Protocol selection | Defined by api in models.json | Selected per model from the 开桥 catalog |
| Credential lifecycle | Managed by the user | Access-token refresh and rotation handled automatically |
Troubleshooting
The 开桥 model does not appear
For standard API key configuration, confirm that:
~/.pi/agent/models.jsonis valid JSON.- The provider contains
baseUrl,api, and at least one model ID. OPENQIAO_API_KEYis available in the same terminal that starts Pi.
Check the loaded model directly:
pi --list-models openqiaoFor OAuth, confirm that the extension is installed:
pi listIf necessary, update it and sign in again:
pi update npm:@openqiao/pi-openqiao-oauthThe browser opens but authorization does not finish
The OAuth callback uses a temporary port on 127.0.0.1. The browser and Pi must reach the same machine's loopback address. Remote servers, containers, SSH sessions, and browser proxies may require port forwarding or a local Pi session.
Requests return 401
- Standard API key: verify that
OPENQIAO_API_KEYis current and was exported before Pi started. - OAuth: run
/login openqiaoagain. If the problem remains, revoke the old grant from 开桥 Authorized Apps and authorize again.
Never paste an API key or OAuth token into prompts, project files, logs, or screenshots.