TheDocumentation 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.
/stream_agent endpoint is the heart of ChatAgents. It accepts a user message along with session and model configuration, runs the LangGraph ReAct agent with Tavily web-search tooling, and streams the result back as a sequence of newline-delimited JSON (NDJSON) events. Clients receive LLM tokens as they are generated, plus lifecycle events for every tool call the agent makes — giving the UI everything it needs to render a live, step-by-step response. Once the stream completes, the full conversation turn is automatically persisted to disk under the supplied thread_id.
Endpoint
Request Headers
Your Tavily API key. Required for all requests — the agent cannot perform web searches without it. Falls back to the
TAVILY_API_KEY environment variable if the header is absent.Your Anthropic API key. Required when
llm_provider is "claude". Falls back to ANTHROPIC_API_KEY.Your OpenAI API key. Required when
llm_provider is "openai". Falls back to OPENAI_API_KEY.Your Groq API key. Required when
llm_provider is "groq". Falls back to GROQ_API_KEY.Must be
application/json.Request Body
The user’s message or question. This is passed directly to the LangGraph ReAct agent as a
HumanMessage.A UUID that identifies the conversation session. LangGraph uses this value as the
thread_id for its MemorySaver checkpointer, enabling multi-turn context across requests. After the stream ends, the session is saved to data/sessions/<thread_id>.json.The reasoning mode for this request. Accepted values:
"fast"— uses Tavilybasicsearch depth, fetches up to 3 results, excludes images. Optimised for speed and lower cost."deep"— uses Tavilyadvancedsearch depth, fetches up to 5 results, includes images. More thorough but takes longer and costs more.
The language model provider to use for agent reasoning. Accepted values:
"claude", "openai", "groq".The model name within the chosen provider. Accepted values by provider:
| Provider | Accepted values |
|---|---|
claude | "haiku", "sonnet", "opus" |
openai | "gpt-5.1", "gpt-5-mini", "gpt-5-nano", "gpt-5", "gpt-4.1-nano" |
groq | Pass the Groq model identifier directly |
Response
Content-Type:application/json
The response body is an NDJSON stream — one JSON object per line, delivered as the agent produces output. Parse each line independently as it arrives. Do not attempt to parse the entire body as a single JSON document.
Response Event Types
Discriminator field. One of
"chatbot", "tool_start", "tool_end", or "error".chatbot Event
Carries a text chunk from the language model. Concatenate all chatbot chunks in order to reconstruct the full assistant reply.
Always
"chatbot".A token or short sequence of tokens from the LLM output.
tool_start Event
Emitted when the agent begins invoking a Tavily tool. The content field contains the serialised tool input so the UI can show the query before results arrive.
Always
"tool_start".The LangChain tool class name, e.g.
"TavilySearch", "TavilyExtract", "TavilyCrawl".Simplified category derived from the tool name:
"search", "extract", or "crawl".Zero-based counter that increments with each completed tool call in the request. Pair this with
operation_index in the corresponding tool_end event to correlate start and end.The tool’s input arguments, serialised to strings for safe JSON transport.
tool_end Event
Emitted when a Tavily tool returns its result.
Always
"tool_end".The LangChain tool class name.
"search", "extract", or "crawl".Matches the
operation_index in the preceding tool_start event. The counter increments after tool_end is emitted.The tool’s output, serialised for safe JSON transport. For
TavilyExtract and TavilyCrawl, this is a summarised version of the raw content.error Event
Emitted if an unrecoverable error occurs during streaming. The stream ends immediately after this event.
Always
"error".A human-readable description of what went wrong.
Error Responses
| Status | Condition |
|---|---|
400 Bad Request | X-Tavily-Key header is missing and TAVILY_API_KEY env var is not set; or agent_type is not "fast" or "deep" |
401 Unauthorized | The supplied Tavily API key failed validation |
500 Internal Server Error | LLM instantiation failed (bad model name, wrong API key) or the LangGraph agent graph could not be built |
Examples
Fast Mode — Claude Sonnet
Streaming Response
Each line below is a separate NDJSON object delivered as the agent runs:Deep Thinking Mode — Claude Opus
Python Client
After the stream ends, the full conversation turn — user message and assistant reply — is automatically saved to
data/sessions/<thread_id>.json. If no session file exists for the given thread_id, a new one is created with a title auto-generated from the first message.