POST /v1/api/chat/completions
Hosted chat always selects eligible routes through B3IQ pooled-sync router policy. Direct node targeting and private-job payloads are rejected. Customer-owned `b3iq_gateway_` keys bill their owning customer directly; callers should not also send raw customer headers with those keys. `stream: true` requests pass selected-node SSE through. Customer-billed streaming parses final SSE usage and `b3iq.receipt_hash` metadata for billing/receipt settlement without storing prompts or outputs.

Authentication

Bearer Token (b3iq_gateway)

Header Parameters

Idempotency-Key string optional header
Optional for paid gateway requests. Stored only as a hash.
X-B3IQ-Customer-ID string optional header
Operator/bootstrap paid-smoke credential. Do not send with customer-owned gateway keys.
X-B3IQ-Customer-Token string optional header
Operator/bootstrap paid-smoke credential. Do not send with customer-owned gateway keys.

Request Body required

application/json
model string REQUIRED
messages object[] REQUIRED
Array of:
role string REQUIRED
Enum: system, user, assistant, tool
content unknown REQUIRED
max_tokens integer
temperature number
top_p number
stop unknown
stream boolean
n integer
B3IQ currently rejects `n > 1`.
b3iq object
Router policy metadata consumed by B3IQ and stripped before node dispatch.
model_profile_id string
job_id string
max_price_wei string
dispatch_mode string
Hosted chat rejects `private_job`.
Enum: pooled_sync
mixture object
Mixture of Experts: fan the prompt out to several expert models and return one combined answer. Experts run in parallel and each is routed through normal B3IQ policy; experts cannot pin nodes.
strategy string REQUIRED
synthesize combines expert answers with an aggregator model; vote returns the weighted-plurality answer; weighted returns the highest-weight successful expert answer.
Enum: synthesize, vote, weighted
experts object[] REQUIRED
Capped by an operator-configured limit (default 4 experts; the aggregator is not counted).
Array of:
model string REQUIRED
Model id from GET /v1/api/models.
weight number
Vote pooling / selection weight.
aggregator object
Required for the synthesize strategy; ignored otherwise.
model string REQUIRED
min_experts integer
Quorum of experts that must succeed. Defaults to half the experts, rounded up, for vote; otherwise 1.
max_price_wei string
Aggregate price cap across every sub-call (experts plus aggregator); checked before any node is dispatched.

Responses

200 Chat completion response, or SSE stream when `stream` is true and allowed.
application/json
id string REQUIRED
object string REQUIRED
created integer REQUIRED
model string REQUIRED
choices object[] REQUIRED
Array of:
usage object
prompt_tokens integer
completion_tokens integer
total_tokens integer
b3iq object
runtime_id string
runtime_kind string
latency_ms integer
ttft_ms integer
receipt_hash string
request_id string
mixture object
Present when the request carried b3iq.mixture. Metadata-only trace of the fan-out — never expert or aggregator text.
strategy string
degraded boolean
True when the mixture completed with a partial failure — one or more sub-calls did not succeed, or the synthesize aggregator failed and the answer fell back to the top-weighted surviving expert.
experts object[]
Array of:
role string
Enum: expert, aggregator
model string
status string
ok, no_node, upstream_error, billing_declined, or (defensively) error.
node_id string
usage object
total_tokens integer
default OpenAI-compatible error with B3IQ metadata.
curl -X POST 'https://{controlPlaneHost}/v1/api/chat/completions' \  -H 'Authorization: Bearer YOUR_API_TOKEN' \  -H 'Content-Type: application/json' \  -d '{  "model": "string",  "messages": [    {      "role": "system",      "content": "string"    }  ],  "max_tokens": 1,  "temperature": 0,  "top_p": 0,  "stop": "string",  "stream": false,  "n": 1,  "b3iq": {    "model_profile_id": "string",    "job_id": "string",    "max_price_wei": "string",    "dispatch_mode": "pooled_sync",    "mixture": {      "strategy": "synthesize",      "experts": [        {          "model": "string",          "weight": 1        }      ],      "aggregator": {        "model": "string"      },      "min_experts": 1,      "max_price_wei": "string"    }  }}'
const response = await fetch('https://{controlPlaneHost}/v1/api/chat/completions', {  method: 'POST',  headers: {      "Authorization": "Bearer YOUR_API_TOKEN",      "Content-Type": "application/json"  },  body: JSON.stringify({    "model": "string",    "messages": [      {        "role": "system",        "content": "string"      }    ],    "max_tokens": 1,    "temperature": 0,    "top_p": 0,    "stop": "string",    "stream": false,    "n": 1,    "b3iq": {      "model_profile_id": "string",      "job_id": "string",      "max_price_wei": "string",      "dispatch_mode": "pooled_sync",      "mixture": {        "strategy": "synthesize",        "experts": [          {            "model": "string",            "weight": 1          }        ],        "aggregator": {          "model": "string"        },        "min_experts": 1,        "max_price_wei": "string"      }    }  })});const data = await response.json();console.log(data);
200 Response
{  "id": "<string>",  "object": "<string>",  "created": 123,  "model": "<string>",  "choices": [    "<object>"  ],  "usage": {    "prompt_tokens": 123,    "completion_tokens": 123,    "total_tokens": 123  },  "b3iq": {    "runtime_id": "<string>",    "runtime_kind": "<string>",    "latency_ms": 123,    "ttft_ms": 123,    "receipt_hash": "<string>",    "request_id": "<string>",    "mixture": {      "strategy": "<string>",      "degraded": true,      "experts": [        {          "role": "expert",          "model": "<string>",          "status": "<string>",          "node_id": "<string>",          "usage": {            "total_tokens": {}          }        }      ]    }  }}
Ask a question... ⌘I