Skip to main content
Mastra is a TypeScript-first agent framework built on the Vercel AI SDK. It works with any AI SDK-compatible model provider.
agent.ts
import { Agent } from "@mastra/core/agent"
import { createInterface } from "readline"

const agent = new Agent({
  name: "assistant",
  instructions: "You are a helpful assistant.",
  model: "openai/gpt-4o",
})

const rl = createInterface({ input: process.stdin })
rl.on("line", async (line) => {
  const result = await agent.generate(line)
  console.log(result.text)
})
package.json
{
  "dependencies": {
    "@mastra/core": "latest"
  }
}
superserve deploy agent.ts
superserve secrets set my-agent OPENAI_API_KEY=sk-...
superserve run my-agent
TypeScript agents are run with npx tsx automatically - no build step needed. Dependencies are installed from package.json.

See the full TypeScript example. Integrate deployed agents into your apps using the Superserve SDK.