Skip to main content

Introduction

LibreChat provides a comprehensive REST API for managing conversations, messages, agents, files, and more. All API endpoints are prefixed with /api and require authentication.

Base URL

All API requests should be made to:
http://localhost:3080/api
For production deployments, replace localhost:3080 with your domain.

Authentication

LibreChat supports two authentication methods:
  • JWT Authentication: Session-based authentication using JWT tokens (recommended for web applications)
  • API Keys: Token-based authentication for programmatic access
See the Authentication page for detailed information.

API Endpoints

LibreChat’s API is organized into the following categories:

Core Resources

  • Conversations - Manage chat conversations, titles, and archives
  • Messages - Create, retrieve, and update messages within conversations
  • Users - User account management and settings

AI Features

  • Agents - Create and manage AI agents with custom capabilities
  • Presets - Save and load conversation presets
  • Prompts - Manage prompt libraries and prompt groups

Files & Media

  • Files - Upload, download, and manage file attachments

Configuration

Authentication

  • Auth - Login, registration, password reset, and 2FA

Rate Limiting

Most endpoints implement rate limiting to prevent abuse:
  • IP-based limits: Applied per IP address
  • User-based limits: Applied per authenticated user
  • Special limits: File uploads, imports, and message endpoints have specific rate limits
Rate limit responses include:
{
  "error": "Too many requests",
  "message": "Rate limit exceeded. Please try again later."
}

Error Handling

The API uses standard HTTP status codes:
Status CodeDescription
200Success
201Created
204No Content
400Bad Request
401Unauthorized
403Forbidden
404Not Found
500Internal Server Error
Error responses follow this format:
{
  "error": "Error type",
  "message": "Human-readable error message"
}

Pagination

Many list endpoints support cursor-based pagination:
GET /api/convos?limit=25&cursor=abc123
limit
number
default:"25"
Number of results to return
cursor
string
Pagination cursor from previous response
Paginated responses include:
{
  "conversations": [...],
  "pageNumber": 1,
  "pageSize": 25,
  "pages": 5
}
Many endpoints support filtering and search:
GET /api/convos?search=machine%20learning&tags=important
GET /api/messages?conversationId=abc123&search=keyword

WebSocket Connections

For real-time features, LibreChat uses Server-Sent Events (SSE) for streaming responses:
GET /api/agents/chat/stream/:streamId
See the Agents documentation for streaming details.

SDK Support

LibreChat provides TypeScript type definitions in packages/data-provider:
import { TConversation, TMessage } from 'librechat-data-provider';

API Versioning

Some endpoints support versioning:
  • /api/agents/v1/* - Agent API v1
  • /api/assistants/v1/* - Assistants API v1
  • /api/assistants/v2/* - Assistants API v2

Health Check

GET /health
Returns the health status of the API server.

Next Steps

Build docs developers (and LLMs) love