Seller HTTP API
A seller runs a gateway in front of an OpenAI-compatible model server. Its HTTP surface:
| Method and path | Purpose |
|---|---|
GET /.well-known/inference-marketplace.json |
The seller's signed listing |
GET /im/v1/capacity |
Signed capacity reports, one per route; ?route_id= selects one (A12) |
POST /v1/chat/completions |
OpenAI-compatible chat, streaming or not, admitted by a Hold |
GET /im/v1/requests/{request_id_hex}/receipt |
Re-fetch a receipt: {"receipt", "sig"}, or 404 not_found |
POST /im/v1/vouchers |
Submit a voucher with the receipts it covers |
Every error body is {"error": {"code": "<code>", "message": "<text>"}}. Any other path answers 404 not_found.
Listing
The listing is a signed JSON envelope under the seller's listing key, whose base58 form is seller_id.
{
"v": 1,
"seller_id": "<base58 listing key>",
"receipt_keys": [{ "key": "<base58>", "key_epoch": 0 }],
"routes": [{
"route_id": "<hex>",
"nonce": "<64 hex characters>",
"endpoint": "https://seller.example/v1/chat/completions",
"model_identity": {
"family": "…", "revision": "…", "quantization": "…",
"serving": { "engine": "…", "engine_version": "…", "gpu": "…", "gpu_count": 1, "max_concurrency": 8 }
},
"model_identity_id": "<hex>",
"schedule": { "v": 1, "…": "see Price schedule" },
"schedule_digest": "<hex>",
"policy": { "zdr": true, "region": ["…"] },
"settler": "<base58 seller_settler>",
"payout_token": "<base58 seller_payout_token>",
"receipt_key": "<base58>",
"key_epoch": 0
}]
}
model_identity_id = SHA256(jcs(model_identity))androute_id = SHA256(jcs({seller_id, endpoint, model_identity_id, nonce})). Verifiers recompute both (A4).endpointis anhttporhttpsURL whose path is exactly/v1/chat/completions, with no credentials, query or fragment.settlerandpayout_tokenare what a buyer's channel must name asseller_settlerandseller_payout_token; otherwise every Hold fails withwrong_seller.receipt_keyslists every receipt key a receipt may be signed under (A14).
Capacity
GET /im/v1/capacity returns a JSON array of signed documents, one per listed route, under the listing key:
{ "route_id": "<hex>", "in_flight": 2, "max_concurrency": 8, "headroom": 6, "queue_depth": 0, "observed_at": 1700000000 }
headroom = max_concurrency − in_flight, and 0 while the gateway drains (A35). The reference gateway always reports queue_depth: 0.
Chat completions
Send the OpenAI-compatible body with the four Hold headers (X-IM-Hold, X-IM-Hold-Sig, X-IM-Session, X-IM-Salt). The body must be a JSON object with a messages array; stream, if present, is a boolean. The reference gateway reads at most 2 MiB of body by default (413 beyond that) and fails an upload that stalls (408); neither creates a receipt.
Admission is described on the Hold page. Refusals are 402 with a Hold error code, 429 no_headroom when the route is full, and 503 ingress_busy when too many uploads are pending; the last two carry Retry-After: 1. None of these is billable.
Once admitted, the request always ends in a signed receipt:
- Non-streaming: the upstream response with
X-IM-Receipt: base64(receipt).base64(sig). - Streaming: Server-Sent Events, ending with
event: im_receiptand data{"receipt": "<base64>", "sig": "<base64>"}, then the gateway's owndata: [DONE]. - Failure after admission: an error status with
X-IM-Receipton the error response (see the chat outcomes on Error codes).
The gateway does not turn a non-streaming request into a streaming one (A26).
Vouchers
POST /im/v1/vouchers takes {"voucher", "sig", "receipts": [...]} (all base64) and answers {"ack": true, "settled_total": <integer>}. The checks are on the voucher page; refusals are 400 with a voucher error code. The seller's settler later redeems acknowledged vouchers on-chain in batches.
Draining
A gateway being replaced stops admitting: new chat requests get 503 gateway_draining with Retry-After: 1, before any claim, so the same Hold can be re-sent to another process serving the route. Admitted streams run to completion and their receipts persist before the process exits (A35).