Streaming
Tambahkan "stream": true untuk menerima teks sedikit demi sedikit (Server-Sent Events), diakhiri baris data: [DONE].
Dengan curl
Terminal
curl https://rumahaicloud.my.id/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-N -d '{"model": "deepseek-v4-flash", "stream": true,
"messages": [{"role": "user", "content": "Tulis puisi pendek."}]}'
Dengan Python
Python
import os
from openai import OpenAI
client = OpenAI(base_url="https://rumahaicloud.my.id/v1", api_key=os.environ["API_KEY"])
stream = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "Tulis puisi pendek."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
Masih bingung?
Lihat status layanan atau hubungi kami. Belum punya kunci? Buat akun.