React SDK Types
TypeScript interfaces and types exported by @tambo-ai/react
The @tambo-ai/react package exports TypeScript types and interfaces for building type-safe AI applications.
Thread Types
TamboThread
Represents a conversation thread with messages and metadata.
interface TamboThread {
id: string;
title?: string;
messages: TamboMessage[];
status: RunStatus;
metadata?: Record<string, unknown>;
createdAt: string;
updatedAt: string;
lastRunCancelled: boolean;
}RunStatus
The status of the current run in a thread.
type RunStatus = "idle" | "waiting" | "streaming" | "complete" | "error";| Status | Description |
|---|---|
idle | No generation in progress |
waiting | Waiting for server response |
streaming | Actively receiving streamed response |
complete | Generation finished successfully |
error | An error occurred |
StreamingState
Detailed streaming state returned by useTambo().
interface StreamingState {
status: RunStatus;
runId?: string;
messageId?: string;
startTime?: number;
error?: {
message: string;
code?: string;
};
}Message Types
TamboMessage
A message in a thread, containing an array of content blocks.
interface TamboMessage {
id: string;
role: MessageRole;
content: Content[];
createdAt?: string;
metadata?: Record<string, unknown>;
reasoning?: string[];
reasoningDurationMS?: number;
}| Property | Type | Description |
|---|---|---|
reasoning | string[] | Reasoning chunks from the model. Transient — only present during streaming, not persisted to the API. |
reasoningDurationMS | number | Duration of the reasoning phase in milliseconds, for display purposes. |
MessageRole
The role of a message sender.
type MessageRole = "user" | "assistant" | "system";Content Types
Messages contain an array of typed content blocks:
type Content =
| TextContent
| ComponentContent
| ToolUseContent
| ToolResultContent
| ResourceContent;TextContent
Plain text content.
interface TextContent {
type: "text";
text: string;
}ComponentContent
A rendered component with streaming state.
interface ComponentContent {
type: "component";
id: string;
name: string;
props: Record<string, unknown>;
streamingState?: "started" | "streaming" | "done";
renderedComponent?: ReactElement | null;
}The renderedComponent property contains the pre-rendered React element for the component, looked up from the registry.
ToolUseContent
A tool invocation with display metadata.
interface ToolUseContent {
type: "tool_use";
id: string;
name: string;
input: Record<string, unknown>;
hasCompleted?: boolean;
statusMessage?: string;
tamboDisplayProps?: TamboToolDisplayProps;
}The input object has internal _tambo_* properties automatically stripped.
Display messages are available via tamboDisplayProps.
TamboToolDisplayProps
Display properties extracted from tool inputs.
interface TamboToolDisplayProps {
_tambo_displayMessage?: string;
_tambo_statusMessage?: string;
_tambo_completionStatusMessage?: string;
}ToolResultContent
The result of a tool execution.
interface ToolResultContent {
type: "tool_result";
tool_use_id: string;
content: string | ContentPart[];
}ResourceContent
An MCP resource reference.
interface ResourceContent {
type: "resource";
uri: string;
name?: string;
mimeType?: string;
text?: string;
}Component Types
TamboComponent
Configuration for registering a component with Tambo.
interface TamboComponent {
name: string;
description: string;
component: ComponentType<any>;
propsSchema: Record<string, unknown>;
stateSchema?: Record<string, unknown>;
initialState?: () => Record<string, unknown>;
}Properties
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique identifier for the component |
description | string | Yes | Description for AI understanding |
component | ComponentType | Yes | The React component to render |
propsSchema | object | Yes | JSON Schema for component props |
stateSchema | object | No | JSON Schema for component state |
initialState | () => object | No | Factory function for initial state |
Example Registration
import { z } from "zod";
import { zodToJsonSchema } from "zod-to-json-schema";
const WeatherCardSchema = z.object({
city: z.string().describe("The city name"),
temperature: z.number().describe("Temperature in Fahrenheit"),
condition: z.string().describe("Weather condition"),
});
const components: TamboComponent[] = [
{
name: "WeatherCard",
description: "Displays current weather for a city",
component: WeatherCard,
propsSchema: zodToJsonSchema(WeatherCardSchema),
},
];TamboComponentProps
Props interface for components receiving Tambo data.
interface TamboComponentProps<TProps, TState> {
props: TProps;
state?: TState;
componentId: string;
isStreaming?: boolean;
}Tool Types
TamboTool
The same TamboTool interface from the base SDK is used.
interface TamboTool {
name: string;
description: string;
tool: (params: Record<string, unknown>) => unknown;
inputSchema: SupportedSchema;
outputSchema: SupportedSchema;
transformToContent?: (result: any) => Promise<ContentPart[]> | ContentPart[];
maxCalls?: number;
annotations?: ToolAnnotations;
}| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique identifier for the tool |
description | string | Yes | Description for AI understanding |
tool | function | Yes | The tool implementation function |
inputSchema | SupportedSchema | Yes | Schema for tool input parameters |
outputSchema | SupportedSchema | Yes | Schema for tool output |
maxCalls | number | No | Maximum times this tool can be called in a single response. Overrides the project-level tool call limit. |
annotations | ToolAnnotations | No | Behavior annotations (see ToolAnnotations) |
transformToContent | function | No | Transform tool result into content parts for richer display |
Event Types
TamboCustomEvent
Custom events emitted during streaming.
type TamboCustomEvent =
| ComponentStartEvent
| ComponentPropsDeltaEvent
| ComponentStateDeltaEvent
| ComponentEndEvent
| RunAwaitingInputEvent;ComponentStartEvent
Emitted when component rendering begins.
interface ComponentStartEvent {
name: "tambo.component.start";
componentId: string;
componentName: string;
}ComponentPropsDeltaEvent
Emitted when component props are updated (JSON Patch format).
interface ComponentPropsDeltaEvent {
name: "tambo.component.props_delta";
componentId: string;
delta: JsonPatchOperation[];
}ComponentStateDeltaEvent
Emitted when component state is updated (JSON Patch format).
interface ComponentStateDeltaEvent {
name: "tambo.component.state_delta";
componentId: string;
delta: JsonPatchOperation[];
}ComponentEndEvent
Emitted when component rendering completes.
interface ComponentEndEvent {
name: "tambo.component.end";
componentId: string;
}RunAwaitingInputEvent
Emitted when the run is waiting for tool execution.
interface RunAwaitingInputEvent {
name: "tambo.run.awaiting_input";
toolCalls: ToolCall[];
}Type Guards
Helper functions for working with events:
function isTamboCustomEvent(event: {
name?: string;
}): event is TamboCustomEvent;
function asTamboCustomEvent(event: CustomEvent): TamboCustomEvent | undefined;Input Types
SubmitOptions
Options passed to useTamboThreadInput().submit().
interface SubmitOptions {
debug?: boolean;
toolChoice?: ToolChoice;
}| Property | Type | Description |
|---|---|---|
debug | boolean | Enable debug logging for this submission |
toolChoice | ToolChoice | Control how the model selects tools (see below) |
ToolChoice
Controls how the model selects tools during generation.
type ToolChoice = "auto" | "required" | "none" | { name: string };| Value | Description |
|---|---|
"auto" | Model decides whether to use tools (default) |
"required" | Model must use at least one tool |
"none" | Model cannot use tools |
{ name: string } | Model must use the specified tool |
Stream Status Types
StreamStatus
Overall streaming status for a component, returned by useTamboStreamStatus().
interface StreamStatus {
isPending: boolean;
isStreaming: boolean;
isSuccess: boolean;
isError: boolean;
streamError?: Error;
}| Property | Type | Description |
|---|---|---|
isPending | boolean | No tokens received yet and generation is not active |
isStreaming | boolean | At least one prop is still streaming |
isSuccess | boolean | All props finished streaming without error |
isError | boolean | A fatal error occurred in the stream or any prop |
streamError | Error | The first error encountered during streaming |
PropStatus
Per-prop streaming status, returned by useTamboStreamStatus().
interface PropStatus {
isPending: boolean;
isStreaming: boolean;
isSuccess: boolean;
error?: Error;
}| Property | Type | Description |
|---|---|---|
isPending | boolean | No tokens received for this prop yet |
isStreaming | boolean | Tokens received but streaming is not complete |
isSuccess | boolean | This prop has finished streaming successfully |
error | Error | Error that occurred during streaming for this prop |
Tool Annotations
ToolAnnotations
Annotations describing a tool's behavior, extending the MCP specification.
type ToolAnnotations = MCPToolAnnotations & {
tamboStreamableHint?: boolean;
};| Property | Type | Description |
|---|---|---|
tamboStreamableHint | boolean | When true, the tool can be called with partially-streamed arguments as they arrive. Use for read-only tools without side effects. |
ToolAnnotations can be set on both TamboTool and TamboComponent via the annotations property.
Re-exported Types
The following types are re-exported from the base SDK for convenience:
Component & Tool Types
TamboComponent- Base component registration interfaceTamboTool- Tool definition interfaceComponentRegistry- Map of registered componentsParameterSpec- Parameter specification
Context Types
ContextHelpers- Collection of context helpersContextHelperFn- Context helper function signatureAdditionalContext- Additional context interface
MCP Types
MCPTransport- Transport type enumMcpServerInfo- MCP server configurationNormalizedMcpServerInfo- Processed server infoReadResourceResult- Resource read resultListResourceItem- Resource list itemResourceSource- Resource source interface
SDK Types
Suggestion- AI-generated suggestionSuggestionGenerateParams- Suggestion generation parametersSuggestionGenerateResponse- Suggestion generation response
Error Types
TamboAIError- Base error classAPIError- API errorRateLimitError- Rate limit error