# Model Provider Deep-Link Import Protocol (OPIP v1)

> Canonical HTML: https://octoterm.si/docs/protocols/provider-import (ZH) · https://octoterm.si/en/docs/protocols/provider-import (EN)
> LLMs index: https://octoterm.si/docs/llms.txt

**TL;DR:** OPIP v1 (`octopus://provider/import?v=1&...`) is an open URL-scheme standard that lets web dashboards (such as New API, One-API, and internal AI gateways) launch Octopus Desktop and prefill managed model providers (Anthropic, OpenAI Responses, OpenAI Chat, Gemini) with one click. Keys go exclusively to the OS keychain after user confirmation.

## 1. Canonical URI & Versioning

```text
octopus://provider/import?v=1&<parameters>
```

- Scheme/Host/Path: `octopus://provider/import` (case-insensitive).
- Version: `v=1` (alias `version`), defaults to `1`. Unsupported higher major versions are rejected cleanly.
- Manual paste fallback: Octopus Desktop → **Settings → Model Providers → Import Link** accepts both `octopus://provider/import?...` URIs and raw OPIP v1 JSON.

## 2. Mode A — Flat Query Parameters

```text
octopus://provider/import?v=1&baseUrl=https%3A%2F%2Fapi.example.com&apiKey=sk-xxxx&name=MyRelay&protocol=anthropic
```

| Parameter | Aliases | Required | Description |
|---|---|---|---|
| `baseUrl` | `endpoint`, `url`, `host`, `apiHost` | Yes* | Upstream gateway URL (`https://` or `http://`). Optional only for `geminiOfficialKey`. Tolerates unencoded `{address}`. |
| `apiKey` | `key`, `token` | No | Secret API key. Preserves `+` literally. Omit for secret-free team sharing. |
| `name` | `title`, `provider` | No | Display name; defaults to `baseUrl` host. |
| `protocol` | `protocols`, `apiFormat`, `type` | No | Single value, CSV list, `all`, or `auto` (default multi-protocol fan-out). |
| `models` | `model` | No | Comma-separated model IDs. |
| `opus` / `sonnet` / `haiku` | `flagshipModel`, `balancedModel`, `fastModel` | No | Anthropic tier slot mappings for Claude Code. |
| `authEnv` | `authType` | No | `ANTHROPIC_AUTH_TOKEN` (default) or `ANTHROPIC_API_KEY`. |
| `preset` | `template` | No | Built-in Octopus preset ID to merge default models. |
| `pin` | `pinAgents` | No | CSV of agent IDs to pin in the workspace `+` launcher. |
| `externalId` | `id` | No | Stable external ID for conflict matching / key rotation. |
| `source` | `from` | No | Origin tag (e.g. `new-api`) displayed in the confirmation modal. |
| `docsUrl` | `homepage` | No | `https://` dashboard or docs URL. |
| `isolate` / `tunnel` / `autoModeServer` | `isolateConfigDir`, `allowRemoteTunnel`, `enableAutoModeServer` | No | Boolean flags (`1`/`true`/`0`/`false`). |

## 3. Protocol Tokens & Multi-Protocol Fan-Out

- `anthropic` (aliases: `claude`, `anthropic-messages`) → Claude Code, OpenCode, Aider, Goose
- `openaiResponses` (aliases: `openai-responses`, `responses`, `codex`) → Codex CLI, OpenCode
- `openaiChat` (aliases: `openai-chat`, `openai`, `chat`) → OpenCode, Codex (Chat), Qwen, Aider, Goose
- `gemini` (aliases: `gemini-native`, `google`) → Gemini CLI, OpenCode
- `geminiOfficialKey` (aliases: `gemini-official`, `aistudio`) → Gemini CLI, Antigravity CLI (`agy`)

When `protocol` is omitted or `auto`, Octopus shows all four custom-gateway endpoints sharing one API key and pre-selects `anthropic` + `openaiResponses` (unless a path hint like `/anthropic` narrows the default).

## 4. BaseUrl Protocol Normalization (Multi-Protocol Fan-Out)

| Input `baseUrl` | Anthropic | OpenAI Responses / Chat | Gemini |
|---|---|---|---|
| `https://relay.example.com` | `https://relay.example.com` | `https://relay.example.com/v1` | `https://relay.example.com` |
| `https://relay.example.com/v1` | `https://relay.example.com` | `https://relay.example.com/v1` | `https://relay.example.com` |
| `https://api.deepseek.com/anthropic` | `https://api.deepseek.com/anthropic` | `https://api.deepseek.com/anthropic` | `https://api.deepseek.com/anthropic` |

## 5. Mode B — Structured `data` Payload (`Base64Url JSON` or `GZip + Base64Url JSON`)

```text
octopus://provider/import?v=1&data=<base64url>
```

- Auto-detects GZip magic bytes (`0x1F 0x8B`) with a 64 KiB decompressed safety limit; plain UTF-8 Base64Url JSON works with zero dependencies.
- Also accepts `?cherry=<base64>` for Cherry Studio `{cherryConfig}` compatibility.
- Top-level query `apiKey` / `baseUrl` / `name` / `source` act as fallbacks for fields omitted inside `data`.

```json
{
  "version": 1,
  "source": "new-api",
  "homepage": "https://relay.example.com",
  "providers": [
    {
      "externalId": "newapi:relay.example.com:anthropic",
      "name": "MyRelay (Claude)",
      "protocol": "anthropic",
      "baseUrl": "https://relay.example.com",
      "apiKey": "sk-xxxxxxxx",
      "authEnv": "ANTHROPIC_AUTH_TOKEN",
      "headers": { "X-Workspace": "team-a" },
      "isolateConfigDir": true,
      "allowRemoteTunnel": true,
      "enableAutoModeServer": false,
      "models": [
        {
          "id": "claude-sonnet-4-6",
          "displayName": "Claude Sonnet 4.6",
          "enabled": true,
          "tier": "balanced",
          "efforts": ["low", "medium", "high"],
          "contextWindow": 200000
        }
      ],
      "pinAgents": ["claude"]
    }
  ]
}
```

## 6. Security Contract & Hard Limits

- Always requires explicit user confirmation in Octopus Desktop; never silently writes, overwrites existing providers, or modifies default agent bindings.
- Always displays verified target hostname prominently and shows a danger banner on non-loopback plaintext `http://`.
- Never sends outbound HTTP requests when opening the dialog (prevents SSRF).
- Rejects `file://`, `javascript:`, userinfo URLs (`user:pass@`), control characters, and forbidden headers (`Host`, `Connection`, `Transfer-Encoding`, etc.).
- Hard limits: URI ≤ 32 KiB · Decompressed JSON ≤ 64 KiB · Max 10 providers · Max 200 models/provider · Max 16 headers.

## 7. Frequently Asked Questions

**Q: Does clicking an OPIP v1 link overwrite my existing Octopus providers?**
A: No. Conflict matching defaults to creating a new copy; updating an existing provider requires explicit user opt-in, and built-in CoWork providers cannot be modified via deep links.

**Q: Are API keys ever written to `providers.json` or log files?**
A: No. Startup traces and IPC logs redact every `octopus://` query/fragment automatically, and saved keys are stored exclusively in the OS keychain (`ISecretStore`).

**Q: What if the user has not installed Octopus yet?**
A: Link to the zero-leak bridge `https://octoterm.si/import/provider#v=1&baseUrl=...&apiKey=...`. The `#fragment` stays strictly in the user's browser and never hits `octoterm.si`, while guiding users to download Octopus or copy the deep link.
