All integrations

Mastra

Connect a Mastra agent to OpenUI over AG-UI and render its streamed output as typed interfaces.

How it connects to OpenUI

Mastra owns the agent and tools, the AG-UI transport serializes the run as SSE, and OpenUI's agUIAdapter drives the chat state and component renderer on the client.

Integration steps

  1. 1

    Build the Mastra agent

    Define the Agent with createTool tools and the generated OpenUI instructions. The example registers a custom Mastra gateway that routes model calls through OpenUI Cloud.

  2. 2

    Stream AG-UI events

    Wrap the agent with MastraAgent from @ag-ui/mastra in a server route and stream its AG-UI events to the browser as SSE.

  3. 3

    Connect your chat UI

    Create an llm with fetchLLM and agUIAdapter(), then pass it to AgentInterface for a ready-made chat app or to ChatProvider from @openuidev/react-headless for your own UI.