Back to Mastra

D.Run (China) | Models

docs/src/content/en/models/providers/drun.mdx

2025-12-182.6 KB
Original Source

D.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.

bash
DRUN_API_KEY=your-api-key
typescript
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

<ProviderModelsTable models={[ { "model": "drun/public/deepseek-r1", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 131072, "maxOutput": 32000, "inputCost": 0.55, "outputCost": 2.2 }, { "model": "drun/public/deepseek-v3", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 131072, "maxOutput": 8192, "inputCost": 0.28, "outputCost": 1.1 }, { "model": "drun/public/minimax-m25", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 204800, "maxOutput": 131072, "inputCost": 0.29, "outputCost": 1.16 } ]} />

Advanced configuration

Custom headers

typescript
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

typescript
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";
  }
});