Streaming
Receive interaction output as Server-Sent Events
Set stream: true to receive the response incrementally as Server-Sent Events (SSE).
The gateway relays the model's native Interactions event stream unchanged, so you can
render output as it is produced and read final token usage from the terminal event.
The Interactions API is best supported on the Enterprise plan. Use
https://enterprise.blackbox.ai as the base URL.
Streaming Request
const response = await fetch('https://enterprise.blackbox.ai/v1/interactions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.BLACKBOX_API_KEY}`,
},
body: JSON.stringify({
model: 'gemini-3.8-flash',
input: 'List three uses for Redis.',
stream: true,
store: false,
}),
});
const reader = response.body!.getReader();
const decoder = new TextDecoder();
while (true) {
const { value, done } = await reader.read();
if (done) break;
for (const line of decoder.decode(value).split('\n')) {
if (!line.startsWith('data:')) continue;
const payload = line.slice(5).trim();
if (payload === '[DONE]') continue;
const event = JSON.parse(payload);
// event.type is e.g. "step.delta" or "interaction.completed"
console.log(event.type);
}
}import os
import json
import requests
with requests.post(
'https://enterprise.blackbox.ai/v1/interactions',
headers={
'Content-Type': 'application/json',
'Authorization': f"Bearer {os.environ['BLACKBOX_API_KEY']}",
},
json={
'model': 'gemini-3.8-flash',
'input': 'List three uses for Redis.',
'stream': True,
'store': False,
},
stream=True,
) as r:
for line in r.iter_lines():
if not line or not line.startswith(b'data:'):
continue
payload = line[5:].strip()
if payload == b'[DONE]':
break
event = json.loads(payload)
print(event.get('type'))curl -N https://enterprise.blackbox.ai/v1/interactions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $BLACKBOX_API_KEY" \
-d '{
"model": "gemini-3.8-flash",
"input": "List three uses for Redis.",
"stream": true,
"store": false
}'Event Stream
Each event arrives as an SSE data: line. Incremental text is delivered in
step.delta events; the final event carries the completed interaction and usage.
data: {"type":"step.delta","delta":{"type":"text","text":"Redis "}}
data: {"type":"step.delta","delta":{"type":"text","text":"is often used for "}}
data: {"type":"interaction.completed","interaction":{"status":"completed","usage":{"total_input_tokens":12,"total_output_tokens":48,"total_thought_tokens":30,"total_tokens":90}}}Read final token usage from the interaction.completed event
(interaction.usage). Interim step.delta events do not include usage.
Request Parameters
streambooleandefault: falseWhen true, the response is delivered as text/event-stream.
inputstring | arrayrequiredSame input shape as non-streaming requests.