Hono

01 Prep

Prepare a Hono app for Anvia HTTP routes.

Use this path when Anvia will run behind a plain Hono server or a framework that exposes Hono routes.

1. Create a Hono Project

mkdir anvia-hono
cd anvia-hono
pnpm init
pnpm add hono @hono/node-server
pnpm add -D tsx typescript @types/node

2. Install Anvia

pnpm add @anvia/core @anvia/openai @hono/zod-validator zod

Install other provider packages when you need them:

pnpm add @anvia/anthropic @anvia/gemini @anvia/mistral

3. Add Environment Variables

Anvia clients use explicit constructor options.

OPENAI_API_KEY=sk_...

Read the value in server code:

const apiKey = process.env.OPENAI_API_KEY;

if (!apiKey) {
  throw new Error("OPENAI_API_KEY is required");
}

4. Choose File Boundaries

FilePurpose
src/ai/support-agent.tsProvider client, model, tools, and reusable agent
src/app.tsHono app and routes
src/server.tsNode server entry point

Hono handlers receive c.req, but they can also return standard Web Response objects. That makes Anvia streaming direct.

Next

Build the reusable agent in Setup Anvia. Read How Anvia Works for the SDK boundaries.