Hosted Gateway
Call B3IQ hosted OpenAI-compatible endpoints with gateway keys, own-account routing, receipts, and streaming metadata.
The hosted gateway exposes OpenAI-compatible HTTP endpoints backed by B3IQ router policy. Inference is free: your keys route to the machines on your own account, the gateway enforces customer policy and quotas, and it records receipt metadata without storing raw prompts or outputs in the control plane.
Use https://b3iq.org/v1/api as the public gateway base URL for application
traffic.
The endpoints below are also reachable through the official openai
Python/JavaScript SDK with a base_url/api_key swap — no raw HTTP required.
See the OpenAI SDK Quickstart.
Endpoints
| Method | Path | Purpose |
|---|---|---|
| GET | /v1/api/models | List models — the public network-wide catalog anonymously, or only the models your machines serve when called with your gateway key |
| GET | /v1/api/stats | Read public aggregate network stats without auth |
| GET | /v1/api/pricing | Read legacy settlement-policy metadata without auth (inference itself is unbilled) |
| POST | /v1/api/chat/completions | Run a hosted OpenAI-compatible chat completion through B3IQ route policy |
| GET | /v1/api/receipts/{receipt_hash} | Read public-safe receipt evidence |
Embeddings, image generation, audio, and rerank are OpenAI-compatible endpoints on the local host-agent API when your machine's runtime serves that modality. The hosted gateway facade above is chat-only today.
The model field takes an id returned by GET /v1/api/models. Called with
your gateway key, that list is exactly the models the machines on your
account serve right now — anything on it can dispatch, and anything missing
would fail with no_eligible_nodes. The examples below use a representative
id (qwen3-8b); always list the live models first, since the set changes as
your machines come and go.
List Models
bash: "${B3IQ_GATEWAY_BASE_URL:?set B3IQ_GATEWAY_BASE_URL}"cfg="$(mktemp)"chmod 600 "$cfg"trap 'rm -f "$cfg"' EXIT{ printf 'url = "%s/models"\n' "${B3IQ_GATEWAY_BASE_URL%/}"} > "$cfg"curl --fail --silent --show-error --config "$cfg"
/v1/api/models has two views. Anonymous calls return the public network-wide
catalog: models with at least one live, route-eligible profile on a public
machine. Calls that send a valid customer-owned gateway key
return only the models the machines on that account serve right now — the
key's node scope is respected, any machine you've switched to Earn mode is
excluded, and the account's model and route-tier policy still filters the
result. The key-scoped list is served uncached, so it always reflects the
current state of your machines.
Public Stats And Pricing
bashcurl --fail --silent --show-error "${B3IQ_GATEWAY_BASE_URL%/}/stats"curl --fail --silent --show-error "${B3IQ_GATEWAY_BASE_URL%/}/pricing"
These metadata endpoints do not require a gateway key and do not expose customer identity, prompts, outputs, raw tokens, node-local URLs, or private routes.
Chat Completion
bash: "${B3IQ_GATEWAY_BASE_URL:?set B3IQ_GATEWAY_BASE_URL}": "${B3IQ_GATEWAY_KEY_FILE:?set B3IQ_GATEWAY_KEY_FILE}"cfg="$(mktemp)"chmod 600 "$cfg"trap 'rm -f "$cfg"' EXIT{ printf 'url = "%s/chat/completions"\n' "${B3IQ_GATEWAY_BASE_URL%/}" printf 'request = "POST"\n' printf 'header = "Authorization: Bearer %s"\n' "$(sed -n '1p' "$B3IQ_GATEWAY_KEY_FILE")" printf 'header = "Content-Type: application/json"\n'} > "$cfg"curl --fail --silent --show-error --config "$cfg" --data-binary @- <<'JSON'{ "model": "qwen3-8b", "messages": [{ "role": "user", "content": "Say hello from B3IQ." }], "max_tokens": 64}JSON
javascriptimport { readFileSync } from "node:fs";const baseURL = process.env.B3IQ_GATEWAY_BASE_URL;const token = readFileSync(process.env.B3IQ_GATEWAY_KEY_FILE, "utf8").trim();const response = await fetch(`${baseURL}/chat/completions`, { method: "POST", headers: { authorization: `Bearer ${token}`, "content-type": "application/json" }, body: JSON.stringify({ model: "qwen3-8b", messages: [{ role: "user", content: "Say hello from B3IQ." }], max_tokens: 64 })});console.log(await response.json());
The same endpoint can fan a prompt out to several models and return one
combined answer — attach a b3iq.mixture object. See
Mixture of Experts.
Streaming
Set stream: true to request SSE streaming. Hosted streaming proxies the
selected node stream while parsing final usage and b3iq.receipt_hash
metadata for usage metering and receipt settlement.
json{ "model": "qwen3-8b", "messages": [{ "role": "user", "content": "Stream a short response." }], "stream": true}
Routing And Policy
A request passes three gates, in order, before it runs:
- Key validity — the gateway key must be active, unexpired, and carry the required scope and a usable customer identity.
- Rate limits and quota — per-key and per-account rate limits, and the account's daily token quota (default uncapped), are enforced next.
- Own-account routing — the request dispatches only to a machine on your
account that is online and serving the requested model. When none can serve
it, the request fails closed with
no_eligible_nodes.
Hosted chat can also fail closed when the model or route tier is outside your policy, or when an incident control pauses a route class, node, or payout path.
See Errors for stable machine codes, and Usage & Quotas for metering, rate limits, and the token quota.
Headers
| Header | Direction | Description |
|---|---|---|
| Authorization | Request | Bearer hosted gateway key |
| Idempotency-Key | Request | Accepted for compatibility; requests are not currently deduplicated. |
| X-B3IQ-Router-Dispatch-Mode | Response | Routed response dispatch mode |
| X-B3IQ-Router-Node-ID | Response | Selected node ID when policy exposes it |
| X-B3IQ-Receipt-Hash | Response | Receipt hash returned by the selected node |
Customer-owned gateway keys carry account ownership and usage attribution. Do not also send raw customer headers with those keys unless an operator smoke path explicitly requires it.

