Endpoints
Create chat completion
Send a chat request through INFERVA.
Routes the request to a provider, generates the reply, charges the key owner and writes a settlement record.
Headers
AuthorizationstringrequiredBearer inf_sk_...
Content-Typestringrequiredapplication/json
Body
messagesarrayrequiredChat messages, each with role and content. content can be a string or an array of parts with text. The last 20 messages are used.
modelstringauto (default) routes to the cheapest active provider. Or pass a model id from GET /v1/models.
max_tokensintegerMaximum output tokens. Defaults to and is capped at 1,024.
Response
idstringRequest id, also the settlement record id.
modelstringThe model id that served the request.
choicesarrayOne choice with the assistant message.
usageobjectprompt_tokens, completion_tokens, total_tokens. The charge is based on total_tokens.
inferva.providerstringName of the provider that served the request.
inferva.tierstringThe payer's tier at the time of the request.
inferva.prioritybooleanWhether the request was flagged priority (Tier 2 and above).
inferva.cost_usdgnumberTotal charged: provider cost minus discount plus protocol fee.
inferva.breakdownobjectprovider_cost, discount, protocol_fee, to_stakers, to_sponsor, to_treasury, in USDG.
inferva.capacitystringThe sponsored capacity position that served the request.
inferva.epochintegerThe epoch the request settled in.
inferva.settlementobjecthash of this record and prev_hash of the record before it. See Settlement log.
curl https://dapp.inferva.xyz/v1/chat/completions \
-H "Authorization: Bearer $INFERVA_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "auto", "messages": [{"role": "user", "content": "Hello"}]}'{
"id": "req_4b1f0c9a7e2d58a13c6f",
"object": "chat.completion",
"created": 1794182523,
"model": "basalt-70b",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "Hello! How can I help?" },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 12, "completion_tokens": 38, "total_tokens": 50 },
"inferva": {
"provider": "Basalt Inference",
"priority": false,
"tier": "No tier",
"cost_usdg": 0.000099,
"breakdown": {
"provider_cost": 0.00009,
"discount": 0,
"protocol_fee": 0.000009,
"to_stakers": 0.000004,
"to_sponsor": 0.000003,
"to_treasury": 0.000002
},
"capacity": "cap_9e41d2a07b3c",
"epoch": 498384,
"settlement": {
"hash": "a3c9…e217",
"prev_hash": "5d02…9b4f"
}
}
}