Skip to main content

theo.complete(request)

Sends a prompt through the full orchestration pipeline and returns the complete response.
const res = await theo.complete({
  prompt: "Explain microservices architecture",
  mode: "auto",           // or "fast", "think", "code", "research", etc.
  skills: ["deep-research"],
  conversation_id: "conv_abc123",  // optional — continue a conversation
  persona: { system_prompt: "You are a senior architect..." },
  tools: [/* inline tool definitions */],
  temperature: 0.7,
  max_iterations: 8,
  metadata: { source: "my-app" },
});

console.log(res.content);          // Generated text
console.log(res.model.label);      // "Theo Reason"
console.log(res.resolved_mode);    // "think"
console.log(res.tools_used);       // [{ name: "...", status: "success" }]
console.log(res.usage.cost_cents); // 0.15

CompletionRequest

FieldTypeRequiredDefaultDescription
promptstringThe prompt text
modeChatMode"auto"Execution mode
conversation_idstringContinue a conversation
skillsstring[]Skill slugs to activate
toolsToolDef[]Inline tool definitions
personaPersonaInput"theo"Persona override
temperaturenumberSampling temperature
max_iterationsnumber8Max agent loop iterations
streambooleanfalseEnable SSE streaming
model_overridesRecord<string, string>Override model per mode
metadataRecord<string, unknown>Custom metadata

theo.stream(request)

Returns an AsyncGenerator<StreamEvent> for real-time token delivery.
for await (const event of theo.stream({ prompt: "Write a poem" })) {
  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); break;
    case "done":  console.log("\nDone"); break;
  }
}

StreamEvent Types

TypeDataDescription
metaModel info, mode, skillsEmitted first
token{ token: string }Each generated token
toolTool call infoTool was invoked
artifactFile/image dataGenerated artifact
genui_metaComponent library infoGenUI mode metadata
doneFull response + usageFinal event
errorError detailsProcessing error