APIMaster.ai

Chat Completions

POST /v1/chat/completions request and response.

Chat Completions

Request

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

Headers

Header Required Notes
Authorization Yes Bearer YOUR_API_KEY
Content-Type Yes application/json

Body (common fields)

Field Type Notes
model string e.g. claude-sonnet-4-6
messages array {role, content}
max_tokens number Max completion tokens
temperature number Optional
stream boolean SSE streaming

Example

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

Non-streaming response

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

With "stream": true, the body is text/event-stream; lines are data: {json} until data: [DONE].

Status codes

Code Meaning
400 Bad parameters
401 Auth failed
402 / 403 Quota or permission
429 Rate limited
502 / 503 Upstream error — retry