Every Runflow project needs a main.ts file at the root that exports an async function main(). This is the function the Runflow engine calls when your agent receives a message:
main.ts
import { Agent, openai } from '@runflow-ai/sdk';import { identify } from '@runflow-ai/sdk/observability';const agent = new Agent({ name: 'My Agent', instructions: 'You are a helpful assistant.', model: openai('gpt-4o'),});export async function main(input: any) { identify(input.email || input.phone || 'anonymous'); const result = await agent.process({ message: input.message, sessionId: input.sessionId, }); return { message: result.message };}
# API ConfigurationRUNFLOW_API_URL=http://localhost:3001RUNFLOW_API_KEY=your_api_key_hereRUNFLOW_TENANT_ID=your_tenant_idRUNFLOW_AGENT_ID=your_agent_id# Execution Context (optional - usually comes from engine)RUNFLOW_EXECUTION_ID=exec_123RUNFLOW_THREAD_ID=thread_456# DevelopmentRUNFLOW_ENV=developmentRUNFLOW_LOCAL_TRACES=trueNODE_ENV=development
The SDK automatically searches for .runflow/rf.json in the current directory and parent directories.To make these values available as environment variables for external tools (Promptfoo, test runners, custom scripts), add: