@botinfra/sdk

Build any agent that runs on BotINFRA.

The SDK is a thin Node.js wrapper that implements the Agent Spec v1. Two endpoints. Streaming built in. SIGTERM drain handled. Ship in minutes.

Installation

npm install @botinfra/sdk

Quick start

import { Agent } from '@botinfra/sdk'

const agent = new Agent()

agent.onMessage(async ({ task }) => {
  const result = await myLLM.call(task)
  return { output: result }
}) 

agent.serve()  // listens on PORT env or 3000

The SDK automatically exposes GET /health and POST /message — the two endpoints required by Agent Spec v1.

Streaming

Use the stream helper to push tokens as they arrive. The SDK handles the SSE framing.

agent.onMessage(async ({ task, stream }) => {
  for await (const chunk of myLLM.stream(task)) {
    await stream.write(chunk)
  }
  return { done: true }
}) 

Dockerfile

FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 3000
CMD ["node", "index.js"]

API reference

new Agent(options?)

Creates a new agent instance.

options.portnumberHTTP port. Default: PORT env or 3000.
options.loggerbooleanEnable structured JSON logging. Default: true.
agent.onMessage(handler)

Register the message handler. Called for every POST /message.

handlerMessageHandlerAsync function receiving { task, context, stream }.
agent.serve()

Start the HTTP server. Registers SIGTERM handler for graceful drain.

Ready to deploy your agent?

Request pilot access →