Deploy Mastra Durable Agents
Durable AI agents with resumable streams via Redis and Inngest.
Mastra Server
Just deployed
/data
Redis
Just deployed
/data
Inngest
Just deployed
Deploy and Host Mastra Durable Agents on Railway
Mastra is the open-source TypeScript framework for building AI agents and workflows. This template deploys a Mastra server that runs one research agent in four durability modes side by side: a plain Agent, a createDurableAgent with Redis-backed resumable streams, a createEventedAgent that adds fire-and-forget execution, and a createInngestAgent with full Inngest durable execution. Disconnect mid-stream, reconnect with the same runId and offset, and the stream resumes where it stopped.
About Hosting Mastra Durable Agents
The template provisions three services: the Mastra server, a Redis instance for the resumable stream cache, and an Inngest server for durable workflow execution. The Mastra server connects to Redis and Inngest over Railway's private network. Agent state and history persist in LibSQL on an attached volume. The Inngest service runs in dev mode and keeps its run state in the container, so a restart of that service drops runs that have not finished. Generate a public domain on the Mastra server and that URL serves both the REST API and Mastra Studio. Set one variable — your OpenAI API key — and deploy.
Common Use Cases
- Compare durability strategies for agent streaming before you commit to one
- Build chat UIs that survive tab refreshes, network drops, and server restarts
- Run long agent tasks in the background and observe them from any client
- Learn the Mastra durable agent APIs from a working reference
Dependencies for Mastra Durable Agents Hosting
- OpenAI API key (agent model)
Deployment Dependencies
Implementation Details
Reconnect to a running stream:
curl -X POST https://YOUR-DOMAIN.up.railway.app/api/agents/durable-research-agent/observe \
-H "Content-Type: application/json" \
-d '{"runId": "your-run-id", "offset": 5}'
Why Deploy Mastra Durable Agents on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Mastra Durable Agents on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
Mastra Server
leoisadev1/mastra-template-durable-agentsOPENAI_API_KEY
Redis
redis:8.2.1Inngest
inngest/inngest:v1.34.0