Chat completions
The OpenAI chat completions shape, metered and receipted.
Run / chat-completions
POST /v1/chat/completions takes the OpenAI request body. Point your client at the Provn base URL with a Provn key and leave the rest of your code alone.
Request
curl -i https://YOUR-PROVN-HOST/v1/chat/completions \
-H "Authorization: Bearer $PROVN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "provn",
"messages": [{ "role": "user", "content": "Name one prime number." }]
}'Response
HTTP/1.1 200 OK
content-type: application/json
x-provn-request-id: req_4tQ8...
x-provn-cost-micro-usd: 21
x-provn-receipt: eyJ...
x-provn-receipt-sig: 0x...
x-provn-receipt-signer: 0x...
{
"id": "chatcmpl-...",
"object": "chat.completion",
"model": "provn",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "7 is prime: its only divisors are 1 and 7." },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 12, "completion_tokens": 48, "total_tokens": 60 }
}Provn headers
| Header | Contents |
|---|---|
x-provn-request-id | The request id, repeated as request_id in the receipt. |
x-provn-cost-micro-usd | The amount debited, in millionths of a dollar. |
x-provn-receipt | The receipt payload as base64url-encoded JSON. |
x-provn-receipt-sig | The EIP-191 signature over the decoded payload. |
x-provn-receipt-signer | The signing address. Compare it with GET /v1/signer. |
Options
| Name | Where | Notes |
|---|---|---|
model | body | provn, provn-nano, or another id from GET /v1/models. |
stream | body | Set true for server-sent events. See Streaming. |
x-provn-run | header | A run id from POST /v1/runs. The receipt joins that run. |
Failures
A key at its cap gets 402 cap_reached, and Provn sends nothing upstream. An account whose balance can't cover the call gets 402 insufficient_balance. A model outside the key's allowlist gets 403 model_not_allowed. The Errors page covers the rest.