integrations/framework/Mastra
MA

Mastra + AIgateway

Agent framework — point models at the gateway, tools route automatically.

Mastra is a TypeScript agent framework. Use the @ai-sdk/openai provider with the AIgateway base URL and every model in our catalog becomes a Mastra-compatible agent brain.

Mastra homepage →
Setup

Three steps or fewer.

STEP 01

Wire the model

Use Mastra's Agent class with @ai-sdk/openai pointed at AIgateway.

import { Agent } from "@mastra/core/agent";
import { openai } from "@ai-sdk/openai";

const agent = new Agent({
  name: "researcher",
  model: openai("anthropic/claude-opus-4.7", {
    baseURL: "https://api.aigateway.sh/v1",
  }),
});
More integrations

Same key. Every other tool.