Endpoint API
Chat Completions
Endpoint utama untuk menghasilkan respons dari model chat. Kompatibel penuh dengan format OpenAI.
Endpoint
text
POST https://api.siron.dev/v1/chat/completionsParameter
| Parameter | Tipe | Wajib | Keterangan |
|---|---|---|---|
model | string | Ya | ID model, mis. deepseek-v4-flash. |
messages | array | Ya | Daftar pesan dengan role dan content. |
temperature | number | Tidak | 0–2. Default 1. Makin tinggi makin acak. |
max_tokens | integer | Tidak | Batas token output. |
stream | boolean | Tidak | Kalau true, respons dikirim sebagai SSE. |
top_p | number | Tidak | Nucleus sampling, 0–1. |
Contoh request
bash
curl https://api.siron.dev/v1/chat/completions \
-H "Authorization: Bearer $SIRON_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [
{ "role": "system", "content": "Anda adalah asisten yang ramah." },
{ "role": "user", "content": "Jelaskan apa itu AI gateway." }
],
"temperature": 0.7,
"max_tokens": 512
}'Contoh response
json
{
"id": "chatcmpl-8f3k2",
"object": "chat.completion",
"created": 1787000000,
"model": "deepseek-v4-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "AI gateway adalah satu pintu API untuk mengakses banyak model..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 88,
"total_tokens": 112
}
}Untuk respons token-per-token, aktifkan
stream: true dan baca panduan Streaming.