APIMaster.ai

Chat Completions

Richiesta e risposta di POST /v1/chat/completions.

Chat Completions

Richiesta

POST https://apimaster.ai/v1/chat/completions

Intestazioni

Intestazione Obbligatorio Note
Authorization Bearer YOUR_API_KEY
Content-Type application/json

Corpo (campi comuni)

Campo Tipo Note
model stringa ad es. claude-sonnet-4-6
messages array {role, content}
max_tokens numero Token massimi di completamento
temperature numero Opzionale
stream booleano Streaming SSE

Esempio

curl -s "https://apimaster.ai/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [
      {"role": "system", "content": "You are helpful."},
      {"role": "user", "content": "Say hi in one word."}
    ],
    "max_tokens": 64
  }'

Risposta non in streaming

{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "..." },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 5,
    "total_tokens": 15
  }
}

Streaming

Con "stream": true, il corpo è text/event-stream; le righe sono data: {json} fino a data: [DONE].

Codici di stato

Codice Significato
400 Parametri errati
401 Autenticazione fallita
402 / 403 Quota o permesso
429 Limite di velocità superato
502 / 503 Errore upstream — riprova