DoublewordDoubleword

Mastra

Mastra uses the Vercel AI SDK under the hood. Use @ai-sdk/openai-compatible to point it at the Control Layer.

Install

npm install mastra @mastra/core @ai-sdk/openai-compatible

Configure

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

const provider = createOpenAICompatible({
  name: "control-layer",
  baseURL: "https://api.doubleword.ai/v1",
  apiKey: "{{apiKey}}",
});

const agent = new Agent({
  name: "my-agent",
  instructions: "You are a helpful assistant.",
  model: provider("{{selectedModel.id}}"),
});

const result = await agent.generate("Say hello.");
console.log(result.text);

The baseURL is passed directly to the Vercel AI SDK provider. Use whatever model name is configured in your Control Layer.