@stablekernel/pi-bifrost
v0.7.0
Published
Pi extension that registers the Bifrost gateway as a model provider, resolving per-project virtual keys via gateway-cli.
Readme
@stablekernel/pi-bifrost
Pi extension that registers a Bifrost LLM gateway as a model provider, with per-project virtual-key resolution delegated to gateway-cli.
What it does
- Registers two providers:
bifrost-openai— the OpenAI-compatible surface, every chat model the gateway serves.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.
- Fetches each surface's model list, limits and pricing through
gateway-cli models --wire=…at startup — no catalog is checked in. - Seeds reasoning capability per model: catalog-flagged models register
reasoning: true. On the OpenAI surface they also get athinkingLevelMaptranslating pi's thinking levels to the model's effort values (unapplicable levels are hidden, never passed through by name) plussupportsReasoningEffort, 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. - Never holds the key: pi resolves it per request via the
!gateway-cli key printcommand form, so the per-project key cascade (environment override → project → user default) applies on every turn.
/bifrost-refresh
Reconciles the model list on demand, in pi and omp alike (one package, one implementation, one command):
- With
gateway-clionPATHit runsgateway-cli sync— the same reconcile as the background sync — and shows that command's own output. It rewrites the saved selection and the harness configs on disk. - Without it it asks the gateway directly:
$BIFROST_DISCOVERY_URL(or$BIFROST_GATEWAY_URL) with$BIFROST_VK, falling back to the key in~/.config/bifrost/keys/default.env. It then reports how many models the gateway offers and which are new or gone against the ids this session registered. This mode reports only — it writes nothing, and the key is never printed.
Either way the answer arrives as a notification, and any failure is one readable line rather than an error thrown into the session.
Restart the session to use a newly added model. Pi and omp build a provider's model list once, while the session starts, and neither can re-register one to a running session — so the report names the new models and says to restart, and nothing here fakes a reload.
Datasheet supplement (off by default)
Wildcard-provider models — e.g. a fresh Fireworks launch that the CLI's
models.dev source has not cataloged yet — never reach gateway-cli models,
so they cannot be listed here either. When configured, this extension also
reads the datasheet feed Bifrost itself syncs from and appends the
wildcard-provider ids the CLI list lacks; CLI-listed ids always win. Applies
to the OpenAI-compatible surface only; the Anthropic surface stays
Claude-only.
Activation (first wins):
- env
GATEWAY_DATASHEET_URL ~/.config/bifrost/datasheet.json—{"url": "..."}<project>/.gateway/datasheet.json— same shape
The URL must be https://; a source with anything else is treated as absent.
Behavior: the feed is fetched once per hour and cached under
~/.cache/gateway-bifrost/datasheet-cache.json (or $XDG_CACHE_HOME), with
a 3s hard timeout and a stale-cache fallback on failure. A failed first
fetch also triggers a background cache fill, so a slow or cold feed costs
one session rather than every start. Unconfigured or unreachable, the
supplement is silently skipped — startup never blocks on it.
Provenance: supplement-only models are tagged limits_source: "datasheet"
and cost_source: "datasheet" in the gateway-cli models payload they ride
in. The tags stop there — pi's provider config has no provenance field, so
they are not forwarded into the registered shapes.
Requirements
gateway-clionPATH(or theGATEWAY_CLI_BINenv var pointing at it), connected once withgateway-cli connect.
Without it nothing is registered — there is no credential to hand pi — but
/bifrost-refresh still reports the gateway's live list from the environment
(see above).
Install
pi install npm:@stablekernel/pi-bifrostWorks in omp (the Pi fork) too — its plugin loader accepts the same package and pi.extensions manifest:
omp plugin install npm:@stablekernel/pi-bifrostLicense
UNLICENSED — published for installation convenience; all rights reserved. Intended for use within the organization that operates the Bifrost gateway.
