Kryyt / Developers
Streaming Responses
Render content as it arrives without assuming that every chunk contains text.
POST /v1/chat/completionsPython
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.kryyt.com/v1",
api_key=os.environ["KRYYT_API_KEY"],
timeout=600,
max_retries=0,
)
stream = client.chat.completions.create(
model="deepseek-v4.1-flash",
messages=[{"role": "user", "content": "Write a short launch announcement."}],
max_tokens=512,
stream=True,
)
try:
for chunk in stream:
if chunk.choices:
text = chunk.choices[0].delta.content or ""
print(text, end="", flush=True)
if chunk.usage:
print("\nTokens:", chunk.usage.total_tokens)
finally:
stream.close()
client.close()Node.js
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.kryyt.com/v1",
apiKey: process.env.KRYYT_API_KEY,
timeout: 600_000,
maxRetries: 0,
});
const stream = await client.chat.completions.create({
model: "deepseek-v4.1-flash",
messages: [{role: "user", content: "Write a short launch announcement."}],
max_tokens: 512,
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}Wire format
Events are SSE data: lines separated by a blank line, ending with data: [DONE] when the provider completes normally. Usage may arrive without choices; tool-call deltas are not ordinary text deltas.
data: {"object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"}}]}
data: [DONE]
Interruptions and retries
A disconnected or timed-out stream may be incomplete. Retrying can generate a second answer and additional usage. Do not concatenate a fresh response onto the interrupted output automatically. Let the user retry, close abandoned streams, and preserve the original request context.
Kryyt sends Cache-Control: no-cache and disables its own stream buffering. Your application's reverse proxy must also allow long-lived, unbuffered responses.