inferva

Endpoints

Create chat completion

Send a chat request through INFERVA.

POST/v1/chat/completions

Routes the request to a provider, generates the reply, charges the key owner and writes a settlement record.

Headers

Authorizationstringrequired

Bearer inf_sk_...

Content-Typestringrequired

application/json

Body

messagesarrayrequired

Chat messages, each with role and content. content can be a string or an array of parts with text. The last 20 messages are used.

modelstring

auto (default) routes to the cheapest active provider. Or pass a model id from GET /v1/models.

max_tokensinteger

Maximum output tokens. Defaults to and is capped at 1,024.

Response

idstring

Request id, also the settlement record id.

modelstring

The model id that served the request.

choicesarray

One choice with the assistant message.

usageobject

prompt_tokens, completion_tokens, total_tokens. The charge is based on total_tokens.

inferva.providerstring

Name of the provider that served the request.

inferva.tierstring

The payer's tier at the time of the request.

inferva.priorityboolean

Whether the request was flagged priority (Tier 2 and above).

inferva.cost_usdgnumber

Total charged: provider cost minus discount plus protocol fee.

inferva.breakdownobject

provider_cost, discount, protocol_fee, to_stakers, to_sponsor, to_treasury, in USDG.

inferva.capacitystring

The sponsored capacity position that served the request.

inferva.epochinteger

The epoch the request settled in.

inferva.settlementobject

hash of this record and prev_hash of the record before it. See Settlement log.

Hashes in the example response are shortened. Real hashes are 64 hex characters.
Request
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"}]}'
Response · 200
{
  "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"
    }
  }
}
Was this page helpful?