Skip to main content

D.Run (China) logoD.Run (China)

Access 3 D.Run (China) models through Mastra's model router. Authentication is handled automatically using the DRUN_API_KEY environment variable.

Learn more in the D.Run (China) documentation.

.env
DRUN_API_KEY=your-api-key
src/mastra/agents/my-agent.ts
import { Agent } from "@mastra/core/agent";

const agent = new Agent({
id: "my-agent",
name: "My Agent",
instructions: "You are a helpful assistant",
model: "drun/public/deepseek-r1"
});

// Generate a response
const response = await agent.generate("Hello!");

// Stream a response
const stream = await agent.stream("Tell me a story");
for await (const chunk of stream) {
console.log(chunk);
}
info

Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the D.Run (China) documentation for details.

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
drun/public/deepseek-r1131K$0.55$2
drun/public/deepseek-v3131K$0.28$1
drun/public/minimax-m25205K$0.29$1
3 available models

Advanced Configuration
Direct link to Advanced Configuration

Custom Headers
Direct link to Custom Headers

src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "custom-agent",
name: "custom-agent",
model: {
url: "https://chat.d.run/v1",
id: "drun/public/deepseek-r1",
apiKey: process.env.DRUN_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});

Dynamic Model Selection
Direct link to Dynamic Model Selection

src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "dynamic-agent",
name: "Dynamic Agent",
model: ({ requestContext }) => {
const useAdvanced = requestContext.task === "complex";
return useAdvanced
? "drun/public/minimax-m25"
: "drun/public/deepseek-r1";
}
});
On this page