Добавьте "stream": true в запрос /v1/chat/completions — ответ придёт потоком Server-Sent Events, по мере генерации текста.
curl -N https://tokventa.tech/v1/chat/completions \
-H "Authorization: Bearer ВАШ_API_КЛЮЧ" \
-H "Content-Type: application/json" \
-d '{"model":"qwen3.8-flash","messages":[{"role":"user","content":"Привет!"}],"stream":true}'data: {"id":"chatcmpl-…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":"Привет"},"finish_reason":null}]}
data: {"id":"chatcmpl-…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}
data: {"id":"chatcmpl-…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]Токены за запрос приходят в финальном чанке с usage, если передать "stream_options": {"include_usage": true}.
from openai import OpenAI
client = OpenAI(api_key="ВАШ_API_КЛЮЧ", base_url="https://tokventa.tech/v1")
stream = client.chat.completions.create(
model="qwen3.8-flash",
messages=[{"role": "user", "content": "Привет!"}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)import OpenAI from "openai";
const client = new OpenAI({ apiKey: "ВАШ_API_КЛЮЧ", baseURL: "https://tokventa.tech/v1" });
const stream = await client.chat.completions.create({
model: "qwen3.8-flash",
messages: [{ role: "user", content: "Привет!" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Базовый URL API: https://tokventa.tech/v1 · Каталог моделей · Цены · Получить ключ