packages/docs/examples-gallery/rest-apis.mdx
Build REST APIs for your elizaOS agents using your preferred TypeScript framework.
| Framework | Location | Features |
|---|---|---|
| Express | examples/rest-api/express/ | Most popular, middleware ecosystem |
| Hono | examples/rest-api/hono/ | Fast, small, edge-ready |
| Elysia | examples/rest-api/elysia/ | Bun-native, type-safe |
All implementations expose the same endpoints:
Agent information.
{
"name": "Eliza",
"bio": "A Rogerian psychotherapist simulation",
"status": "ready"
}
Health check.
{
"status": "healthy",
"runtime": "elizaos-typescript",
"uptime": 12345.67
}
Send a message.
Request:
{
"message": "I am feeling anxious",
"userId": "optional-user-id"
}
Response:
{
"response": "Tell me more about what's making you feel anxious.",
"character": "Eliza",
"userId": "550e8400-e29b-41d4-a716-446655440000"
}
| Framework | Language | Async | Type Safety | Bundle Size | Performance |
|---|---|---|---|---|---|
| Express | TS | ✅ | ⚠️ | Medium | Good |
| Hono | TS | ✅ | ✅ | Small | Excellent |
| Elysia | TS | ✅ | ✅ | Small | Excellent |
import express from "express";
import { AgentRuntime, ModelType } from "@elizaos/core";
import { elizaClassicPlugin } from "@elizaos/plugin-eliza-classic";
const app = express();
app.use(express.json());
const runtime = new AgentRuntime({
character: { name: "Eliza", bio: "A helpful AI." },
plugins: [elizaClassicPlugin],
});
await runtime.initialize();
app.post("/chat", async (req, res) => {
const { message } = req.body;
const response = await runtime.useModel(ModelType.TEXT_LARGE, {
prompt: message,
});
res.json({ response: String(response) });
});
app.listen(3000);
Replace the classic plugin with OpenAI for real LLM responses:
import { openaiPlugin } from "@elizaos/plugin-openai";
import { plugin as sqlPlugin } from "@elizaos/plugin-sql";
const runtime = new AgentRuntime({
character,
plugins: [sqlPlugin, openaiPlugin],
});