# ![Nvidia logo](https://models.dev/logos/nvidia.svg)Nvidia

Access 75 Nvidia models through Mastra's model router. Authentication is handled automatically using the `NVIDIA_API_KEY` environment variable.

Learn more in the [Nvidia documentation](https://docs.api.nvidia.com/nim/).

```bash
NVIDIA_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: "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);
}
```

> **Info:** Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [Nvidia documentation](https://docs.api.nvidia.com/nim/) for details.

## Models

| Model                                                  | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
| ------------------------------------------------------ | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
| `nvidia/black-forest-labs/flux.1-dev`                  | 4K      |       |           |       |       |       | —          | —           |
| `nvidia/deepseek-ai/deepseek-coder-6.7b-instruct`      | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/deepseek-ai/deepseek-r1`                       | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/deepseek-ai/deepseek-r1-0528`                  | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/deepseek-ai/deepseek-v3.1`                     | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/deepseek-ai/deepseek-v3.1-terminus`            | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/deepseek-ai/deepseek-v3.2`                     | 164K    |       |           |       |       |       | —          | —           |
| `nvidia/google/codegemma-1.1-7b`                       | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/google/codegemma-7b`                           | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/google/gemma-2-27b-it`                         | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/google/gemma-2-2b-it`                          | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/google/gemma-3-12b-it`                         | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/google/gemma-3-1b-it`                          | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/google/gemma-3-27b-it`                         | 131K    |       |           |       |       |       | —          | —           |
| `nvidia/google/gemma-3n-e2b-it`                        | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/google/gemma-3n-e4b-it`                        | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/google/gemma-4-31b-it`                         | 256K    |       |           |       |       |       | —          | —           |
| `nvidia/meta/codellama-70b`                            | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/meta/llama-3.1-405b-instruct`                  | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/meta/llama-3.1-70b-instruct`                   | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/meta/llama-3.2-11b-vision-instruct`            | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/meta/llama-3.2-1b-instruct`                    | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/meta/llama-3.3-70b-instruct`                   | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/meta/llama-4-maverick-17b-128e-instruct`       | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/meta/llama-4-scout-17b-16e-instruct`           | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/meta/llama3-70b-instruct`                      | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/meta/llama3-8b-instruct`                       | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/microsoft/phi-3-medium-128k-instruct`          | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/microsoft/phi-3-medium-4k-instruct`            | 4K      |       |           |       |       |       | —          | —           |
| `nvidia/microsoft/phi-3-small-128k-instruct`           | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/microsoft/phi-3-small-8k-instruct`             | 8K      |       |           |       |       |       | —          | —           |
| `nvidia/microsoft/phi-3-vision-128k-instruct`          | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/microsoft/phi-3.5-moe-instruct`                | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/microsoft/phi-3.5-vision-instruct`             | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/microsoft/phi-4-mini-instruct`                 | 131K    |       |           |       |       |       | —          | —           |
| `nvidia/minimaxai/minimax-m2.1`                        | 205K    |       |           |       |       |       | —          | —           |
| `nvidia/minimaxai/minimax-m2.5`                        | 205K    |       |           |       |       |       | —          | —           |
| `nvidia/mistralai/codestral-22b-instruct-v0.1`         | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/mistralai/devstral-2-123b-instruct-2512`       | 262K    |       |           |       |       |       | —          | —           |
| `nvidia/mistralai/mamba-codestral-7b-v0.1`             | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/mistralai/ministral-14b-instruct-2512`         | 262K    |       |           |       |       |       | —          | —           |
| `nvidia/mistralai/mistral-large-2-instruct`            | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/mistralai/mistral-large-3-675b-instruct-2512`  | 262K    |       |           |       |       |       | —          | —           |
| `nvidia/mistralai/mistral-small-3.1-24b-instruct-2503` | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/moonshotai/kimi-k2-instruct`                   | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/moonshotai/kimi-k2-instruct-0905`              | 262K    |       |           |       |       |       | —          | —           |
| `nvidia/moonshotai/kimi-k2-thinking`                   | 262K    |       |           |       |       |       | —          | —           |
| `nvidia/moonshotai/kimi-k2.5`                          | 262K    |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/cosmos-nemotron-34b`                    | 131K    |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/llama-3.1-nemotron-51b-instruct`        | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/llama-3.1-nemotron-70b-instruct`        | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/llama-3.1-nemotron-ultra-253b-v1`       | 131K    |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/llama-3.3-nemotron-super-49b-v1`        | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/llama-3.3-nemotron-super-49b-v1.5`      | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/llama-embed-nemotron-8b`                | 33K     |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/llama3-chatqa-1.5-70b`                  | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/nemoretriever-ocr-v1`                   | —       |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/nemotron-3-nano-30b-a3b`                | 131K    |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/nemotron-3-super-120b-a12b`             | 262K    |       |           |       |       |       | $0.20      | $0.80       |
| `nvidia/nvidia/nemotron-4-340b-instruct`               | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/nvidia-nemotron-nano-9b-v2`             | 131K    |       |           |       |       |       | —          | —           |
| `nvidia/nvidia/parakeet-tdt-0.6b-v2`                   | —       |       |           |       |       |       | —          | —           |
| `nvidia/openai/gpt-oss-120b`                           | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/openai/whisper-large-v3`                       | —       |       |           |       |       |       | —          | —           |
| `nvidia/qwen/qwen2.5-coder-32b-instruct`               | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/qwen/qwen2.5-coder-7b-instruct`                | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/qwen/qwen3-235b-a22b`                          | 131K    |       |           |       |       |       | —          | —           |
| `nvidia/qwen/qwen3-coder-480b-a35b-instruct`           | 262K    |       |           |       |       |       | —          | —           |
| `nvidia/qwen/qwen3-next-80b-a3b-instruct`              | 262K    |       |           |       |       |       | —          | —           |
| `nvidia/qwen/qwen3-next-80b-a3b-thinking`              | 262K    |       |           |       |       |       | —          | —           |
| `nvidia/qwen/qwen3.5-397b-a17b`                        | 262K    |       |           |       |       |       | —          | —           |
| `nvidia/qwen/qwq-32b`                                  | 128K    |       |           |       |       |       | —          | —           |
| `nvidia/stepfun-ai/step-3.5-flash`                     | 256K    |       |           |       |       |       | —          | —           |
| `nvidia/z-ai/glm4.7`                                   | 205K    |       |           |       |       |       | —          | —           |
| `nvidia/z-ai/glm5`                                     | 203K    |       |           |       |       |       | —          | —           |

## Advanced configuration

### Custom headers

```typescript
const agent = new Agent({
  id: "custom-agent",
  name: "custom-agent",
  model: {
    url: "https://integrate.api.nvidia.com/v1",
    id: "nvidia/black-forest-labs/flux.1-dev",
    apiKey: process.env.NVIDIA_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
      ? "nvidia/z-ai/glm5"
      : "nvidia/black-forest-labs/flux.1-dev";
  }
});
```