Skip to Content
AgentPress is finally here! šŸŽ‰
Configuring the API

Configuring the API

The Agent Press API is the backbone of your agent infrastructure. This guide covers starting and configuring the API server.

Starting the API Server

The API server is extremely simple to start:

// apps/api/src/index.ts import { startServer } from "@agentpress/api"; import path from "path"; const paths = { agents: path.resolve("../../packages/custom/src/agents"), tools: path.resolve("../../packages/custom/src/tools"), }; startServer({ agentsPath: paths.agents, toolsPath: paths.tools, seedAdminUser: true, });

Configuration Options

  • agentsPath - Path to your custom agents directory
  • toolsPath - Path to your custom tools directory
  • seedAdminUser - Creates an admin user on first startup

Running the Server

# Development (from project root) bun dev # Production cd apps/api && bun start

The server automatically discovers and loads your custom agents and tools from the specified paths.

Custom Authentication

You can provide custom authentication handlers when starting the server:

startServer({ agentsPath: paths.agents, toolsPath: paths.tools, customLogin: async (params) => { // Validate credentials against your system const { username, password } = params; // Return user data or Error return { username, password }; }, customRegister: async (params) => { // Handle user registration const { username, password, firstName, lastName } = params; return { username, password, firstName, lastName, role: EUserRole.USER }; }, customPasswordValidator: (password) => { // Custom password validation rules return { isValid: password.length >= 8, errors: ["Too short"] }; }, });

Function Parameters

  • customLogin(params) - Receives the request body with user credentials
  • customRegister(params) - Receives the request body with registration data
  • customPasswordValidator(password) - Receives the password string to validate

Return Types

  • customLogin - Returns { username, password } or Error
  • customRegister - Returns user object with role: EUserRole or Error
  • customPasswordValidator - Returns { isValid: boolean, errors: string[] }
Last updated on