Nebius 令牌工厂
🌐 Nebius Token Factory
通过Mastra的模型路由访问15个Nebius Token Factory模型。身份验证会自动使用NEBIUS_API_KEY环境变量处理。
🌐 Access 15 Nebius Token Factory models through Mastra's model router. Authentication is handled automatically using the NEBIUS_API_KEY environment variable.
在Nebius 令牌工厂文档中了解更多。
🌐 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/NousResearch/hermes-4-405b"
});
// 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 使用兼容 OpenAI 的 /chat/completions 端点。某些特定提供商的功能可能无法使用。详见 Nebius Token Factory 文档。
🌐 Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the Nebius Token Factory documentation for details.
模型Direct link to 模型
🌐 Models
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|---|---|---|---|---|---|---|---|---|
nebius/deepseek-ai/deepseek-v3 | 131K | $0.50 | $2 | |||||
nebius/meta-llama/llama-3_1-405b-instruct | 131K | $1 | $3 | |||||
nebius/meta-llama/llama-3.3-70b-instruct-base | 131K | $0.13 | $0.40 | |||||
nebius/meta-llama/llama-3.3-70b-instruct-fast | 131K | $0.25 | $0.75 | |||||
nebius/moonshotai/kimi-k2-instruct | 131K | $0.50 | $2 | |||||
nebius/NousResearch/hermes-4-405b | 131K | $1 | $3 | |||||
nebius/NousResearch/hermes-4-70b | 131K | $0.13 | $0.40 | |||||
nebius/nvidia/llama-3_1-nemotron-ultra-253b-v1 | 131K | $0.60 | $2 | |||||
nebius/openai/gpt-oss-120b | 131K | $0.15 | $0.60 | |||||
nebius/openai/gpt-oss-20b | 131K | $0.05 | $0.20 | |||||
nebius/qwen/qwen3-235b-a22b-instruct-2507 | 262K | $0.20 | $0.60 | |||||
nebius/qwen/qwen3-235b-a22b-thinking-2507 | 262K | $0.20 | $0.80 | |||||
nebius/qwen/qwen3-coder-480b-a35b-instruct | 262K | $0.40 | $2 | |||||
nebius/zai-org/glm-4.5 | 131K | $0.60 | $2 | |||||
nebius/zai-org/glm-4.5-air | 131K | $0.20 | $1 |
高级配置Direct link to 高级配置
🌐 Advanced Configuration
自定义头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/NousResearch/hermes-4-405b",
apiKey: process.env.NEBIUS_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});
动态模型选择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-4.5-air"
: "nebius/NousResearch/hermes-4-405b";
}
});