Dio Provider, Creem Credits, and Kimi K2.6 Default
Summary
Add a reusable Dio provider module that makes dio the default web provider and kimi-k2.6 the default model, backed by https://bifrost.dio.computer through Bifrost virtual keys. Users without a Dio key see a purchase flow,
pay for one configured Creem credit bundle, and receive a Bifrost virtual key that is automatically stored as the dio provider key.
Use server-side Nitro routes for Creem and Bifrost secrets. Use Bifrost budgets as the credit enforcement layer. Use email-based recovery. Relevant docs checked: Creem checkout/webhooks and Bifrost virtual keys/OpenAI-
compatible gateway.
Key Changes
Add a local reusable module, web/src/dio-provider/, with browser/server-safe exports:
Add Dio to getSelectableModels() ahead of built-in cloud providers.
Change DEFAULT_MODEL in the web chat stream layer to DIO_DEFAULT_MODEL.
Store/retrieve Dio virtual keys through existing getAppStorage().providerKeys under provider name dio.
Ensure shouldProxyModel() proxies Dio requests through /api/chat-proxy, preserving the user’s Dio virtual key as bearer auth.
Add a Dio-specific key prompt path:
For provider dio, replace the generic “paste API key” dialog with “Buy Dio credits” and “Recover access by email”.
After successful checkout/claim, save the returned virtual key automatically and retry the pending model request.
Still allow manual key paste behind an advanced/disclosure affordance for development and support.
Payment and Provisioning Flow
Add Nitro routes:
POST /api/dio/checkout: creates a Creem checkout for the single configured product and stores a pending purchase record in useStorage("keating:dio").
POST /api/dio/webhook: verifies creem-signature, handles checkout.completed, ignores duplicate event IDs, validates product ID, creates or updates a Bifrost virtual key, and stores the entitlement by normalized
customer email.
User
.
User
.
User
status
Assistant
Implemented the Dio provider, made Kimi K2.6 the default web model, and wired the purchase/recovery flow through Bifrost virtual keys.
web/src/dio-provider/server.ts — server-only Creem/Bifrost helpers and entitlement persistence.
POST /api/dio/claim: accepts email plus checkout/purchase reference when available, returns the virtual key if the webhook has completed, otherwise returns pending.
POST /api/dio/recover: accepts email and returns the active virtual key for that email.
Include a name like keating::, description/metadata linking Creem event/order/product IDs, allowed model kimi-k2.6, and a budget max equal to the purchased credit amount.
Store returned virtual_key.id and virtual_key.value; only return value to the browser after a valid claim/recovery.
Local dev docs should mention export BIFROST_API_KEY="$(fnox get bifrost_api_key)"; never expose or fetch this key client-side.
Tests
Unit tests for Dio module constants and model shape: provider dio, model kimi-k2.6, base URL normalization, selectable model ordering, and default model selection.
Server route tests for checkout payload validation, webhook signature verification, duplicate webhook idempotency, product mismatch rejection, and claim/recovery pending/success states.
Mocked Bifrost tests verifying virtual-key request shape and that only virtual_key.value is sent to the client.
UI tests for Dio API-key prompt behavior: missing key opens purchase dialog, successful claim stores provider key, recovery by email stores provider key, manual key fallback still works.
Run rtk just test-web, rtk bun run typecheck in web/, and rtk just build-all after implementation.
Assumptions
V1 uses one Creem product configured by env, not hardcoded pricing or a live catalog.
Credits map directly to a Bifrost virtual-key budget; Keating does not maintain its own spend ledger.
Email is the durable account identifier; normalized lowercase email keys entitlements in Nitro storage.
The Bifrost gateway has or will have a routable model alias named exactly kimi-k2.6; if not, set a single module constant/env override during implementation without changing the public Dio provider interface.
Nitro useStorage("keating:dio") is acceptable for v1 persistence, matching the existing share-storage pattern. If the deployment storage is ephemeral, configure Nitro storage to a persistent backend before launch.
web/src/lib/provider-models.ts — Dio model is now first in getSelectableModels().
web/src/hooks/keating-stream.ts — DEFAULT_MODEL is now DIO_DEFAULT_MODEL.
web/src/lib/provider-proxy.ts — Dio requests are explicitly proxied through /api/chat-proxy.
web/src/components/DioAccessPromptDialog.tsx — Dio-specific prompt with buy credits, recover by email, and an advanced manual-key fallback.
web/src/components/KeatingApiKeyPromptDialog.tsx — routes provider dio to the Dio prompt.
web/server/api/dio/ — Nitro routes for checkout, webhook, claim, and recover.
web/nitro.config.ts — registered the four Dio routes.
web/src/test/dio-provider.test.ts — unit tests for provider/model shape, ordering, and proxy behavior.
web/test/dio-server.test.ts — server route tests for validation, webhook signature/idempotency/product mismatch, and claim/recover states with mocked Bifrost.
AGENTS.md — documented the Dio web environment variables and the fnox get bifrost_api_key local-dev note.
Verification
cd web && bun run typecheck — no errors.
cd web && bun test — 213 pass, 0 fail.
just test (root) — 231 pass, 0 fail.
just build-all — succeeded (root tsc + nitro web build).
The BIFROST_API_KEY is only used server-side; the browser never sees it. The virtual-key value is returned to the client only after a valid /api/dio/claim or /api/dio/recover call.