Hono
easy5 minhono-server.ts
You want a small, fetch-based server that you can later move to an edge runtime.
What it shows
- Mount
cogitatorApp()as a Hono sub-app and serve it on Node with@hono/node-server
The code
hono-server.ts
import { Agent, Cogitator, calculator } from '@cogitator-ai/core';
import { cogitatorApp } from '@cogitator-ai/hono';
import { serve } from '@hono/node-server';
import { Hono } from 'hono';
const apiKey = process.env.GOOGLE_API_KEY;
if (!apiKey) throw new Error('Set GOOGLE_API_KEY');
const cog = new Cogitator({ llm: { providers: { google: { apiKey } } } });
const assistant = new Agent({
name: 'assistant',
description: 'General assistant with a calculator tool',
model: 'google/gemini-3.5-flash-lite',
instructions: 'You are a helpful assistant. Use tools when appropriate. Be concise.',
tools: [calculator],
temperature: 0.3,
});
const app = new Hono();
app.route('/cogitator', cogitatorApp({ cogitator: cog, agents: { assistant }, enableSwagger: false }));
serve({ fetch: app.fetch, port: 3102 }, () => console.log('Listening on http://localhost:3102/cogitator'));Run it
install · bash
pnpm add @cogitator-ai/core @cogitator-ai/hono @hono/node-server honoEnvironment
GOOGLE_API_KEYrun · bash
GOOGLE_API_KEY=your-key npx tsx hono-server.tsOr run the full example from a clone of the repository (keys in .env):
repository · bash
npx tsx examples/integrations/03-hono-server.tsTry it
Try it · bash
curl -X POST http://localhost:3102/cogitator/agents/assistant/run \
-H 'Content-Type: application/json' -d '{"input": "What is 123 * 456?"}'