theo.complete(request)
Sends a prompt through the full orchestration pipeline and returns the complete response.
CompletionRequest
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | string | ✅ | — | The prompt text |
mode | ChatMode | — | "auto" | Execution mode |
conversation_id | string | null | — | — | Continue a persisted conversation (null accepted) |
conversation | InlineConversation | — | — | Inline history envelope for stateless callers |
skills | string[] | — | — | Skill slugs to activate |
tools | ToolDef[] | — | — | Inline tool definitions |
persona | PersonaInput | — | "theo" | Persona override |
personality_config | PersonalityConfigInput | — | — | Trait intensities + uncensored mode override |
response_style | ResponseStyleInput | — | — | Format / preciseness / intent override |
theo_branding | boolean | — | — | false strips Theo personality/branding from this response |
brand_soul | boolean | — | — | false disables the API key’s Brand Soul for this request |
temperature | number | — | — | Sampling temperature |
max_iterations | number | — | 8 | Max agent loop iterations |
stream | boolean | — | false | Enable SSE streaming |
model_overrides | Record<string, string> | — | — | Override model per mode |
metadata | Record<string, unknown> | — | — | Custom metadata |
attachments | CompletionAttachment[] | — | — | Image attachments for vision analysis |
image_model | TheoImageEngine | — | — | Pin a Theo image sub-engine when mode resolves to image |
image_quality | TheoImageQuality | — | — | "draft" | "standard" | "hd" |
stealth_model | string | — | — | Pin a stealth model (stealth modes only) |
stealth_aspect | TheoStealthAspect | — | — | Stealth image aspect ratio |
stealth_duration | TheoStealthDuration | — | — | Stealth video duration |
null is accepted in place of any optional field and treated as the field being absent (matches OpenAI / Anthropic / Stripe behavior). |
CompletionResponse.usage
0. Use cost_cents as the sole usage metric on those modes.
theo.stream(request)
Returns a TheoStream — an async-iterable handle with a cancel() method plus final-metadata properties populated as events arrive.
TheoStream
| Member | Type | Description |
|---|---|---|
[Symbol.asyncIterator]() | AsyncIterator<StreamEvent> | Standard async iteration — works with for await |
cancel() | void | Abort the underlying HTTP connection; stops generation + billing |
isCancelled | boolean | true after cancel() has been called |
requestId | string | null | Server request id (from done event or X-Request-Id header) |
model | { id, label, engine } | null | Populated from the meta event |
resolvedMode | ChatMode | null | Mode after intent classification (from meta) |
conversationId | string | null | Populated from meta / done (null for stateless callers) |
usage | CompletionUsage | null | Populated from the done event |
content | string | Accumulated text content from token events |
StreamEvent (discriminated union)
switch (event.type) narrows event.data automatically.
event.type | event.data shape |
|---|---|
meta | StreamMetaData — id, mode, resolved_mode, model, tools, artifacts, brand?, routing?, conversation_id, request_id |
token | { token: string } — also exposed as event.token for convenience |
tool | { name, status, description? } |
artifact | Record<string, unknown> — shape varies by artifact type (image / video / document / code) |
skills | { active: Array<{ id, slug, name, intensity? }> } |
genui_meta | { library, tools[] } (GenUI mode only) |
done | StreamDoneData — id, content, follow_ups, structured_output?, skills_active?, routing?, usage, conversation_id, request_id |
error | { error: { message, type, code, request_id } } — matches the REST error envelope |
| See Streaming Completions (API reference) for the full wire format and a mid-stream 429 example. |
