@diegopetrucci/pi-fast 0.1.10 → 0.1.12
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.
- package/README.md +12 -13
- package/index.ts +30 -83
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,11 +34,7 @@ For eligible Anthropic Claude models it injects:
|
|
|
34
34
|
}
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
It also
|
|
38
|
-
|
|
39
|
-
```text
|
|
40
|
-
anthropic-beta: fast-mode-2026-02-01
|
|
41
|
-
```
|
|
37
|
+
It also appends the required beta `fast-mode-2026-02-01` to the request's `betas` list, which Pi sends as the `anthropic-beta` header. The extension does not set the `anthropic-beta` header itself, so Pi's own betas are kept.
|
|
42
38
|
|
|
43
39
|
## Eligibility
|
|
44
40
|
|
|
@@ -46,7 +42,7 @@ Direct OpenAI API Fast mode requires all of the following:
|
|
|
46
42
|
|
|
47
43
|
- Provider `openai`.
|
|
48
44
|
- API `openai-responses` or `openai-completions`.
|
|
49
|
-
- Model `gpt-6.1-sol`, `gpt-6-astra`, `gpt-6-sol`, or `gpt-6-luna`.
|
|
45
|
+
- Model `gpt-6.1-sol`, `gpt-6.1-terra`, `gpt-5.6-sol`, `gpt-6-astra`, `gpt-6-sol`, or `gpt-6-luna`.
|
|
50
46
|
- API-key auth sets `service_tier: "fast"`; Pi's `openai` ChatGPT OAuth sets `priority`.
|
|
51
47
|
- No existing `service_tier` field in the request payload.
|
|
52
48
|
|
|
@@ -64,7 +60,7 @@ the following on every activation and provider request:
|
|
|
64
60
|
|
|
65
61
|
- Provider `openai`.
|
|
66
62
|
- API `openai-responses`.
|
|
67
|
-
- Model `gpt-6-astra`.
|
|
63
|
+
- Model `gpt-6-astra` or `gpt-6.1-sol`.
|
|
68
64
|
- Direct API-key auth, not Codex OAuth or direct OpenAI OAuth.
|
|
69
65
|
- Base URL exactly `https://api.openai.com/v1` (a single trailing slash is also accepted).
|
|
70
66
|
|
|
@@ -85,7 +81,7 @@ OpenAI Codex Fast mode requires all of the following:
|
|
|
85
81
|
|
|
86
82
|
- Provider `openai-codex`.
|
|
87
83
|
- API `openai-codex-responses`.
|
|
88
|
-
- Model `gpt-5.5`, `gpt-5.6-sol`, `gpt-5.6-terra`, `gpt-5.6-luna`, `gpt-6-astra`, `gpt-6.1-sol`, `gpt-6-sol`, or `gpt-6-luna`.
|
|
84
|
+
- Model `gpt-5.5`, `gpt-5.6-sol`, `gpt-5.6-terra`, `gpt-5.6-luna`, `gpt-6-astra`, `gpt-6.1-sol`, `gpt-6.1-terra`, `gpt-6-sol`, or `gpt-6-luna`.
|
|
89
85
|
- ChatGPT OAuth/subscription auth, not API-key auth.
|
|
90
86
|
- No existing `service_tier` field in the request payload.
|
|
91
87
|
|
|
@@ -112,10 +108,10 @@ Anthropic Fast mode requires all of the following:
|
|
|
112
108
|
|
|
113
109
|
- Provider `anthropic`.
|
|
114
110
|
- API `anthropic-messages`.
|
|
115
|
-
- Model `claude-opus-
|
|
111
|
+
- Model `claude-opus-5`, `claude-opus-5-5`, `claude-fable-5-2`, or `claude-mythos-5-2`.
|
|
116
112
|
- No existing `speed` field in the request payload.
|
|
117
113
|
|
|
118
|
-
Anthropic Fast mode supports both API-key and Claude Code OAuth access
|
|
114
|
+
Anthropic Fast mode supports both API-key and Claude Code OAuth access. Fast mode on Claude Opus 5.5 and Claude Fable 5.2 is generally available, subject to the account usage tier. Fast mode on Claude Opus 5 is a research preview and requires research-preview access. On Claude subscriptions (OAuth), Fast usage draws from usage credits.
|
|
119
115
|
|
|
120
116
|
## Commands
|
|
121
117
|
|
|
@@ -136,7 +132,8 @@ Ultrafast override. Ultrafast defaults off, is never enabled by global or projec
|
|
|
136
132
|
configuration, and can be undone with either command. Running ordinary `/fast`
|
|
137
133
|
while Ultrafast is selected turns Ultrafast off rather than silently switching to
|
|
138
134
|
another paid tier. Switching to an unsupported model or endpoint disables
|
|
139
|
-
Ultrafast and does not re-enable it when `gpt-6-astra` is selected again.
|
|
135
|
+
Ultrafast and does not re-enable it when `gpt-6-astra` or `gpt-6.1-sol` is selected again. Switching directly
|
|
136
|
+
between those two eligible models keeps Ultrafast on. The
|
|
140
137
|
footer uses `ultrafast` while an eligible request is selected; status text says
|
|
141
138
|
that the tier is requested, not remotely applied.
|
|
142
139
|
|
|
@@ -203,8 +200,10 @@ The collection package loads this unified extension only (`extensions/fast/index
|
|
|
203
200
|
## Notes
|
|
204
201
|
|
|
205
202
|
- Anthropic Fast mode has separate rate limits, costs more than standard speed, and does not share prompt-cache prefixes with standard-speed requests.
|
|
206
|
-
-
|
|
207
|
-
-
|
|
203
|
+
- Claude Fable 5.2 Fast mode bills at $16 / $80 per MTok input/output (2x its standard rate). Because the Fast toggle follows model changes, a config default of `enabled: true` applies Fast to Fable 5.2 as soon as it is selected.
|
|
204
|
+
- Direct OpenAI Fast mode is limited to the documented API models above; Fast pricing, availability, and rate limits remain provider- and account-dependent.
|
|
205
|
+
- Authoritative support evidence: [OpenAI Fast mode](https://developers.openai.com/api/docs/guides/fast-mode) explicitly uses `gpt-6.1-sol` with `service_tier: "fast"` and documents `priority` as an equivalent alias for supported API models; the [GPT-6.1 Sol model page](https://developers.openai.com/api/docs/models/gpt-6.1-sol) documents the model itself. The [GPT-6.1 Terra model page](https://developers.openai.com/api/docs/models/gpt-6.1-terra) states Fast prices are 2x Standard, and the Fast mode guide lists GPT-5.6 Sol at 2x.
|
|
206
|
+
- Codex `gpt-6.1-terra` is enabled because openai/codex `codex-rs/models-manager/models.json` @ b32ada5 advertises `priority` for it. Anthropic `claude-mythos-5-2` follows [Anthropic Fast mode](https://platform.claude.com/docs/en/build-with-claude/fast-mode), which lists Claude Mythos 5.2; the native ID is inferred from naming.
|
|
208
207
|
- Codex Fast availability depends on plan, client, workspace settings, and rollout. Local eligibility is not live-provider certification.
|
|
209
208
|
- Pi's provider catalog remains the source of reported model pricing, including any tiered pricing; this extension does not apply guessed discounts or rewrite cost metadata.
|
|
210
209
|
- OpenAI Codex Fast mode intentionally does not affect API-key models.
|
package/index.ts
CHANGED
|
@@ -12,10 +12,12 @@ const ANTHROPIC_PROVIDER_ID = "anthropic";
|
|
|
12
12
|
const ANTHROPIC_API_ID = "anthropic-messages";
|
|
13
13
|
const ANTHROPIC_FAST_SPEED = "fast";
|
|
14
14
|
const ANTHROPIC_FAST_BETA = "fast-mode-2026-02-01";
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const ANTHROPIC_SUPPORTED_MODELS = new Set([
|
|
16
|
+
"claude-opus-5",
|
|
17
|
+
"claude-opus-5-5",
|
|
18
|
+
"claude-fable-5-2",
|
|
19
|
+
"claude-mythos-5-2",
|
|
20
|
+
]);
|
|
19
21
|
|
|
20
22
|
const OPENAI_PROVIDER_ID = "openai-codex";
|
|
21
23
|
const OPENAI_API_ID = "openai-codex-responses";
|
|
@@ -27,6 +29,7 @@ const OPENAI_SUPPORTED_MODELS = new Set([
|
|
|
27
29
|
"gpt-5.6-luna",
|
|
28
30
|
"gpt-6-astra",
|
|
29
31
|
"gpt-6.1-sol",
|
|
32
|
+
"gpt-6.1-terra",
|
|
30
33
|
"gpt-6-sol",
|
|
31
34
|
"gpt-6-luna",
|
|
32
35
|
]);
|
|
@@ -35,11 +38,13 @@ const OPENAI_API_IDS = new Set(["openai-responses", "openai-completions"]);
|
|
|
35
38
|
const OPENAI_API_FAST_SERVICE_TIER = "fast";
|
|
36
39
|
const OPENAI_API_SUPPORTED_MODELS = new Set([
|
|
37
40
|
"gpt-6.1-sol",
|
|
41
|
+
"gpt-6.1-terra",
|
|
42
|
+
"gpt-5.6-sol",
|
|
38
43
|
"gpt-6-astra",
|
|
39
44
|
"gpt-6-sol",
|
|
40
45
|
"gpt-6-luna",
|
|
41
46
|
]);
|
|
42
|
-
const
|
|
47
|
+
const OPENAI_ULTRAFAST_MODELS = new Set(["gpt-6-astra", "gpt-6.1-sol"]);
|
|
43
48
|
const OPENAI_ULTRAFAST_API_ID = "openai-responses";
|
|
44
49
|
const OPENAI_ULTRAFAST_SERVICE_TIER = "ultrafast";
|
|
45
50
|
const OPENAI_CANONICAL_BASE_URL = "https://api.openai.com/v1";
|
|
@@ -79,11 +84,6 @@ type RecursivePartial<T> = {
|
|
|
79
84
|
|
|
80
85
|
type PayloadRecord = Record<string, unknown>;
|
|
81
86
|
|
|
82
|
-
type AnthropicHeaderCompat = {
|
|
83
|
-
forceAdaptiveThinking?: boolean;
|
|
84
|
-
supportsEagerToolInputStreaming?: boolean;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
87
|
type Eligibility = {
|
|
88
88
|
eligible: boolean;
|
|
89
89
|
modelKey: string;
|
|
@@ -175,7 +175,8 @@ function getEligibility(ctx: ExtensionContext, includeServiceTier = true): Eligi
|
|
|
175
175
|
return {
|
|
176
176
|
eligible: false,
|
|
177
177
|
modelKey: key,
|
|
178
|
-
reason:
|
|
178
|
+
reason:
|
|
179
|
+
"Fast mode is only enabled for Claude Opus 5, Claude Opus 5.5, Claude Fable 5.2, and Claude Mythos 5.2",
|
|
179
180
|
};
|
|
180
181
|
}
|
|
181
182
|
|
|
@@ -229,7 +230,7 @@ function getEligibility(ctx: ExtensionContext, includeServiceTier = true): Eligi
|
|
|
229
230
|
eligible: false,
|
|
230
231
|
modelKey: key,
|
|
231
232
|
reason:
|
|
232
|
-
"Fast mode is only enabled for GPT-6.1 Sol, GPT-6 Astra, GPT-6 Sol, and GPT-6 Luna on direct OpenAI APIs",
|
|
233
|
+
"Fast mode is only enabled for GPT-6.1 Sol, GPT-6.1 Terra, GPT-5.6 Sol, GPT-6 Astra, GPT-6 Sol, and GPT-6 Luna on direct OpenAI APIs",
|
|
233
234
|
};
|
|
234
235
|
}
|
|
235
236
|
|
|
@@ -279,11 +280,11 @@ function getUltrafastEligibility(ctx: ExtensionContext): Eligibility {
|
|
|
279
280
|
};
|
|
280
281
|
}
|
|
281
282
|
|
|
282
|
-
if (model.id
|
|
283
|
+
if (!OPENAI_ULTRAFAST_MODELS.has(model.id)) {
|
|
283
284
|
return {
|
|
284
285
|
eligible: false,
|
|
285
286
|
modelKey: key,
|
|
286
|
-
reason:
|
|
287
|
+
reason: "Ultrafast mode is only enabled for GPT-6 Astra and GPT-6.1 Sol",
|
|
287
288
|
};
|
|
288
289
|
}
|
|
289
290
|
|
|
@@ -368,67 +369,17 @@ function getStatusMessage(ctx: ExtensionContext, state: SessionState): string {
|
|
|
368
369
|
return `Fast mode is ${describeMode(state)}. Current model: ${eligibility.modelKey}.${injected}`;
|
|
369
370
|
}
|
|
370
371
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
if (typeof apiKey === "string") return apiKey.includes("sk-ant-oat");
|
|
383
|
-
} catch {
|
|
384
|
-
// Fall back to the synchronous registry snapshot below.
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
return ctx.model ? ctx.modelRegistry.isUsingOAuth(ctx.model) : false;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
function getAnthropicProviderBetas(ctx: ExtensionContext, hasActiveTools: boolean): string[] {
|
|
391
|
-
const model = ctx.model;
|
|
392
|
-
if (!model) return [];
|
|
393
|
-
const compat = model.compat as AnthropicHeaderCompat | undefined;
|
|
394
|
-
|
|
395
|
-
const betas: string[] = [];
|
|
396
|
-
if (hasActiveTools && compat?.supportsEagerToolInputStreaming === false) {
|
|
397
|
-
betas.push(FINE_GRAINED_TOOL_STREAMING_BETA);
|
|
398
|
-
}
|
|
399
|
-
if (compat?.forceAdaptiveThinking !== true) {
|
|
400
|
-
betas.push(INTERLEAVED_THINKING_BETA);
|
|
401
|
-
}
|
|
402
|
-
return betas;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
async function injectAnthropicFastHeader(
|
|
406
|
-
headers: Record<string, string | null>,
|
|
407
|
-
ctx: ExtensionContext,
|
|
408
|
-
state: SessionState,
|
|
409
|
-
hasActiveTools: boolean,
|
|
410
|
-
): Promise<void> {
|
|
411
|
-
if (state.ultrafast || !isFastEnabled(state)) return;
|
|
412
|
-
const eligibility = getEligibility(ctx, false);
|
|
413
|
-
if (!eligibility.eligible || eligibility.provider !== "anthropic") return;
|
|
414
|
-
|
|
415
|
-
const matchingKeys = Object.keys(headers).filter(
|
|
416
|
-
(name) => name.toLowerCase() === "anthropic-beta",
|
|
417
|
-
);
|
|
418
|
-
const existing = matchingKeys.flatMap((name) => splitBetaHeader(headers[name]));
|
|
419
|
-
const matchingModelEntries = Object.entries(ctx.model?.headers ?? {}).filter(
|
|
420
|
-
([name]) => name.toLowerCase() === "anthropic-beta",
|
|
421
|
-
);
|
|
422
|
-
const modelBetas = matchingModelEntries.flatMap(([, value]) => splitBetaHeader(value));
|
|
423
|
-
const providerBetas = getAnthropicProviderBetas(ctx, hasActiveTools);
|
|
424
|
-
const oauthBetas = (await isAnthropicOAuth(ctx)) ? CLAUDE_CODE_OAUTH_BETAS : [];
|
|
425
|
-
const next = Array.from(
|
|
426
|
-
new Set([...modelBetas, ...existing, ...oauthBetas, ...providerBetas, ANTHROPIC_FAST_BETA]),
|
|
427
|
-
);
|
|
428
|
-
|
|
429
|
-
for (const key of matchingKeys) delete headers[key];
|
|
430
|
-
const outputKey = matchingModelEntries.at(-1)?.[0] ?? "anthropic-beta";
|
|
431
|
-
headers[outputKey] = next.join(",");
|
|
372
|
+
/**
|
|
373
|
+
* Adds the Fast beta to the request's `betas` list instead of rewriting the
|
|
374
|
+
* `anthropic-beta` header. Pi derives the final beta list from the model and
|
|
375
|
+
* request (mid-conversation effort, server-side fallback, inline tools, OAuth,
|
|
376
|
+
* interleaved thinking, ...) and treats an explicit `anthropic-beta` header as
|
|
377
|
+
* the complete list, so setting that header here would drop any beta this
|
|
378
|
+
* extension does not know about.
|
|
379
|
+
*/
|
|
380
|
+
function withAnthropicFastBeta(betas: unknown[] | undefined): unknown[] {
|
|
381
|
+
const existing = betas ?? [];
|
|
382
|
+
return existing.includes(ANTHROPIC_FAST_BETA) ? existing : [...existing, ANTHROPIC_FAST_BETA];
|
|
432
383
|
}
|
|
433
384
|
|
|
434
385
|
function injectUltrafastPayload(
|
|
@@ -461,9 +412,10 @@ function injectFastPayload(
|
|
|
461
412
|
|
|
462
413
|
if (eligibility.provider === "anthropic") {
|
|
463
414
|
if ("speed" in payload) return undefined;
|
|
415
|
+
if (payload.betas !== undefined && !Array.isArray(payload.betas)) return undefined;
|
|
464
416
|
state.lastInjectedAt = Date.now();
|
|
465
417
|
state.lastInjectedModel = eligibility.modelKey;
|
|
466
|
-
return { ...payload, speed: ANTHROPIC_FAST_SPEED };
|
|
418
|
+
return { ...payload, speed: ANTHROPIC_FAST_SPEED, betas: withAnthropicFastBeta(payload.betas) };
|
|
467
419
|
}
|
|
468
420
|
|
|
469
421
|
if ("service_tier" in payload) return undefined;
|
|
@@ -552,12 +504,6 @@ export default function fastExtension(pi: ExtensionAPI) {
|
|
|
552
504
|
updateStatus(ctx, state);
|
|
553
505
|
});
|
|
554
506
|
|
|
555
|
-
pi.on("before_provider_headers", async (event, ctx) => {
|
|
556
|
-
const hasActiveTools =
|
|
557
|
-
typeof pi.getActiveTools === "function" && pi.getActiveTools().length > 0;
|
|
558
|
-
await injectAnthropicFastHeader(event.headers, ctx, getState(ctx), hasActiveTools);
|
|
559
|
-
});
|
|
560
|
-
|
|
561
507
|
pi.on("before_provider_request", (event, ctx) => {
|
|
562
508
|
const state = getState(ctx);
|
|
563
509
|
if (state.ultrafast) {
|
|
@@ -581,7 +527,8 @@ export default function fastExtension(pi: ExtensionAPI) {
|
|
|
581
527
|
});
|
|
582
528
|
|
|
583
529
|
pi.registerCommand("ultrafast", {
|
|
584
|
-
description:
|
|
530
|
+
description:
|
|
531
|
+
"Toggle session-only Ultrafast mode for direct OpenAI API-key GPT-6 Astra or GPT-6.1 Sol",
|
|
585
532
|
getArgumentCompletions: () => null,
|
|
586
533
|
handler: async (args, ctx) => {
|
|
587
534
|
if (args.trim()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diegopetrucci/pi-fast",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "A pi extension that enables Fast mode for supported direct OpenAI API, OpenAI Codex, and Anthropic Claude models based on the currently selected model.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|