Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/EllisYuan/ChatAgents/llms.txt

Use this file to discover all available pages before exploring further.

The ChatAgents backend is a FastAPI application that powers intelligent conversational agents built on LangGraph’s ReAct architecture and Tavily’s web-search tooling. It listens on port 8080 and exposes two distinct surface areas: a streaming inference endpoint (/stream_agent) for real-time agent responses, and a full CRUD REST API (/api/sessions/*) for managing conversation history. FastAPI automatically generates interactive API documentation, so you can explore and test every endpoint without writing any client code.

Base URL

EnvironmentBase URL
Local developmenthttp://localhost:8080
Docker (frontend → backend)http://backend:8080
Production (via Nginx)https://your-domain.com/api

Authentication

The streaming endpoint reads API keys from request headers at inference time. If a header is absent, the server falls back to the corresponding environment variable.
HeaderEnvironment VariableRequired For
X-Tavily-KeyTAVILY_API_KEYAll /stream_agent requests
X-Claude-KeyANTHROPIC_API_KEYClaude provider
X-OpenAI-KeyOPENAI_API_KEYOpenAI provider
X-Groq-KeyGROQ_API_KEYGroq provider
The session management API (/api/sessions/*) does not require any authentication headers. All CRUD operations on conversation history are open by default.

Endpoint Summary

MethodPathDescription
GET/Health check — returns server status
GET/healthHealth check used by the frontend container
POST/stream_agentRun the ReAct agent and stream NDJSON events
GET/api/sessionsList all sessions (metadata only)
GET/api/sessions/{session_id}Retrieve a single session with full message history
POST/api/sessionsCreate a new empty session
PUT/api/sessions/{session_id}Rename an existing session
DELETE/api/sessions/{session_id}Permanently delete a session

NDJSON Streaming Format

The /stream_agent endpoint returns Content-Type: application/json but delivers its body as newline-delimited JSON (NDJSON) — one complete JSON object per line. Clients should read the response body line-by-line and parse each line independently as it arrives. There are four event types that can appear in the stream: LLM token — a text chunk from the language model:
{"type": "chatbot", "content": "LangGraph is a library for building..."}
Tool begins — fired when a Tavily tool (search, extract, or crawl) starts executing:
{"type": "tool_start", "tool_name": "TavilySearch", "tool_type": "search", "operation_index": 0, "content": {"query": "LangGraph latest release"}}
Tool finishes — fired when the tool returns its results:
{"type": "tool_end", "tool_name": "TavilySearch", "tool_type": "search", "operation_index": 0, "content": "LangGraph 0.2 was released..."}
Error — emitted if an unrecoverable error occurs mid-stream:
{"type": "error", "content": "Generation failed: context length exceeded"}
The operation_index field is a monotonically increasing counter scoped to the current request — it lets you correlate each tool_start with its corresponding tool_end even if multiple tools run in the same session.

Auto-Generated API Docs

FastAPI automatically generates two interactive documentation UIs from the application’s route definitions and Pydantic models:
  • Swagger UIhttp://localhost:8080/docs — lets you try every endpoint directly in the browser
  • ReDochttp://localhost:8080/redoc — provides a clean, read-only reference layout
Both UIs stay in sync with the live code and require no manual maintenance.

Explore the API

POST /stream_agent

Stream real-time agent responses and tool call events over NDJSON. Supports Fast and Deep Thinking modes across Claude, OpenAI, and Groq.

Sessions API

CRUD endpoints for managing conversation sessions stored as JSON files on disk. List, create, retrieve, rename, and delete sessions.

Build docs developers (and LLMs) love