Recipe 01
Streaming chat
Build an assistant UI that feels alive, with messages appearing as the model responds.
useAIChat({ stream: true })
Forgeon AI SDK gives you clean primitives for chat, streaming, structured output, tools, and gateway-ready AI routes — without turning your app into a bowl of spaghetti.
pnpm add @forgeon/ai
route.ts
liveconst result = await streamText({
route: "support-chat",
input: message,
})Assistant preview
Typed object
zod{
title: "Deployment Guide"
tags: ["ai", "deploy"]
ready: true
}
SDK modules
Field manual
Most AI features need the same annoying parts: stream handling, retries, loading states, tool calls, schema validation, and provider routing. The SDK wraps those pieces into primitives you can actually enjoy using.
Recipe 01
Build an assistant UI that feels alive, with messages appearing as the model responds.
useAIChat({ stream: true })
Recipe 02
Turn unpredictable model replies into validated objects your product can actually trust.
generateObject({ schema })
Recipe 03
Let AI call product actions like search, deploy, create, summarize, or query safely.
defineTool({ input, run })
streamText()
useAIChat()
defineTool()
gatewayRoute()
generateObject()
createAgent()
Primitive map
Treat the SDK like a toolbox, not a black box. Pick the primitive you need, compose it with your product flow, then let Forgeon carry the provider and gateway complexity behind the curtain.
@forgeon/ai
server primitives
@forgeon/ai/react
client hooks
@forgeon/ai/tools
typed tools
@forgeon/ai/gateway
gateway routes
Build sequence
Install the SDK
readyCreate an AI route
readyStream into UI
readyAdd typed output
readyConnect tools
readyShip with gateway control
readyapp/api/ai/route.ts
import { generateObject } from "@forgeon/ai"
import { z } from "zod"
export async function POST(req: Request) {
const { prompt } = await req.json()
const result = await generateObject({
route: "content-draft",
schema: z.object({
title: z.string(),
summary: z.string(),
nextSteps: z.array(z.string()),
}),
prompt,
})
return Response.json(result.object)
}Typed generation
Define the shape once, validate the response, and use predictable data in your UI. This is how AI features become product features, not fragile demos held together by hope and vibes.
AI SDK
Streaming UI, typed output, tool calls, gateway routes, and cleaner primitives for the apps you actually want to ship.
pnpm add @forgeon/ai