跳到正文

Pi Coding Agent Integration ​

Pi Coding Agent supports two ways to connect to 开桥:

MethodExtension requiredBest for
Standard API key configurationNoUsers who already have a 开桥 API key and want to configure specific models manually
OAuth PKCE@openqiao/pi-openqiao-oauthUsers 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:

bash
npm install -g @earendil-works/pi-coding-agent

Verify the installation:

bash
pi --version

Migrating 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:

bash
npm uninstall -g @mariozechner/pi-coding-agent
npm install -g @earendil-works/pi-coding-agent

Configure 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:

bash
export OPENQIAO_API_KEY="sk-ai-v1-xxx"

Then add a openqiao provider to ~/.pi/agent/models.json:

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:

bash
pi --provider openqiao --model deepseek-v4-flash

apiKey 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:

bash
pi install npm:@openqiao/pi-openqiao-oauth

Start Pi and sign in:

text
/login openqiao

Approve 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:invoke and offline_access scopes.

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 ​

CapabilityStandard API keyOAuth PKCE
AuthenticationOPENQIAO_API_KEYBrowser authorization
Extra extensionNot required@openqiao/pi-openqiao-oauth
Model setupAdd model IDs to models.jsonDiscover models automatically
Protocol selectionDefined by api in models.jsonSelected per model from the 开桥 catalog
Credential lifecycleManaged by the userAccess-token refresh and rotation handled automatically

Troubleshooting ​

The 开桥 model does not appear ​

For standard API key configuration, confirm that:

  • ~/.pi/agent/models.json is valid JSON.
  • The provider contains baseUrl, api, and at least one model ID.
  • OPENQIAO_API_KEY is available in the same terminal that starts Pi.

Check the loaded model directly:

bash
pi --list-models openqiao

For OAuth, confirm that the extension is installed:

bash
pi list

If necessary, update it and sign in again:

bash
pi update npm:@openqiao/pi-openqiao-oauth

The 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_KEY is current and was exported before Pi started.
  • OAuth: run /login openqiao again. 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.