API Reference

Chat

POST /v1/chat/completions — generate a response from a language model given a list of messages.

Endpoint

http
POST https://api.satryx.ai/v1/chat/completions

Request parameters

ParameterTypeDescription
modelrequiredstringModel ID. See /v1/models for available options. Example: "llama-3.1-70b".
messagesrequiredarrayArray of message objects with "role" (system | user | assistant) and "content" (string).
streambooleanIf true, tokens are returned as SSE chunks. Default false.
temperaturenumberSampling temperature 0–2. Higher = more creative. Default 1.0.
max_tokensintegerMaximum tokens to generate. Model-dependent ceiling.
nintegerNumber of completions to generate. Default 1.
Note:The request shape is intentionally compatible with OpenAI's chat completions API. Most OpenAI client code works with no changes beyond the base URL and key.

Non-streaming request

curl
curl https://api.satryx.ai/v1/chat/completions \
  -H "Authorization: Bearer $SATRYX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama-3.1-70b",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain async/await in one paragraph."}
    ],
    "temperature": 0.7,
    "max_tokens": 512
  }'

Response

json
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1714000000,
  "model": "llama-3.1-70b",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Async/await is a syntactic pattern…"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 42,
    "completion_tokens": 87,
    "total_tokens": 129
  }
}

Streaming

Set "stream": true to receive tokens progressively over a server-sent events (SSE) connection. This dramatically reduces time-to-first-token for long responses.

curl
curl https://api.satryx.ai/v1/chat/completions \
  -H "Authorization: Bearer $SATRYX_API_KEY" \
  -H "Content-Type: application/json" \
  --no-buffer \
  -d '{
    "model": "llama-3.1-70b",
    "messages": [{"role": "user", "content": "Write a haiku about rain."}],
    "stream": true
  }'

Chunk format

text
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","model":"llama-3.1-70b","choices":[{"index":0,"delta":{"role":"assistant","content":"Async"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","model":"llama-3.1-70b","choices":[{"index":0,"delta":{"content":"/await"},"finish_reason":null}]}

data: [DONE]

Each data: line is a JSON object. The stream ends with data: [DONE]. Parse the choices[0].delta.content field to accumulate the full response.

Available models

ParameterTypeDescription
llama-3.1-70bchatDefault. Strong reasoning and instruction following. $0.20/$0.60 per Mtok in/out.
qwen3.6-35b-a3bchatEfficient multilingual model. $0.15/$0.45 per Mtok in/out.

Fetch the live model list with GET /v1/models.

Error responses

json
{
  "error": {
    "type": "invalid_request_error",
    "code": "missing_field",
    "message": "\"messages\" is required.",
    "param": "messages"
  }
}