@earendil-works/pi-coding-agent 0.87.0 → 0.87.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +25 -711
  3. package/dist/bundle/chunks/{anthropic-messages-MYU5ZMRF.js → anthropic-messages-J5WXPPPC.js} +1 -1
  4. package/dist/bundle/chunks/{chunk-GV2E3GBU.js → chunk-65HAU2C5.js} +1 -1
  5. package/dist/bundle/chunks/{chunk-4DKZACXI.js → chunk-OJP47DM6.js} +13 -13
  6. package/dist/bundle/chunks/github-copilot.js +1 -1
  7. package/dist/bundle/chunks/{openai-completions-XHML6MTL.js → openai-completions-OBX42CLD.js} +1 -1
  8. package/dist/bundle/chunks/{virtual-modules-BNWPZYDH.js → virtual-modules-VHMJYYWQ.js} +1 -1
  9. package/dist/bundle/cli-runtime.js +1 -1
  10. package/dist/bundle/index.js +1 -1
  11. package/dist/bundle/rpc-entry.js +1 -1
  12. package/dist/cli/args.d.ts.map +1 -1
  13. package/dist/cli/args.js +14 -4
  14. package/dist/cli/args.js.map +1 -1
  15. package/dist/core/compaction/compaction.d.ts.map +1 -1
  16. package/dist/core/compaction/compaction.js +9 -9
  17. package/dist/core/compaction/compaction.js.map +1 -1
  18. package/dist/core/model-resolver.d.ts.map +1 -1
  19. package/dist/core/model-resolver.js +1 -1
  20. package/dist/core/model-resolver.js.map +1 -1
  21. package/docs/cli-integration.md +106 -0
  22. package/docs/cli.md +268 -0
  23. package/docs/compaction.md +22 -22
  24. package/docs/configuration.md +45 -0
  25. package/docs/containerization.md +109 -82
  26. package/docs/custom-provider.md +132 -784
  27. package/docs/docs.json +139 -99
  28. package/docs/environment-variables.md +3 -5
  29. package/docs/extensions.md +134 -3020
  30. package/docs/how-pi-works.md +49 -0
  31. package/docs/images/interactive-mode.png +0 -0
  32. package/docs/index.md +24 -69
  33. package/docs/json.md +193 -65
  34. package/docs/keybindings.md +57 -102
  35. package/docs/llama-cpp.md +3 -3
  36. package/docs/message-types.md +261 -0
  37. package/docs/models.md +55 -565
  38. package/docs/packages.md +66 -167
  39. package/docs/prompt-templates.md +31 -68
  40. package/docs/providers.md +102 -240
  41. package/docs/quickstart.md +61 -106
  42. package/docs/rpc-commands.md +854 -0
  43. package/docs/rpc-extension-ui.md +200 -0
  44. package/docs/rpc.md +129 -1556
  45. package/docs/sdk.md +76 -1171
  46. package/docs/security.md +70 -32
  47. package/docs/session-format.md +10 -214
  48. package/docs/sessions.md +35 -141
  49. package/docs/settings.md +109 -387
  50. package/docs/shell-aliases.md +85 -5
  51. package/docs/skills.md +51 -190
  52. package/docs/slash-commands.md +60 -0
  53. package/docs/terminal-setup.md +105 -78
  54. package/docs/termux.md +74 -83
  55. package/docs/themes.md +68 -280
  56. package/docs/tmux.md +31 -39
  57. package/docs/tui.md +69 -923
  58. package/docs/usage.md +54 -272
  59. package/docs/windows.md +43 -17
  60. package/examples/README.md +13 -2
  61. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  62. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  63. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  64. package/examples/extensions/gondolin/package-lock.json +2 -2
  65. package/examples/extensions/gondolin/package.json +1 -1
  66. package/examples/extensions/sandbox/package-lock.json +2 -2
  67. package/examples/extensions/sandbox/package.json +1 -1
  68. package/examples/extensions/with-deps/package-lock.json +2 -2
  69. package/examples/extensions/with-deps/package.json +1 -1
  70. package/examples/rpc-client.ts +35 -0
  71. package/examples/rpc-extension-ui.ts +25 -5
  72. package/examples/sdk/README.md +1 -1
  73. package/npm-shrinkwrap.json +20 -20
  74. package/package.json +8 -8
  75. package/docs/development.md +0 -90
package/docs/providers.md CHANGED
@@ -1,325 +1,187 @@
1
- # Providers
1
+ # Provider Authentication
2
2
 
3
- Pi supports subscription-based providers via OAuth and API key providers via environment variables or auth file. Built-in catalogs ship with pi; configured providers may refresh newer catalogs and cache them in `~/.pi/agent/models-store.json` for offline use.
3
+ Most hosted providers support one or both of these authentication methods:
4
4
 
5
- ## Table of Contents
5
+ - Sign in through a browser or device flow backed by OAuth.
6
+ - Provide an API key.
6
7
 
7
- - [Subscriptions](#subscriptions)
8
- - [API Keys](#api-keys)
9
- - [Auth File](#auth-file)
10
- - [Cloud Providers](#cloud-providers)
11
- - [llama.cpp](#llamacpp)
12
- - [Custom Providers](#custom-providers)
13
- - [Resolution Order](#resolution-order)
8
+ Use `/login [provider]` to see the methods supported by a provider. Amazon Bedrock and Google Vertex AI can also use ambient cloud credentials.
14
9
 
15
- ## Subscriptions
10
+ ## Authenticate interactively
16
11
 
17
- Use `/login` in interactive mode, then select a provider:
12
+ Run `/login` and select a provider. Pi guides you through its OAuth or API-key flow and saves the resulting credential in [`auth.json`](configuration.md#agent-directory).
18
13
 
19
- - ChatGPT Plus/Pro (Codex)
20
- - Claude Pro/Max
21
- - GitHub Copilot
22
- - xAI (Grok/X subscription)
23
- - Meta (Muse subscription)
24
- - OpenRouter (OAuth-minted API key billed from OpenRouter credits)
25
- - Radius
14
+ On a remote or headless machine, an OAuth callback may not reach the local process. When prompted, paste the final redirect URL or authorization code back into Pi.
26
15
 
27
- Use `/logout` to clear credentials. Tokens are stored in `~/.pi/agent/auth.json` and auto-refresh when expired. OpenRouter instead mints a user-controlled API key that does not expire automatically.
16
+ Run `/logout` and select a provider to remove its stored credential. This does not unset environment variables, remove authentication from `models.json`, or revoke the credential at the provider.
28
17
 
29
- ### OpenAI Codex
18
+ `auth.json` can contain API keys and OAuth tokens. Keep it private and do not commit it.
30
19
 
31
- - Requires ChatGPT Plus or Pro subscription
32
- - Officially endorsed by OpenAI: [Codex for OSS](https://developers.openai.com/community/codex-for-oss)
20
+ Radius authentication uses its gateway catalog and caches refreshed model metadata for later offline startup. A custom Radius gateway configured in `models.json` uses its own catalog rather than inheriting the public `radius.pi.dev` catalog.
33
21
 
34
- ### Claude Pro/Max
22
+ ## Use an API key from the environment
35
23
 
36
- Anthropic subscription auth is active for Claude Pro/Max accounts. Third-party harness usage draws from [extra usage](https://claude.ai/settings/usage) and is billed per token, not against Claude plan limits.
37
-
38
- ### GitHub Copilot
39
-
40
- - Press Enter for github.com, or enter your GitHub Enterprise Server domain
41
- - If you get "model not supported", enable it in VS Code: Copilot Chat → model selector → select model → "Enable"
42
-
43
- ### xAI (Grok/X subscription)
44
-
45
- - Run `/login xai`, then select **Use a subscription**
46
- - `XAI_API_KEY` remains available through **Use an API key**
47
-
48
- ### Meta (Muse subscription)
49
-
50
- - Run `/login meta`, then select **Sign in with Meta** to open the device authorization flow
51
- - The login mints a Model API key that is re-minted automatically about once a day
52
- - `META_API_KEY` remains available through **Use an API key**
53
-
54
- ### OpenRouter
55
-
56
- - Run `/login openrouter`, then select **Sign in with OpenRouter** to open the OpenRouter PKCE authorization flow
57
- - The authorization creates a user-controlled OpenRouter API key billed from your OpenRouter credits
58
- - On remote/headless machines (e.g. over SSH) the browser cannot reach the loopback callback; paste the final redirect URL (or the authorization code) into the login prompt instead
59
- - `OPENROUTER_API_KEY` remains available through **Use an API key**
60
-
61
- ### Radius
62
-
63
- Radius is a `pi-messages` gateway. Pi ships the public Radius model catalog for immediate and offline model lookup, then overlays it with the effective gateway catalog after authentication. `/login radius` stores OAuth tokens in `auth.json`; refreshed catalogs are cached in `models-store.json`. Custom Radius gateways can be declared in `models.json` with `"oauth": "radius"` and a gateway `baseUrl`; they do not inherit the public `radius.pi.dev` catalog.
64
-
65
- ## API Keys
66
-
67
- ### Environment Variables or Auth File
68
-
69
- Use `/login` in interactive mode and select a provider to store an API key in `auth.json`, or set credentials via environment variable:
24
+ Environment variables are useful in CI and anywhere Pi should not store the key. Set the variable before starting Pi:
70
25
 
71
26
  ```bash
72
27
  export ANTHROPIC_API_KEY=sk-ant-...
73
28
  pi
74
29
  ```
75
30
 
76
- | Provider | Environment Variable | `auth.json` key |
77
- |----------|----------------------|------------------|
78
- | Anthropic | `ANTHROPIC_API_KEY` | `anthropic` |
79
- | Ant Ling | `ANT_LING_API_KEY` | `ant-ling` |
80
- | Azure OpenAI Responses | `AZURE_OPENAI_API_KEY` | `azure-openai-responses` |
81
- | OpenAI | `OPENAI_API_KEY` | `openai` |
82
- | DeepSeek | `DEEPSEEK_API_KEY` | `deepseek` |
83
- | NVIDIA NIM | `NVIDIA_API_KEY` | `nvidia` |
84
- | Google Gemini | `GEMINI_API_KEY` | `google` |
85
- | Amazon Bedrock | `AWS_BEARER_TOKEN_BEDROCK` | `amazon-bedrock` |
86
- | Mistral | `MISTRAL_API_KEY` | `mistral` |
87
- | Groq | `GROQ_API_KEY` | `groq` |
88
- | Cerebras | `CEREBRAS_API_KEY` | `cerebras` |
89
- | Cloudflare AI Gateway | `CLOUDFLARE_API_KEY` (+ `CLOUDFLARE_ACCOUNT_ID`, `CLOUDFLARE_GATEWAY_ID`) | `cloudflare-ai-gateway` |
90
- | Cloudflare Workers AI | `CLOUDFLARE_API_KEY` (+ `CLOUDFLARE_ACCOUNT_ID`) | `cloudflare-workers-ai` |
91
- | xAI | `XAI_API_KEY` | `xai` |
92
- | OpenRouter | `OPENROUTER_API_KEY` | `openrouter` |
93
- | Vercel AI Gateway | `AI_GATEWAY_API_KEY` | `vercel-ai-gateway` |
94
- | ZAI Coding Plan (Global) | `ZAI_API_KEY` | `zai` |
95
- | ZAI Coding Plan (China) | `ZAI_CODING_CN_API_KEY` | `zai-coding-cn` |
96
- | OpenCode Zen | `OPENCODE_API_KEY` | `opencode` |
97
- | OpenCode Go | `OPENCODE_API_KEY` | `opencode-go` |
98
- | Radius | `RADIUS_API_KEY` | `radius` |
99
- | Hugging Face | `HF_TOKEN` | `huggingface` |
100
- | Fireworks | `FIREWORKS_API_KEY` | `fireworks` |
101
- | Together AI | `TOGETHER_API_KEY` | `together` |
102
- | Baseten | `BASETEN_API_KEY` | `baseten` |
103
- | Kimi For Coding | `KIMI_API_KEY` | `kimi-coding` |
104
- | Meta | `META_API_KEY` | `meta` |
105
- | MiniMax | `MINIMAX_API_KEY` | `minimax` |
106
- | MiniMax (China) | `MINIMAX_CN_API_KEY` | `minimax-cn` |
107
- | Qwen Token Plan (existing catalog) | `QWEN_TOKEN_PLAN_API_KEY` | `qwen-token-plan` |
108
- | Qwen Token Plan (Individual) | `QWEN_TOKEN_PLAN_API_KEY` | `qwen-token-plan-individual` |
109
- | Qwen Token Plan (China) | `QWEN_TOKEN_PLAN_CN_API_KEY` | `qwen-token-plan-cn` |
110
- | Xiaomi MiMo | `XIAOMI_API_KEY` | `xiaomi` |
111
- | Xiaomi MiMo Token Plan (China) | `XIAOMI_TOKEN_PLAN_CN_API_KEY` | `xiaomi-token-plan-cn` |
112
- | Xiaomi MiMo Token Plan (Amsterdam) | `XIAOMI_TOKEN_PLAN_AMS_API_KEY` | `xiaomi-token-plan-ams` |
113
- | Xiaomi MiMo Token Plan (Singapore) | `XIAOMI_TOKEN_PLAN_SGP_API_KEY` | `xiaomi-token-plan-sgp` |
114
-
115
- Reference for environment variables and `auth.json` keys: [`const envMap`](https://github.com/earendil-works/pi/blob/main/packages/ai/src/env-api-keys.ts) in [`packages/ai/src/env-api-keys.ts`](https://github.com/earendil-works/pi/blob/main/packages/ai/src/env-api-keys.ts).
116
-
117
- #### Auth File
118
-
119
- Store credentials in `~/.pi/agent/auth.json`:
31
+ This table covers providers with a single primary API-key variable. Providers that need additional configuration or support ambient credentials are covered under [Cloud providers](#cloud-providers).
32
+
33
+ | Provider | Environment variable |
34
+ |---|---|
35
+ | Anthropic | `ANTHROPIC_API_KEY` |
36
+ | Ant Ling | `ANT_LING_API_KEY` |
37
+ | OpenAI | `OPENAI_API_KEY` |
38
+ | DeepSeek | `DEEPSEEK_API_KEY` |
39
+ | NVIDIA NIM | `NVIDIA_API_KEY` |
40
+ | Google Gemini | `GEMINI_API_KEY` |
41
+ | GitHub Copilot | `COPILOT_GITHUB_TOKEN` |
42
+ | Mistral | `MISTRAL_API_KEY` |
43
+ | Groq | `GROQ_API_KEY` |
44
+ | Cerebras | `CEREBRAS_API_KEY` |
45
+ | xAI | `XAI_API_KEY` |
46
+ | OpenRouter | `OPENROUTER_API_KEY` |
47
+ | Vercel AI Gateway | `AI_GATEWAY_API_KEY` |
48
+ | ZAI Coding Plan (Global) | `ZAI_API_KEY` |
49
+ | ZAI Coding Plan (China) | `ZAI_CODING_CN_API_KEY` |
50
+ | OpenCode Zen and Go | `OPENCODE_API_KEY` |
51
+ | Radius | `RADIUS_API_KEY` |
52
+ | Hugging Face | `HF_TOKEN` |
53
+ | Fireworks | `FIREWORKS_API_KEY` |
54
+ | Together AI | `TOGETHER_API_KEY` |
55
+ | Baseten | `BASETEN_API_KEY` |
56
+ | Kimi For Coding | `KIMI_API_KEY` |
57
+ | Meta | `META_API_KEY` |
58
+ | MiniMax | `MINIMAX_API_KEY` |
59
+ | MiniMax (China) | `MINIMAX_CN_API_KEY` |
60
+ | Moonshot AI (Global and China) | `MOONSHOT_API_KEY` |
61
+ | Qwen Token Plan and Individual | `QWEN_TOKEN_PLAN_API_KEY` |
62
+ | Qwen Token Plan (China) | `QWEN_TOKEN_PLAN_CN_API_KEY` |
63
+ | Xiaomi MiMo | `XIAOMI_API_KEY` |
64
+ | Xiaomi MiMo Token Plan (China) | `XIAOMI_TOKEN_PLAN_CN_API_KEY` |
65
+ | Xiaomi MiMo Token Plan (Amsterdam) | `XIAOMI_TOKEN_PLAN_AMS_API_KEY` |
66
+ | Xiaomi MiMo Token Plan (Singapore) | `XIAOMI_TOKEN_PLAN_SGP_API_KEY` |
67
+
68
+ Anthropic also recognizes `ANTHROPIC_OAUTH_TOKEN` as an API credential and `ANTHROPIC_AUTH_TOKEN` as bearer authentication.
69
+
70
+ ## Load an API key from a command
71
+
72
+ To use a secret manager without writing the resolved key to disk, set a provider's `key` in `auth.json` to a command prefixed with `!`:
120
73
 
121
74
  ```json
122
75
  {
123
- "anthropic": { "type": "api_key", "key": "sk-ant-..." },
124
- "ant-ling": { "type": "api_key", "key": "..." },
125
- "openai": { "type": "api_key", "key": "sk-..." },
126
- "deepseek": { "type": "api_key", "key": "sk-..." },
127
- "nvidia": { "type": "api_key", "key": "nvapi-..." },
128
- "google": { "type": "api_key", "key": "..." },
129
- "opencode": { "type": "api_key", "key": "..." },
130
- "opencode-go": { "type": "api_key", "key": "..." },
131
- "together": { "type": "api_key", "key": "..." },
132
- "qwen-token-plan": { "type": "api_key", "key": "sk-sp-..." },
133
- "qwen-token-plan-individual": { "type": "api_key", "key": "sk-sp-..." },
134
- "qwen-token-plan-cn": { "type": "api_key", "key": "sk-sp-..." },
135
- "xiaomi": { "type": "api_key", "key": "..." },
136
- "xiaomi-token-plan-cn": { "type": "api_key", "key": "..." },
137
- "xiaomi-token-plan-ams": { "type": "api_key", "key": "..." },
138
- "xiaomi-token-plan-sgp": { "type": "api_key", "key": "..." }
76
+ "anthropic": {
77
+ "type": "api_key",
78
+ "key": "!security find-generic-password -ws 'anthropic'"
79
+ }
139
80
  }
140
81
  ```
141
82
 
142
- `qwen-token-plan-individual` uses the same international endpoint and `QWEN_TOKEN_PLAN_API_KEY` as
143
- `qwen-token-plan`, but limits the picker to the models documented for Individual subscriptions. The existing
144
- provider keeps its broader catalog for backward compatibility. When using `auth.json`, store the
145
- credential under the provider you select; an environment variable is shared by both international providers.
83
+ Pi runs the command when the key is first needed and caches its standard output for the process lifetime. Empty output, a timeout, or a nonzero exit leaves the key unresolved until Pi restarts.
84
+
85
+ ## Cloud Providers
146
86
 
147
- The file is created with `0600` permissions (user read/write only). Auth file credentials take priority over environment variables.
87
+ The providers below need additional settings or can use credentials supplied by their cloud platform.
148
88
 
149
- API key credentials can also include provider-scoped environment values. These values are used before process environment variables when resolving the credential key, provider/model headers, and provider configuration such as Cloudflare account IDs, Azure OpenAI settings, Vertex project/location, Bedrock settings, `PI_CACHE_RETENTION`, and `HTTP_PROXY`/`HTTPS_PROXY`.
89
+ A stored API-key credential can include an `env` object. Its values take priority over the process environment for that provider:
150
90
 
151
91
  ```json
152
92
  {
153
- "cloudflare-ai-gateway": {
93
+ "cloudflare-workers-ai": {
154
94
  "type": "api_key",
155
- "key": "$CLOUDFLARE_API_KEY",
95
+ "key": "...",
156
96
  "env": {
157
- "CLOUDFLARE_API_KEY": "...",
158
- "CLOUDFLARE_ACCOUNT_ID": "account-id",
159
- "CLOUDFLARE_GATEWAY_ID": "gateway-id"
97
+ "CLOUDFLARE_ACCOUNT_ID": "account-id"
160
98
  }
161
99
  }
162
100
  }
163
101
  ```
164
102
 
165
- Use this when pi should use different provider settings than the project shell environment.
166
-
167
- ### Key Resolution
168
-
169
- The `key` field supports command execution, environment interpolation, and literals:
170
-
171
- - **Shell command:** `"!command"` at the start executes the whole value as a command and uses stdout (cached for process lifetime)
172
- ```json
173
- { "type": "api_key", "key": "!security find-generic-password -ws 'anthropic'" }
174
- { "type": "api_key", "key": "!op read 'op://vault/item/credential'" }
175
- ```
176
- - **Environment interpolation:** `"$ENV_VAR"` or `"${ENV_VAR}"` uses the value of the named variable. Interpolation works inside larger literals.
177
- ```json
178
- { "type": "api_key", "key": "$MY_ANTHROPIC_KEY" }
179
- { "type": "api_key", "key": "${KEY_PREFIX}_${KEY_SUFFIX}" }
180
- ```
181
- `$FOO_BAR` is the variable `FOO_BAR`; use `${FOO}_BAR` when `BAR` is literal text. Missing environment variables make the value unresolved.
182
- - **Escapes:** `"$$"` emits a literal `"$"`; `"$!"` emits a literal `"!"` without triggering command execution.
183
- ```json
184
- { "type": "api_key", "key": "$$literal-dollar-prefix" }
185
- { "type": "api_key", "key": "$!literal-bang-prefix" }
186
- ```
187
- - **Literal value:** Used directly. Plain uppercase strings such as `MY_API_KEY` are literals; use `$MY_API_KEY` for environment variables.
188
- ```json
189
- { "type": "api_key", "key": "sk-ant-..." }
190
- { "type": "api_key", "key": "public" }
191
- ```
192
-
193
- OAuth credentials are also stored here after `/login` and managed automatically.
194
-
195
- ## Cloud Providers
196
-
197
103
  ### Azure OpenAI
198
104
 
105
+ Set an API key plus either a base URL or resource name:
106
+
199
107
  ```bash
200
108
  export AZURE_OPENAI_API_KEY=...
201
109
  export AZURE_OPENAI_BASE_URL=https://your-resource.ai.azure.com
202
- # also supported: https://your-resource.cognitiveservices.azure.com
203
- # also supported: https://your-resource.openai.azure.com
204
- # root endpoints are auto-normalized to /openai/v1
205
- # or use resource name instead of base URL
110
+ # Or:
206
111
  export AZURE_OPENAI_RESOURCE_NAME=your-resource
207
-
208
- # Optional
209
- export AZURE_OPENAI_API_VERSION=2024-02-01
210
- export AZURE_OPENAI_DEPLOYMENT_NAME_MAP=gpt-4=my-gpt4,gpt-4o=my-gpt4o
211
112
  ```
212
113
 
114
+ Resource root URLs under `ai.azure.com`, `cognitiveservices.azure.com`, and `openai.azure.com` are normalized to the OpenAI API path.
115
+
213
116
  ### Amazon Bedrock
214
117
 
215
- Use `/login amazon-bedrock` to store a Bedrock API key, or configure one of the ambient AWS credential sources below:
118
+ Bedrock can use a bearer token or an ambient AWS credential source:
216
119
 
217
120
  ```bash
218
- # Option 1: AWS Profile
121
+ # Named profile
219
122
  export AWS_PROFILE=your-profile
220
123
 
221
- # Option 2: IAM Keys
124
+ # IAM keys
222
125
  export AWS_ACCESS_KEY_ID=AKIA...
223
126
  export AWS_SECRET_ACCESS_KEY=...
127
+ # Required for temporary credentials
128
+ export AWS_SESSION_TOKEN=...
224
129
 
225
- # Option 3: Bearer Token
130
+ # Bedrock bearer token
226
131
  export AWS_BEARER_TOKEN_BEDROCK=...
227
132
 
228
- # Optional region (defaults to us-east-1)
133
+ # Region, when not supplied by the profile or AWS SDK configuration
229
134
  export AWS_REGION=us-west-2
135
+ # AWS_DEFAULT_REGION is also supported
230
136
  ```
231
137
 
232
- Also supports ECS task roles (`AWS_CONTAINER_CREDENTIALS_*`) and IRSA (`AWS_WEB_IDENTITY_TOKEN_FILE`).
233
-
234
- ```bash
235
- pi --provider amazon-bedrock --model us.anthropic.claude-sonnet-4-20250514-v1:0
236
- ```
237
-
238
- Prompt caching is enabled automatically for Claude models whose ID contains a recognizable model name (base models and system-defined inference profiles). For application inference profiles (whose ARNs don't contain the model name), set `AWS_BEDROCK_FORCE_CACHE=1` to enable cache points:
239
-
240
- ```bash
241
- export AWS_BEDROCK_FORCE_CACHE=1
242
- pi --provider amazon-bedrock --model arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abc123
243
- ```
244
-
245
- If you are connecting to a Bedrock API proxy, the following environment variables can be used:
246
-
247
- ```bash
248
- # Set the URL for the Bedrock proxy (standard AWS SDK env var)
249
- export AWS_ENDPOINT_URL_BEDROCK_RUNTIME=https://my.corp.proxy/bedrock
250
-
251
- # Set if your proxy does not require authentication
252
- export AWS_BEDROCK_SKIP_AUTH=1
253
-
254
- # Set if your proxy only supports HTTP/1.1
255
- export AWS_BEDROCK_FORCE_HTTP1=1
256
- ```
138
+ Pi also supports ECS task credentials and IRSA through the standard `AWS_CONTAINER_CREDENTIALS_*` and `AWS_WEB_IDENTITY_TOKEN_FILE` variables.
257
139
 
258
140
  ### Cloudflare AI Gateway
259
141
 
260
- `CLOUDFLARE_API_KEY` can be set via `/login`. The account ID and gateway slug can be set as environment variables or in the API key credential's `env` object in `auth.json`.
142
+ The gateway requires a token, account ID, and gateway ID:
261
143
 
262
144
  ```bash
263
- export CLOUDFLARE_API_KEY=... # or use /login
145
+ export CLOUDFLARE_API_KEY=...
264
146
  export CLOUDFLARE_ACCOUNT_ID=...
265
- export CLOUDFLARE_GATEWAY_ID=... # create at dash.cloudflare.com → AI → AI Gateway
266
- pi --provider cloudflare-ai-gateway --model "claude-sonnet-4-5"
147
+ export CLOUDFLARE_GATEWAY_ID=...
267
148
  ```
268
149
 
269
- Routes to OpenAI, Anthropic, and Workers AI through Cloudflare AI Gateway. Workers AI uses the Unified API (`/compat`) and prefixed model IDs (`workers-ai/@cf/...`). OpenAI uses the OpenAI passthrough route (`/openai`) with native OpenAI model IDs such as `gpt-5.1`. Anthropic uses the Anthropic passthrough route (`/anthropic`) with native Anthropic model IDs such as `claude-sonnet-4-5`.
270
-
271
- AI Gateway authentication uses `CLOUDFLARE_API_KEY` as `cf-aig-authorization`. Upstream authentication can be one of:
150
+ The account and gateway IDs can come from the process environment or the credential's `env` object in `auth.json`.
272
151
 
273
- | Mode | Request auth | Upstream auth |
274
- |------|--------------|---------------|
275
- | Workers AI | Cloudflare token only | Cloudflare-native |
276
- | Unified billing | Cloudflare token only | Cloudflare handles upstream auth and deducts credits |
277
- | Stored BYOK | Cloudflare token only | Cloudflare injects provider keys stored in the AI Gateway dashboard |
278
- | Inline BYOK | Cloudflare token plus upstream `Authorization` header | The request supplies the upstream provider key |
279
-
280
- For normal pi usage, prefer unified billing or stored BYOK. Inline BYOK requires configuring an additional upstream `Authorization` header for the Cloudflare AI Gateway provider, for example via a `models.json` provider/model override.
152
+ `CLOUDFLARE_API_KEY` authenticates Pi to the gateway. Upstream access can use Cloudflare unified billing, credentials stored in the gateway, or an `Authorization` header configured for the provider in `models.json`.
281
153
 
282
154
  ### Cloudflare Workers AI
283
155
 
284
- `CLOUDFLARE_API_KEY` can be set via `/login`. `CLOUDFLARE_ACCOUNT_ID` can be set as an environment variable or in the API key credential's `env` object in `auth.json`.
156
+ Workers AI requires a token and account ID:
285
157
 
286
158
  ```bash
287
- export CLOUDFLARE_API_KEY=... # or use /login
159
+ export CLOUDFLARE_API_KEY=...
288
160
  export CLOUDFLARE_ACCOUNT_ID=...
289
- pi --provider cloudflare-workers-ai --model "@cf/moonshotai/kimi-k2.6"
290
161
  ```
291
162
 
292
- Pi automatically sets `x-session-affinity` for [prefix caching](https://developers.cloudflare.com/workers-ai/features/prompt-caching/) discounts.
163
+ The account ID can also be stored in the credential's `env` object.
293
164
 
294
165
  ### Google Vertex AI
295
166
 
296
- Uses Application Default Credentials:
167
+ Use a Google Cloud API key:
297
168
 
298
169
  ```bash
299
- gcloud auth application-default login
300
- export GOOGLE_CLOUD_PROJECT=your-project
301
- export GOOGLE_CLOUD_LOCATION=us-central1
170
+ export GOOGLE_CLOUD_API_KEY=...
302
171
  ```
303
172
 
304
- Or set `GOOGLE_APPLICATION_CREDENTIALS` to a service account key file.
305
-
306
- ## llama.cpp
307
-
308
- Pi supports the llama.cpp router server. Configure it with `/login llama.cpp`, manage loaded models with `/llama`, and select a loaded model with `/model`.
309
-
310
- See [llama.cpp](llama-cpp.md) for server setup, model directory layout, environment variables, and command usage.
173
+ To use Application Default Credentials, configure a project and location:
311
174
 
312
- ## Custom Providers
313
-
314
- **Via models.json:** Add Ollama, LM Studio, vLLM, or any provider that speaks a supported API (OpenAI Completions, OpenAI Responses, Anthropic Messages, Google Generative AI). See [models.md](models.md).
315
-
316
- **Via extensions:** For providers that need custom API implementations or OAuth flows, create an extension. See [custom-provider.md](custom-provider.md) and [examples/extensions/custom-provider-gitlab-duo](../examples/extensions/custom-provider-gitlab-duo/).
175
+ ```bash
176
+ export GOOGLE_CLOUD_PROJECT=your-project
177
+ # GCLOUD_PROJECT is also supported
178
+ export GOOGLE_CLOUD_LOCATION=us-central1
179
+ ```
317
180
 
318
- ## Resolution Order
181
+ Then authenticate:
319
182
 
320
- When resolving credentials for a provider:
183
+ ```bash
184
+ gcloud auth application-default login
185
+ ```
321
186
 
322
- 1. CLI `--api-key` flag
323
- 2. `auth.json` entry (API key or OAuth token)
324
- 3. Environment variable
325
- 4. Custom provider keys from `models.json`
187
+ To use a service-account key file instead, set `GOOGLE_APPLICATION_CREDENTIALS` along with the project and location.