Nvidia
Access 13 Nvidia models through Mastra’s model router. Authentication is handled automatically using the NVIDIA_API_KEY
environment variable.
Learn more in the Nvidia documentation .
NVIDIA_API_KEY=your-api-key
import { Agent } from "@mastra/core";
const agent = new Agent({
name: "my-agent",
instructions: "You are a helpful assistant",
model: "nvidia/black-forest-labs/flux.1-dev"
});
// 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);
}
Mastra uses the OpenAI-compatible /chat/completions
endpoint. Some provider-specific features may not be available. Check the Nvidia documentation for details.
Models
Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
---|---|---|---|---|---|---|---|---|
nvidia/moonshotai/kimi-k2-instruct | 128K | — | — | |||||
nvidia/nvidia/cosmos-nemotron-34b | 131K | — | — | |||||
nvidia/nvidia/parakeet-tdt-0.6b-v2 | — | — | — | |||||
nvidia/nvidia/nemoretriever-ocr-v1 | — | — | — | |||||
nvidia/nvidia/llama-3.1-nemotron-ultra-253b-v1 | 131K | — | — | |||||
nvidia/google/gemma-3-27b-it | 131K | — | — | |||||
nvidia/microsoft/phi-4-mini-instruct | 131K | — | — | |||||
nvidia/openai/whisper-large-v3 | — | — | — | |||||
nvidia/openai/gpt-oss-120b | 128K | — | — | |||||
nvidia/qwen/qwen3-235b-a22b | 131K | — | — | |||||
nvidia/qwen/qwen3-coder-480b-a35b-instruct | 262K | — | — | |||||
nvidia/deepseek-ai/deepseek-v3.1 | 128K | — | — | |||||
nvidia/black-forest-labs/flux.1-dev | 4K | — | — |
Advanced Configuration
Custom Headers
const agent = new Agent({
name: "custom-agent",
model: {
url: "https://integrate.api.nvidia.com/v1/chat/completions",
modelId: "black-forest-labs/flux.1-dev",
apiKey: process.env.NVIDIA_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});
Dynamic Model Selection
const agent = new Agent({
name: "dynamic-agent",
model: ({ runtimeContext }) => {
const useAdvanced = runtimeContext.task === "complex";
return useAdvanced
? "nvidia/black-forest-labs/flux.1-dev"
: "nvidia/deepseek-ai/deepseek-v3.1";
}
});