Hono
Hono exposes a web Request, so you can call app.handler directly.
Server
// lib/better-agent/server.ts
import { betterAgent, defineAgent } from "@better-agent/core";
import { openai } from "@better-agent/openai";
const supportAgent = defineAgent({
name: "support",
model: openai("gpt-5.5"),
instruction: "You help customers.",
});
const app = betterAgent({
agents: [supportAgent],
basePath: "/api/agents",
});
export default app;Route
import { serve } from "@hono/node-server";
import { Hono } from "hono";
import app from "./lib/better-agent/server";
const server = new Hono();
server.all("/api/agents/*", (c) => app.handler(c.req.raw));
serve(server);CORS
Register CORS before the Better Agent route.
import { cors } from "hono/cors";
server.use(
"/api/agents/*",
cors({
origin: "http://localhost:3000",
allowMethods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"],
allowHeaders: ["Content-Type", "Authorization"],
}),
);Client
import { createClient } from "@better-agent/client";
import type app from "./lib/better-agent/server";
export const client = createClient<typeof app>({
baseURL: "http://localhost:3000/api/agents",
});Auth and headers
Headers from c.req.raw are forwarded to Better Agent. Use
Auth to resolve identity from cookies, bearer tokens, or
API keys.
Features
The mounted route supports runs, streams, threads, interrupts, client tools, and approvals. Use Client from your frontend to call it.
Next
See Client, Tools, Human in the Loop, Memory, Events, and Storage.