AI Features
Build AI-powered features with Vercel AI SDK and Agents
AI Features
Eden Stack includes a comprehensive AI suite built on Vercel AI SDK and Inngest AgentKit:
- @eden/ai - Lightweight wrapper for chat and completions
- @eden/agents - Advanced multi-agent systems with tool calling and durable execution
Simple Chat Completion
The @eden/ai package provides a unified interface for chat completions:
import { generateChatResponse } from "@eden/ai";
// Streaming response using default model (gpt-4o-mini)
const response = await generateChatResponse([
{ role: "user", content: "Hello, world!" }
]);
// Response is a streamText result from Vercel AI SDK
for await (const chunk of response.textStream) {
process.stdout.write(chunk);
}Required environment variable:
OPENAI_API_KEY=sk-...AI Routes in Elysia
Expose AI functionality to your frontend with streaming routes:
// apps/api/src/routes/ai.ts
import { Elysia, t } from "elysia";
import { generateChatResponse } from "@eden/ai";
export const aiRoute = new Elysia({ prefix: "/ai" })
.post("/chat", async ({ body }) => {
const { messages } = body;
return generateChatResponse(messages);
}, {
body: t.Object({
messages: t.Array(t.Object({
role: t.Union([t.Literal("user"), t.Literal("assistant")]),
content: t.String()
}))
})
});Agent Networks
For complex tasks requiring reasoning, planning, or external data, use @eden/agents:
Planning Network
Breaks down complex goals into executable steps:
import { createPlanningNetwork, runPlanningAgent } from "@eden/agents";
const network = createPlanningNetwork();
const result = await runPlanningAgent({
network,
goal: "Create a marketing plan for the product launch",
});
console.log(result.output);Research Network
Uses Exa's deep research API for comprehensive web search and analysis:
import { exaDeepResearch, exaSearch } from "@eden/agents/exa";
// Deep research - multi-step pipeline with citations
const research = await exaDeepResearch(
"Latest trends in React server components"
);
console.log(research.content); // Grounded report
console.log(research.sources); // Citation URLs
// Quick search - for simpler queries
const quick = await exaSearch("React 19 release notes");Additional environment variables for agents:
ANTHROPIC_API_KEY=sk-ant-...
EXA_API_KEY=...
TAVILY_API_KEY=tvly-...Durable Agents
For long-running tasks that shouldn't fail on server restart, integrate with Inngest:
import { inngest } from "@eden/jobs";
import { durablePlanningFunction } from "@eden/agents";
// Trigger a durable agent as a background job
await inngest.send({
name: "agents/planning.run",
data: {
goal: "Analyze competitor pricing strategies",
model: "gpt-4o"
}
});Durable agents store state and execution history, allowing them to run reliably for minutes or hours.
Next Steps
- Background Jobs - Run agents durably
- Packages - Explore all AI exports
Full documentation for Eden Stack users
This documentation is exclusively available to Eden Stack customers. Already purchased? Log in to access the full content.