Framework Guides
Add Anvia agents to application frameworks without giving up your app boundaries.
These guides show how to move Anvia from a local script into real HTTP runtimes.
Each framework follows the same path:
| Step | Goal |
|---|---|
| 01 Prep | Create the project shape and install Anvia packages |
| 02 Setup Anvia | Build provider clients, models, tools, and agents in server-side modules |
| 03 Route Handler | Return a normal JSON response from a framework route |
| 04 Streaming | Return newline-delimited stream events from the same agent |
| 05 Tools and Context | Pass request-local auth, product data, and retrieval context safely |
| 06 Persistence | Store conversation history through your application storage |
| 07 Deploy | Check runtime, environment, and operational constraints |
| 08 Troubleshooting | Fix common framework and provider failures |
| 09 Human in the Loop | Add approvals, questions, and reviewer waits to framework routes |
| 10 Setup Tests | Test route handlers, streams, Studio wiring, and provider boundaries |
Start with the framework that owns your HTTP routes:
| Framework | Start here | Route shape |
|---|---|---|
| Next.js | Next.js Prep | App Router route.ts handlers |
| TanStack Start | TanStack Start Prep | createServerFn(...) and server routes |
| SvelteKit | SvelteKit Prep | +server.ts endpoint modules |
| Hono | Hono Prep | Plain Hono routes |
| Express | Express Prep | Router middleware and handlers |
| Fastify | Fastify Prep | Plugin routes and replies |
| NestJS | NestJS Prep | Modules, services, and controllers |
The Anvia runtime shape stays the same across every framework:
import { AgentBuilder } from "@anvia/core";
import { OpenAIClient } from "@anvia/openai";
const client = new OpenAIClient({ apiKey });
const model = client.completionModel("gpt-5.5");
export const supportAgent = new AgentBuilder("support", model)
.instructions("Answer support questions clearly.")
.defaultMaxTurns(3)
.build();For the underlying SDK concepts, read How Anvia Works, Creating Agents, Tools, Readable Streams, and Memory.
