Chat Completions
Create a model response for a conversation. This endpoint is compatible with the OpenAI Chat Completions API.
POST https://api.setu.dwet.ai/v1/chat/completions
Request body
| Field | Type | Description |
|---|---|---|
model | string | ID of the model to use, e.g. sutra-v2-pro. |
messages | array | The conversation so far. Each item has a role (system, user, assistant) and content. |
stream | boolean | If true, partial deltas are sent as SSE. Default false. |
temperature | number | Sampling temperature between 0 and 2. Default 0.7. |
max_tokens | integer | Maximum tokens to generate in the response. |
Example request
bash
curl https://api.setu.dwet.ai/v1/chat/completions \
-H "Authorization: Bearer $SETU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "sutra-v2-pro",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain UPI in one line"}
],
"temperature": 0.7
}'Example response
json
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1782033025,
"model": "sutra-v2-pro",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "UPI is..." },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 97,
"total_tokens": 107
}
}Streaming response
With stream: true, the server emits chat.completion.chunk events terminated by a data: [DONE] line.
text
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"UPI "},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]See Models for available model IDs and SDKs for client examples.