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.
.env
RUNINFRA_GATEWAY_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: "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 for details.
ModelsDirect link to 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 configurationDirect link to Advanced configuration
Custom headersDirect link to Custom headers
src/mastra/agents/my-agent.ts
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 selectionDirect 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
? "runinfra/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16"
: "runinfra/Inferact/Qwen3.8-2.4T-A95B-NVFP4";
}
});