Skip to main content

RunInfra logoRunInfra

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.

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
runinfra/deepseek-ai/DeepSeek-V4-Flash-07311.0M$0.13$0.27
runinfra/Inferact/Qwen3.8-2.4T-A95B-NVFP4262K$2$6
runinfra/nvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16262K$0.05$0.15
runinfra/Qwen/Qwen3.8-27B262K$0.10$0.40
4 available models

Advanced configuration
Direct link to Advanced configuration

Custom headers
Direct 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 selection
Direct 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";
}
});
On this page