Back to Mastra

Baseten | Models

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

2025-12-184.3 KB
Original Source

Baseten

Access 9 Baseten models through Mastra's model router. Authentication is handled automatically using the BASETEN_API_KEY environment variable.

Learn more in the Baseten documentation.

bash
BASETEN_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: "baseten/MiniMaxAI/MiniMax-M2.5"
});

// 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 Baseten documentation for details.

:::

Models

<ProviderModelsTable models={[ { "model": "baseten/deepseek-ai/DeepSeek-V3-0324", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 164000, "maxOutput": 131000, "inputCost": 0.77, "outputCost": 0.77 }, { "model": "baseten/deepseek-ai/DeepSeek-V3.1", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 164000, "maxOutput": 131000, "inputCost": 0.5, "outputCost": 1.5 }, { "model": "baseten/MiniMaxAI/MiniMax-M2.5", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 204000, "maxOutput": 204000, "inputCost": 0.3, "outputCost": 1.2 }, { "model": "baseten/moonshotai/Kimi-K2.5", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 262144, "maxOutput": 8192, "inputCost": 0.6, "outputCost": 3 }, { "model": "baseten/nvidia/Nemotron-3-Super", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 262144, "maxOutput": 32678, "inputCost": 0.3, "outputCost": 0.75 }, { "model": "baseten/openai/gpt-oss-120b", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 128000, "maxOutput": 128000, "inputCost": 0.1, "outputCost": 0.5 }, { "model": "baseten/zai-org/GLM-4.6", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 200000, "maxOutput": 200000, "inputCost": 0.6, "outputCost": 2.2 }, { "model": "baseten/zai-org/GLM-4.7", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 204800, "maxOutput": 131072, "inputCost": 0.6, "outputCost": 2.2 }, { "model": "baseten/zai-org/GLM-5", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 202752, "maxOutput": 131072, "inputCost": 0.95, "outputCost": 3.15 } ]} />

Advanced configuration

Custom headers

typescript
const agent = new Agent({
  id: "custom-agent",
  name: "custom-agent",
  model: {
    url: "https://inference.baseten.co/v1",
    id: "baseten/MiniMaxAI/MiniMax-M2.5",
    apiKey: process.env.BASETEN_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
      ? "baseten/zai-org/GLM-5"
      : "baseten/MiniMaxAI/MiniMax-M2.5";
  }
});