Mastra is a TypeScript-first agent and workflow framework. Its createOpenAI-compatible provider setup lets you swap in OpenDunes as the inference backend in a single line.
npm install @mastra/core @ai-sdk/openai
import { createOpenAI } from "@ai-sdk/openai";
const opendunes = createOpenAI({
baseURL: "https://opendunes.com/api/v1",
apiKey: process.env.OPENDUNES_API_KEY,
});
Mastra uses the Vercel AI SDK under the hood for model calls, so the provider setup is identical to the Vercel AI SDK guide.
import { Mastra, Agent } from "@mastra/core";
import { createOpenAI } from "@ai-sdk/openai";
const opendunes = createOpenAI({
baseURL: "https://opendunes.com/api/v1",
apiKey: process.env.OPENDUNES_API_KEY,
});
const assistantAgent = new Agent({
name: "assistant",
instructions: "You are a helpful assistant that answers questions concisely.",
model: opendunes("anthropic/claude-opus-4.8"),
});
const mastra = new Mastra({ agents: { assistantAgent } });
const response = await mastra.getAgent("assistantAgent").generate(
"What is the currency used in Algeria?"
);
console.log(response.text);
const stream = await mastra
.getAgent("assistantAgent")
.stream("Describe the Sahara in three sentences.");
for await (const chunk of stream.textStream) {
process.stdout.write(chunk);
}
import { Mastra, Agent, createWorkflow, createStep } from "@mastra/core";
import { createOpenAI } from "@ai-sdk/openai";
import { z } from "zod";
const opendunes = createOpenAI({
baseURL: "https://opendunes.com/api/v1",
apiKey: process.env.OPENDUNES_API_KEY,
});
const summarizeStep = createStep({
id: "summarize",
inputSchema: z.object({ text: z.string() }),
outputSchema: z.object({ summary: z.string() }),
execute: async ({ context }) => {
const agent = new Agent({
name: "summarizer",
instructions: "Summarize the provided text in one sentence.",
model: opendunes("meta-llama/llama-4-maverick"),
});
const result = await agent.generate(context.inputData.text);
return { summary: result.text };
},
});
const workflow = createWorkflow({
id: "summarize-workflow",
inputSchema: z.object({ text: z.string() }),
outputSchema: z.object({ summary: z.string() }),
}).then(summarizeStep);
workflow.commit();
OPENDUNES_API_KEY=sk-your-key-here
Browse the full model catalog at /models or query GET /api/models.