API
Streaming
Set "stream": true and tokens arrive as server-sent events while the model writes, exactly like the OpenAI API.
stream = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Flash-0731",
messages=[{"role": "user", "content": "Write a haiku about rivers."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="", flush=True)const stream = await client.chat.completions.create({
model: "deepseek-ai/DeepSeek-V4-Flash-0731",
messages: [{ role: "user", content: "Write a haiku about rivers." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}curl -N https://api.laminarity.uk/v1/chat/completions \
-H "Authorization: Bearer $LAMINARITY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "deepseek-ai/DeepSeek-V4-Flash-0731", "stream": true,
"messages": [{"role": "user", "content": "Write a haiku about rivers."}]}'Event format
- Each event is a line
data: {…}with a chat completion chunk; the text is inchoices[0].delta.content. - The stream ends with
data: [DONE]. - Lines that start with a colon are keep-alive comments sent during long pauses. OpenAI SDKs skip them; custom parsers should too.
With curl use
-N so output is not buffered.