@stablekernel/pi-bifrost 0.9.0 → 0.10.0

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 CHANGED
@@ -5,7 +5,7 @@ Pi extension that registers a [Bifrost](https://docs.getbifrost.ai) LLM gateway
5
5
  ## What it does
6
6
 
7
7
  - Registers two providers:
8
- - `bifrost-openai` — the OpenAI-compatible surface, every chat model the gateway serves.
8
+ - `bifrost-openai` — the OpenAI-compatible surface, every chat model the gateway serves. First-party OpenAI GPT models (not `gpt-oss`) are sent over the Responses API (`api: "openai-responses"` per model): gpt-6-class models reject chat completions through the gateway.
9
9
  - `bifrost-anthropic` — the Anthropic Messages surface, Claude models only. The Anthropic wire carries prompt-cache control blocks that only Claude accepts, so non-Claude models are registered on the OpenAI surface instead of being listed twice with one copy broken.
10
10
  - Fetches each surface's model list, limits and pricing through `gateway-cli models --wire=…` at startup — no catalog is checked in.
11
11
  - Seeds reasoning capability per model: catalog-flagged models register `reasoning: true`. On the OpenAI surface they also get a `thinkingLevelMap` translating pi's thinking levels to the model's effort values (unapplicable levels are hidden, never passed through by name) plus `supportsReasoningEffort`, so pi's per-request effort picker sends the provider's own values. On the Anthropic surface the capability is flagged and pi's Claude thinking handling applies. Toggle-only reasoning models get no effort map. The default effort itself is pi's own thinking-level default.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stablekernel/pi-bifrost",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Pi extension that registers the Bifrost gateway as a model provider, resolving per-project virtual keys via gateway-cli.",
5
5
  "type": "module",
6
6
  "files": [
package/src/index.ts CHANGED
@@ -51,6 +51,8 @@ type ProviderModelConfig = {
51
51
  string | null
52
52
  >
53
53
  >;
54
+ /** Per-model override of the provider's api; pi and omp both honor it. */
55
+ api?: "openai-responses";
54
56
  /** Provider/model compat flags pi reads. Only the subset this provider sets. */
55
57
  compat?: {
56
58
  supportsReasoningEffort?: boolean;
@@ -306,6 +308,12 @@ export function toPiModels(
306
308
  contextWindow: m.context_window,
307
309
  maxTokens: m.max_output_tokens,
308
310
  };
311
+ // gpt-6-class models reject every chat-completions request through the
312
+ // gateway ("use /v1/responses"; verified live 2026-10-22). Responses works
313
+ // for the whole first-party GPT family, so route all of it there.
314
+ if (api === "openai-completions" && OPENAI_GPT.test(m.id)) {
315
+ model.api = "openai-responses";
316
+ }
309
317
  if (reasoning) {
310
318
  const map = thinkingLevelMap(m.reasoning_efforts);
311
319
  if (api === "openai-completions") {
@@ -351,6 +359,10 @@ const PI_LEVELS = [
351
359
  "max",
352
360
  ] as const;
353
361
 
362
+ /** First-party OpenAI GPT ids ("openai/gpt-6.0", "bedrock/openai.gpt-6.1-sol"),
363
+ * not the open-weight gpt-oss line, which chat completions serves fine. */
364
+ const OPENAI_GPT = /(?:^|\/)openai[./]gpt-(?!oss)/;
365
+
354
366
  /**
355
367
  * Build a thinkingLevelMap from a model's advertised effort values. Each pi
356
368
  * level maps to the same-named provider value when the model accepts it, and
@@ -475,6 +475,54 @@ describe("reasoning", () => {
475
475
  });
476
476
  });
477
477
 
478
+ describe("responses routing", () => {
479
+ // gpt-6-class models 400 on chat completions ("use /v1/responses"), so
480
+ // first-party OpenAI GPT models ride the Responses API instead.
481
+ const GPT = (id: string): CliModel => ({
482
+ id,
483
+ name: id,
484
+ context_window: 400000,
485
+ max_output_tokens: 128000,
486
+ limits_source: "gateway",
487
+ reasoning: true,
488
+ reasoning_efforts: ["low", "medium", "high", "xhigh", "max"],
489
+ });
490
+
491
+ test("routes OpenAI GPT models to openai-responses", async () => {
492
+ const { toPiModels } = await import("./index.js");
493
+ const models = toPiModels(
494
+ {
495
+ models: [
496
+ GPT("bedrock/openai.gpt-6.1-sol"),
497
+ GPT("openai/gpt-6.0"),
498
+ ],
499
+ },
500
+ "openai-completions",
501
+ );
502
+ expect(models.map((m) => m.api)).toEqual([
503
+ "openai-responses",
504
+ "openai-responses",
505
+ ]);
506
+ // Effort levels still map: thinking control survives the API switch.
507
+ expect(models[0].thinkingLevelMap?.max).toBe("max");
508
+ });
509
+
510
+ test("leaves gpt-oss and other models on the provider's api", async () => {
511
+ const { toPiModels } = await import("./index.js");
512
+ const models = toPiModels(
513
+ {
514
+ models: [
515
+ GPT("bedrock/openai.gpt-oss-120b"),
516
+ GPT("fireworks/gpt-oss-120b"),
517
+ NOVA,
518
+ ],
519
+ },
520
+ "openai-completions",
521
+ );
522
+ expect(models.map((m) => m.api)).toEqual([undefined, undefined, undefined]);
523
+ });
524
+ });
525
+
478
526
  describe("gateway URL allowlist", () => {
479
527
  test("accepts TLS gateways and loopback, rejects everything else", async () => {
480
528
  const { isAllowedGatewayUrl } = await import("./index.js");