Integrations
Mastra
Mastra is a TypeScript framework for building AI agents. Connect it to DEVUP AI through @ai-sdk/openai-compatible.
Prerequisites
- Node.js
- A DEVUP AI API key from https://devupai.com/dashboard/api-keys.
Install
bash
npm install @mastra/core @ai-sdk/openai-compatible zodThe examples use top-level await; save them in a .mts file. Node.js 24 runs .mts files directly: node app.mts.
Set your API key
export DEVUP_API_KEY="your-key"Create an agent
typescript
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { Agent } from "@mastra/core/agent";
const devupai = createOpenAICompatible({
name: "devupai",
baseURL: "https://api.devupai.com/v1",
apiKey: process.env.DEVUP_API_KEY,
});
const agent = new Agent({
id: "assistant",
name: "Assistant",
instructions: "Be concise.",
model: devupai("deepseek-ai/DeepSeek-V4-Pro"),
});
const result = await agent.generate("Reply with exactly: Salam DEVUP");
console.log(result.text);Output: Salam DEVUP
Streaming
typescript
const stream = await agent.stream("Count from 1 to 5, separated by spaces.");
for await (const chunk of stream.textStream) {
process.stdout.write(chunk);
}
console.log();Output: 1 2 3 4 5
Tool calling
Define a tool with createTool and a zod schema, then pass it in tools.
typescript
import { createTool } from "@mastra/core/tools";
import { z } from "zod";
const getOrderStatus = createTool({
id: "getOrderStatus",
description: "Look up the delivery status of an order by its ID.",
inputSchema: z.object({ orderId: z.string() }),
execute: async ({ orderId }) => ({ orderId, status: "shipped" }),
});
const supportAgent = new Agent({
id: "support",
name: "Support",
instructions: "Answer order questions with the getOrderStatus tool.",
model: devupai("deepseek-ai/DeepSeek-V4-Pro"),
tools: { getOrderStatus },
});
const orderResult = await supportAgent.generate("What is the status of order A-100?");
console.log(orderResult.toolCalls.map((call) => call.payload.toolName), orderResult.text);The agent calls getOrderStatus and answers that order A-100 has shipped.
Structured output
Pass a zod schema as structuredOutput. jsonPromptInjection: true puts the schema in the prompt so the model returns the fields you asked for.
typescript
const city = await agent.generate("Which city is the capital of Algeria?", {
structuredOutput: {
schema: z.object({ name: z.string(), country: z.string() }),
jsonPromptInjection: true,
},
});
console.log(city.object);Output: { name: 'Algiers', country: 'Algeria' }
Choosing models
Use the exact catalog ID as the model name. Tool calling needs a model whose catalog entry supports it. See Models and Tool Calling.
Troubleshooting
- Authentication error (401)Set DEVUP_API_KEY in the same terminal that runs your script, without a Bearer prefix.
- Structured output fails validationSet jsonPromptInjection: true in structuredOutput. Without it the model is only asked for a JSON object and may choose its own keys.
- The agent answers without calling your toolModels can answer simple questions on their own. Use tools for data the model cannot know, and a model whose catalog entry supports tool calling.