Skip to content

Chat and streaming

POST/v1/chat/completions

The main endpoint for text models. Its request and response format match OpenAI Chat Completions.

curl https://api-dev.satulink.ai/v1/chat/completions \
  -H "Authorization: Bearer $SATULINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v-4.1-flash",
    "messages": [{ "role": "user", "content": "Halo!" }],
    "max_tokens": 512
  }'

Request fields

FieldTypeDescription
modelstringRequired. The public model ID.
messagesarrayRequired. A list of messages with a role and content.
streambooleanOptional. true for an event-stream response.
max_tokensnumberOptional but recommended. Without it the provider uses the full context and a large amount of balance is reserved.
temperaturenumberOptional. Passed through to the provider.
top_pnumberOptional. Passed through to the provider.
stopstring / arrayOptional. Passed through to the provider.
toolsarrayOptional. See Tool calling.
tool_choicestring / objectOptional. Passed through to the provider.
response_formatobjectOptional. Passed through as-is.

Non-streaming response

200 OK
json
{
  "id": "chatcmpl-7c1a",
  "object": "chat.completion",
  "created": 1760000000,
  "model": "deepseek-v-4.1-flash",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Halo! Ada yang bisa dibantu?" },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 9,
    "total_tokens": 21,
    "prompt_tokens_details": { "cached_tokens": 0 },
    "cost_idr": 38
  }
}

finish_reason holds stop, length, tool_calls, function_call, or content_filter.

Streaming

POST/v1/chat/completions

With "stream": true, the response is text/event-stream. Each line is data: <json> and entries are separated by one blank line. There is no event: name, and the stream always closes with data: [DONE].

Chunk order

text/event-stream
bash
data: {"id":"chatcmpl-7c1a","object":"chat.completion.chunk","created":1760000000,"model":"deepseek-v-4.1-flash","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"id":"chatcmpl-7c1a","object":"chat.completion.chunk","created":1760000000,"model":"deepseek-v-4.1-flash","choices":[{"index":0,"delta":{"content":"Ha"},"finish_reason":null}]}

data: {"id":"chatcmpl-7c1a","object":"chat.completion.chunk","created":1760000000,"model":"deepseek-v-4.1-flash","choices":[{"index":0,"delta":{"content":"lo!"},"finish_reason":null}]}

data: {"id":"chatcmpl-7c1a","object":"chat.completion.chunk","created":1760000000,"model":"deepseek-v-4.1-flash","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: {"id":"chatcmpl-7c1a","object":"chat.completion.chunk","created":1760000000,"model":"deepseek-v-4.1-flash","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":9,"total_tokens":21,"cost_idr":38}}

data: [DONE]

A mid-stream failure arrives as data: {"error":{…,"code":"stream_error"}} followed by [DONE]. An error before the stream starts is still plain JSON with a normal HTTP status.

Reading a stream with the SDK

curl -N https://api-dev.satulink.ai/v1/chat/completions \
  -H "Authorization: Bearer $SATULINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v-4.1-flash",
    "messages": [{ "role": "user", "content": "Halo!" }],
    "stream": true
  }'

Still haven't found the answer? Try it directly in Playground or view the list of active models.