APIMaster.ai

Chat-Completions

POST /v1/chat/completions Anfrage und Antwort.

Chat-Completions

Anfrage

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

Header

Header Erforderlich Anmerkungen
Authorization Ja Bearer YOUR_API_KEY
Content-Type Ja application/json

Body (allgemeine Felder)

Feld Typ Anmerkungen
model Zeichenkette z. B. claude-sonnet-4-6
messages Array {role, content}
max_tokens Zahl Maximale Abschluss-Tokens
temperature Zahl Optional
stream Boolesch SSE-Streaming

Beispiel

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
  }'

Nicht-Streaming-Antwort

{
  "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

Mit "stream": true ist der Body text/event-stream; Zeilen sind data: {json} bis data: [DONE].

Statuscodes

Code Bedeutung
400 Ungültige Parameter
401 Authentifizierung fehlgeschlagen
402 / 403 Kontingent oder Berechtigung
429 Ratenbegrenzung
502 / 503 Upstream-Fehler – Wiederholen