Export a handler function that takes event and context. We handle the rest.
Event-driven architecture with full context access
Your agent handler receives both event data and runtime context. Access to API keys, memory stores, vector databases, and more.
import { generateText } from 'ai'
export async function handler(evt: any, ctx: any) {
const { text } = await generateText({
model: 'openai/gpt-4',
prompt: `You are a helpful AI assistant.
Respond to: ${evt.input}`
})
return {
response: text,
metadata: {
model: 'gpt-4',
timestamp: new Date().toISOString()
}
}
}
Focus on your agent logic while we handle the infrastructure