> Discover all available pages from the documentation index: https://mastra.ai/llms.txt

# ![RunInfra logo](https://models.dev/logos/runinfra.svg)RunInfra

Access 4 RunInfra models through Mastra's model router. Authentication is handled automatically using the `RUNINFRA_GATEWAY_KEY` environment variable.

Learn more in the [RunInfra documentation](https://runinfra.ai/docs).

```bash
RUNINFRA_GATEWAY_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: "runinfra/Inferact/Qwen3.8-2.4T-A95B-NVFP4"
});

// 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 [RunInfra documentation](https://runinfra.ai/docs) for details.

## Models

| Model                                                        | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
| ------------------------------------------------------------ | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
| `runinfra/deepseek-ai/DeepSeek-V4-Flash-0731`                | 1.0M    |       |           |       |       |       | $0.13      | $0.27       |
| `runinfra/Inferact/Qwen3.8-2.4T-A95B-NVFP4`                  | 262K    |       |           |       |       |       | $2         | $6          |
| `runinfra/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16` | 262K    |       |           |       |       |       | $0.05      | $0.15       |
| `runinfra/Qwen/Qwen3.8-27B`                                  | 262K    |       |           |       |       |       | $0.10      | $0.40       |

## Advanced configuration

### Custom headers

```typescript
const agent = new Agent({
  id: "custom-agent",
  name: "custom-agent",
  model: {
    url: "https://api.runinfra.ai/v1",
    id: "runinfra/Inferact/Qwen3.8-2.4T-A95B-NVFP4",
    apiKey: process.env.RUNINFRA_GATEWAY_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
      ? "runinfra/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16"
      : "runinfra/Inferact/Qwen3.8-2.4T-A95B-NVFP4";
  }
});
```