Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/MotiaDev/motia/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The Motia class is the core class for building AI-powered applications with Motia. It manages steps, streams, and handles the registration of triggers and handlers.

Exports

Main Class

Motia

The main class for managing Motia applications.
class Motia {
  public streams: Record<string, Stream<unknown>>
  
  public addStep(
    config: StepConfig,
    stepPath: string,
    handler: StepHandler<unknown>,
    filePath: string
  ): void
  
  public addStream(config: StreamConfig, streamPath: string): void
  
  public initialize(): void
}
streams
Record<string, Stream<unknown>>
A dictionary of registered streams indexed by stream name.
Methods
addStep
function
Registers a step with its configuration and handler.
config
StepConfig
The step configuration defining name, triggers, and other settings.
stepPath
string
The path identifier for the step.
handler
StepHandler<unknown>
The handler function that processes step executions.
filePath
string
The file path where the step is defined.
addStream
function
Registers a stream with its configuration.
config
StreamConfig
The stream configuration.
streamPath
string
The path identifier for the stream.
initialize
function
Initializes the Motia instance, registering all configured triggers and handlers.

Helper Functions

getInstance

function getInstance(): IIIInstance
Returns the singleton instance of the III SDK.

initIII

function initIII(): void
Initializes the III SDK instance.

generateStepId

function generateStepId(stepName: string): string
Generates a unique identifier for a step.
stepName
string
The name of the step.
return
string
A unique step identifier.