Skip to main content
Theo supports streaming via Server-Sent Events (SSE) for real-time token delivery. Set stream: true on any completion request.

Event Types

EventDescription
metaModel info, resolved mode, active skills — emitted first
tokenA text chunk — emitted for each token as it’s generated
toolA tool was called — includes tool name, arguments, and status
artifactA generated file (image, document, code)
genui_metaGenUI component library info (genui mode only)
doneFinal event — includes full response with usage data
errorAn error occurred during processing

SDK Streaming

const stream = theo.stream({
  prompt: "Explain how TCP/IP works",
});

for await (const event of stream) {
  switch (event.type) {
    case "meta":
      console.log("Mode:", (event.data as any).resolved_mode);
      break;
    case "token":
      process.stdout.write(event.token!);
      break;
    case "tool":
      console.log("Tool:", (event.data as any).name, (event.data as any).status);
      break;
    case "done":
      console.log("\nCost:", (event.data as any).usage.cost_cents, "cents");
      break;
  }
}

Raw SSE (curl)

curl -N -X POST https://hitheo.ai/api/v1/completions \
  -H "Authorization: Bearer $THEO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Write a haiku about code", "stream": true}'
The response is a stream of SSE events:
event: meta
data: {"resolved_mode":"fast","model":{"id":"theo-1-flash","label":"Theo Flash"}}

event: token
data: {"token":"Lines"}

event: token
data: {"token":" of"}

event: token
data: {"token":" code"}

event: done
data: {"content":"Lines of code...", "usage": {"cost_cents": 0.01}}

E.V.I. Streaming

E.V.I. instances also support streaming:
const evi = theo.evi({
  persona: "You are Kai, a coding assistant...",
});

const stream = evi.stream({
  prompt: "Debug this React hook",
});

for await (const event of stream) {
  if (event.type === "token") {
    process.stdout.write(event.token!);
  }
}