Skip to content

Chat completions

POST /v1/chat/completions is OpenAI-compatible. Authenticate with a Bearer key.

Request

bash
curl -sS -X POST "${PUBLIC_URL}/v1/chat/completions" \
  -H "Authorization: Bearer pzero_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama-3.3-70b",
    "stream": false,
    "messages": [{ "role": "user", "content": "Hello" }]
  }'
  • model: a model id from GET /v1/models.
  • stream: must be false or omitted; stream: true returns 400 in v1.
  • messages: standard OpenAI chat array.

Response

Standard OpenAI chat.completion object:

json
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "llama-3.3-70b",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "..." },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 5, "completion_tokens": 6, "total_tokens": 11 }
}

Headers

  • Success: X-Balance-Remaining, your confirmed USDC balance after the clear.
  • On 503: X-Pzero-Error-Code, X-Pzero-Buyer-Max-Cents, X-Pzero-Cheapest-Posted-Cents, X-Pzero-Routable-Diem-Above-Max.

Behind the request

The router picks the cheapest eligible offer at or below your max price, forwards once, meters the capacity burn, and settles with the 10% platform fee. One completion is one clear. See The router.

Errors

See Errors & limits for 401, 402, 404, 429, 500, 502, and 503.

Frontier First Inference. Minimum 20% off.