Get started
Quickstart
Install sideagent, mount the agent on one route and render the chat in React.
On this page
Install the package:
npm i sideagent
Create the agent on your server and mount its handler on one route:
import { createAgent, honoHandler } from "sideagent/server";
const agent = await createAgent({
spec: "https://api.example.com/openapi.json",
baseUrl: "https://api.example.com",
llm: { baseUrl: "https://api.openai.com/v1", apiKey: process.env.LLM_API_KEY!, model: "gpt-4o-mini" },
allow: ["listInvoices", "createInvoice"],
allowedOrigins: ["https://app.example.com"],
getAuth: (req) => ({
userId: "user-123",
headers: { authorization: req.headers.get("authorization")! },
}),
});
app.on(["POST", "OPTIONS"], "/agent", honoHandler(agent));
Render the chat in your React app:
import { AgentChat } from "sideagent";
<AgentChat endpoint="/agent" mode="floating" />
Try it without an API key#
Clone the repo and run pnpm demo. It starts a fake invoices API, an agent with a mock LLM, and the UI.
Next steps#
- Tune the options: Server.
- Choose what the model may call: Operations and allowlist.
- Replace the hard-coded
userId: User authentication. - Skip the server: sideagent Cloud.