Skip to main content
POST
/
v1
/
chat
/
completions
Create chat completion
curl --request POST \
  --url https://grid.x402compute.cc/v1/chat/completions \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "llama-3.2-3b",
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ],
  "temperature": 0.7,
  "max_tokens": 512,
  "stream": false
}
'
{
  "id": "<string>",
  "object": "chat.completion",
  "model": "<string>",
  "choices": [
    {
      "index": 123,
      "message": {
        "role": "<string>",
        "content": "<string>"
      },
      "finish_reason": "<string>"
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  }
}

Headers

X-API-Key
string

Compute/Grid API key (billed to prepaid credits). Omit to pay per request via x402 X-Payment.

Example:

"x402c_..."

Body

application/json
model
string
required
Example:

"llama-3.2-3b"

messages
object[]
required
Example:
[{ "role": "user", "content": "Hello" }]
temperature
number
Example:

0.7

max_tokens
integer
Example:

512

stream
boolean
default:false

Response

Completion (or SSE stream when stream=true)

id
string
object
string
Example:

"chat.completion"

model
string
choices
object[]
usage
object