Skip to main content
The /agent/run endpoint streams AG-UI events over Server-Sent Events. The bundled chat UI uses it. Your scripts and integrations call the same endpoint.

Request shape

The body is an AG-UI RunAgentInput: parentRunId is optional, used when resuming a run. All seven required fields must be present (even when empty), or the endpoint returns 422 Unprocessable Entity.

Curl example

The response is an SSE stream (Content-Type: text/event-stream) of AG-UI events: RunStarted, TextMessageStart / Content / End, ToolCallStart / Args / End, ThinkingStart / End, RunFinished.

Structured-mode agents

If your LangGraph agent declares an explicit input_schema on the StateGraph that contains fields beyond messages, the engine auto-detects input.mode = "structured" and requires messages[-1].content to be valid JSON matching the input schema. The chat surface returns a RUN_ERROR SSE event with code: VALIDATION_ERROR if you send plain text. Example explicit-schema agent:
For this agent, the chat content must be JSON:
The bundled chat UI handles this auto-wrap. If you call /agent/run directly, build the JSON yourself.

Implicit-state agents (the common case)

When your agent declares one OverallState TypedDict with messages plus internal carry-fields and does not supply input_schema=, the engine resolves to input.mode = "chat". Plain-text content works as expected. The internal scalars (intent, draft, etc.) get populated by your nodes during the run.
For a strict typed public input contract, follow the explicit-schema idiom from LangGraph’s input/output schema how-to. Otherwise the implicit default keeps chat plain-text-friendly.

Reading the SSE stream

Every event line is data: <json>\n\n. Decode and dispatch on type. A minimal Python reader:
For TypeScript and React, use the AG-UI client SDK or the bundled chat UI hook. Both handle reconnects and token-level streaming for you.
Last modified on May 18, 2026