Skip to main content

Nebius Token Factory logoNebius Token Factory

Access 20 Nebius Token Factory models through Mastra's model router. Authentication is handled automatically using the NEBIUS_API_KEY environment variable.

Learn more in the Nebius Token Factory documentation.

.env
NEBIUS_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: "nebius/MiniMaxAI/MiniMax-M3"
});

// 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);
}
note

Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the Nebius Token Factory documentation for details.

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
nebius/deepseek-ai/DeepSeek-V4-Flash-07311.0M$0.14$0.28
nebius/deepseek-ai/DeepSeek-V4-Pro1.0M$2$4
nebius/deepseek-ai/DeepSeek-V4-Pro-0813979K$1$4
nebius/deepseek-ai/DeepSeek-V4.1-Flash1.0M$0.30$1
nebius/google/gemma-3-27b-it110K$0.10$0.30
nebius/MiniMaxAI/MiniMax-M31.0M$0.30$1
nebius/moonshotai/Kimi-K2.7-Code262K$0.95$4
nebius/moonshotai/Kimi-K31.0M$3$15
nebius/NousResearch/Hermes-4-405B131K$1$3
nebius/nvidia/Nemotron-3_5-Lightning1.0M$0.06$0.24
nebius/nvidia/nemotron-3-super-120b-a12b262K$0.30$0.90
nebius/nvidia/Nemotron-3-Ultra-550b-a55b1.0M$1$3
nebius/openai/gpt-oss-120b131K$0.15$0.60
nebius/Qwen/Qwen3-235B-A22B-Instruct-2507262K$0.20$0.60
nebius/Qwen/Qwen3-30B-A3B-Instruct-2507262K$0.10$0.30
nebius/Qwen/Qwen3-Embedding-8B41K$0.01
nebius/Qwen/Qwen3.5-397B-A17B262K$0.60$4
nebius/zai-org/GLM-5.21.0M$1$4
nebius/zai-org/GLM-5.31.0M$1$4
nebius/zai-org/GLM-5.3-Flash1.0M$0.15$0.50
20 available models

Model availability, capabilities, context windows, and pricing are sourced from models.dev and may change.

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://api.tokenfactory.nebius.com/v1",
id: "nebius/MiniMaxAI/MiniMax-M3",
apiKey: process.env.NEBIUS_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
? "nebius/zai-org/GLM-5.3-Flash"
: "nebius/MiniMaxAI/MiniMax-M3";
}
});
On this page