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);
}
OpenAI Compatibility
Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the Nvidia documentation for details.
Models
| Model | Image | Audio | Video | Tools | Streaming | Context Window |
|---|---|---|---|---|---|---|
nvidia/moonshotai/kimi-k2-instruct | ✗ | ✗ | ✗ | ✓ | ✗ | 128,000 |
nvidia/nvidia/cosmos-nemotron-34b | ✓ | ✗ | ✓ | ✗ | ✗ | 131,072 |
nvidia/nvidia/parakeet-tdt-0.6b-v2 | ✗ | ✓ | ✗ | ✗ | ✗ | N/A |
nvidia/nvidia/nemoretriever-ocr-v1 | ✓ | ✗ | ✗ | ✗ | ✗ | N/A |
nvidia/nvidia/llama-3.1-nemotron-ultra-253b-v1 | ✗ | ✗ | ✗ | ✓ | ✗ | 131,072 |
nvidia/google/gemma-3-27b-it | ✓ | ✗ | ✗ | ✓ | ✗ | 131,072 |
nvidia/microsoft/phi-4-mini-instruct | ✓ | ✓ | ✗ | ✓ | ✗ | 131,072 |
nvidia/openai/whisper-large-v3 | ✗ | ✓ | ✗ | ✗ | ✗ | N/A |
nvidia/openai/gpt-oss-120b | ✗ | ✗ | ✗ | ✗ | ✗ | 128,000 |
nvidia/qwen/qwen3-235b-a22b | ✗ | ✗ | ✗ | ✓ | ✗ | 131,072 |
nvidia/qwen/qwen3-coder-480b-a35b-instruct | ✗ | ✗ | ✗ | ✓ | ✗ | 262,144 |
nvidia/deepseek-ai/deepseek-v3.1 | ✗ | ✗ | ✗ | ✓ | ✗ | 128,000 |
nvidia/black-forest-labs/flux.1-dev | ✗ | ✗ | ✗ | ✗ | ✗ | 4,096 |
Advanced Configuration
Custom Headers
const agent = new Agent({
name: "custom-agent",
model: {
url: "https://integrate.api.nvidia.com/v1",
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/qwen/qwen3-coder-480b-a35b-instruct"
: "nvidia/black-forest-labs/flux.1-dev";
},
});