DIM · Dagon Inference Marketplace

The Bifrost reference adapter

Bifrost is an Apache-2.0, OpenAI-compatible AI gateway with request, routing, per-attempt and response hooks. DIM picked it as the first reference gateway adapter. The protocol stays gateway-neutral: Bifrost is not forked into the protocol, and its model catalog is discovery input, never a canonical model identity.

Status

Piece State
Adapter contract (what a Bifrost integration must do) Specified in docs/architecture/overview.md.
Native Bifrost plugin (adapters/bifrost in the repository layout) Not shipped. No plugin code is in the repository.
Bifrost as an upstream of the DIM gateway Works today with the shipped OpenAI adapter, as described below.

Until the plugin exists, the DIM gateway (services/gateway) is the only component that admits Holds, signs receipts and redeems vouchers.

What the native adapter must do

The architecture fixes five obligations for a Bifrost plugin:

  1. Resolve or validate the selected marketplace route before provider dispatch.
  2. Observe the final provider attempts, fallback outcome, usage, cost, latency and status.
  3. Produce exactly one canonical receipt for the client-visible request, however many provider attempts it took.
  4. Sign with a seller key kept outside Bifrost's configuration storage.
  5. Export metadata only, with content logging disabled globally and on every connector.

Native Go plugins give the per-attempt detail an accurate receipt needs, but they couple to Bifrost's Go version and dynamic build. The adapter contract therefore lives in this repository, and its packaging will be version-pinned and tested against supported Bifrost releases. The plugin may select a declared route and sign receipts; it may not redefine receipt hashing, prices or model identity.

Today: Bifrost behind the DIM gateway

Bifrost serves an OpenAI-compatible POST /v1/chat/completions (port 8080 by default) and accepts provider-prefixed model names such as openai/gpt-4o-mini. Point a route's OpenAI backend at it:

{ "kind": "openai", "url": "http://127.0.0.1:8080", "model": "openai/gpt-4o-mini" }

The DIM gateway keeps doing all payment work; Bifrost only routes the admitted request to a provider. Three rules keep the route honest:

  • One identity per route. A route promises one exact model identity. Configure Bifrost so the model name you pin cannot fall back to a different model or quantization. If Bifrost may route to several upstreams, you are publishing a pooled route: the architecture requires you to disclose the pool policy, and measurements apply to the pool, not to an implied fixed upstream. The MVP listing has no pool field, so describe the pool only if every member serves the identical identity.

  • Usage in streams. The gateway asks upstream for stream_options.include_usage and fails (charge 0) any stream that ends without a final usage chunk. Check your Bifrost and provider combination before listing:

    curl -sN http://127.0.0.1:8080/v1/chat/completions -H 'content-type: application/json' \
      -d '{"model":"openai/gpt-4o-mini","stream":true,"stream_options":{"include_usage":true},"messages":[{"role":"user","content":"ping"}]}'

    The last data frame before [DONE] must carry a usage object with prompt_tokens and completion_tokens.

  • No content retention. Bifrost keeps request logs in its own log store by default. If the route declares zdr: true, disable Bifrost's request logging so prompts and completions are not stored (policies).

Keep Bifrost on a private address. Anything that reaches it directly is served without a Hold.

Why not route payments through Bifrost now

A receipt must reflect the client-visible outcome, and admission must complete before the provider call. Doing that inside Bifrost needs the native hooks listed above. Running Bifrost as an upstream gets you its provider routing today with none of those guarantees moved out of the DIM gateway.