API Reference

Chat Completions

Create a model response. OpenAI-compatible — works with any OpenAI SDK by changing the base URL.

POST /v1/chat/completions

Request

Headers

HeaderRequiredDescription
AuthorizationBearer ngk_your_key
Content-Typeapplication/json

Body parameters

ParameterTypeRequiredDescription
modelstringModel ID or "auto" for smart routing
messagesarrayArray of message objects with role and content
max_tokensintegerMaximum tokens to generate
streambooleanEnable SSE streaming (default: false)
temperaturefloatSampling temperature 0–2
tierstringcheapest | balanced | fastest
privacy_modebooleanNever use cloud fallback
trusted_onlybooleanOnly trust_score > 0.8 hosters
max_latency_msintegerSkip hosters slower than N ms
fallback_modelsarrayOrdered fallback model IDs
allow_hostersarrayAllowlist of hoster UUIDs
deny_hostersarrayDenylist of hoster UUIDs

Example request

curl https://api.computeshare.servequake.com/v1/chat/completions \
  -H "Authorization: Bearer ngk_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain quantum entanglement briefly."}
    ],
    "max_tokens": 200
  }'

Response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1744502400,
  "model": "auto",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Quantum entanglement is a phenomenon where..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 28,
    "completion_tokens": 64,
    "total_tokens": 92
  }
}

Message roles

RoleDescription
systemInstructions for the model. Sets behavior and context.
userThe human's message.
assistantPrevious model responses (for multi-turn conversations).

Error codes

CodeMeaning
401Invalid or missing API key
402Insufficient credits or daily spend cap reached
429Rate limit exceeded. Check Retry-After header.
500Internal error — all hosters failed or upstream unavailable