Skip to content

Agent Server

Cognipeer Agent Server ​

REST API infrastructure for AI agents. Register an agent once and get storage, authentication, streaming, and interactive API docs, without writing that plumbing yourself.

  • Package @cognipeer/agent-server
  • Storage PostgreSQL · MongoDB
  • Frameworks Express · Next.js · custom adapters

Register agents built with @cognipeer/agent-sdk directly, or bring an agent from any other library through a simple handler interface. Either way you get the same REST surface: conversations, messages, files, and streaming, backed by a storage provider that auto-migrates.

typescript
import express from 'express';
import {
  createAgentServer,
  createPostgresProvider,
  createExpressMiddleware,
} from '@cognipeer/agent-server';
import { createSmartAgent } from '@cognipeer/agent-sdk';

const storage = createPostgresProvider({
  connectionString: 'postgresql://user:pass@localhost:5432/mydb',
});

const agentServer = createAgentServer({
  basePath: '/api/agents',
  storage,
  swagger: { enabled: true, path: '/docs', title: 'My Agent API' },
});

const myAgent = createSmartAgent({ name: 'Assistant', model: myLLMModel, tools: [...] });
agentServer.registerSDKAgent('assistant', myAgent, { description: 'A helpful assistant' });

const app = express();
app.use(express.json());
await storage.connect();
app.use(createExpressMiddleware(agentServer));
app.listen(3000);

What it gives you ​

Agent SDK integration

Register agents created with @cognipeer/agent-sdk directly and expose them as REST APIs.

Custom handler support

Integrate agents from any library with a simple handler interface.

Multiple storage backends

Built-in PostgreSQL and MongoDB providers with auto-migration support.

Authentication

Token-based and JWT authentication with customizable providers.

SSE streaming

Real-time response streaming with Server-Sent Events.

Swagger UI

Automatic OpenAPI documentation with interactive Swagger UI.

File management

Built-in file upload and download with storage integration.

Framework agnostic

Works with Express, Next.js, and other frameworks via adapters.

The REST surface ​

MethodEndpointDescription
GET/agentsList all agents
GET/agents/:agentIdGet agent details
GET / POST/conversationsList / create conversations
GET / PATCH / DELETE/conversations/:idGet, update, or delete a conversation
GET / POST/conversations/:id/messagesList or send messages
POST/filesUpload file
GET/files/:fileIdGet file metadata
GET/files/:fileId/contentDownload file
DELETE/files/:fileIdDelete file

See REST Endpoints for the complete reference.

Where to go next ​

Studio · Pulse · Console · Agent SDK and more — the Cognipeer documentation hub