Skip to main content

InferX logoInferX

Access 12 InferX models through Mastra's model router. Authentication is handled automatically using the INFERX_API_KEY environment variable.

Learn more in the InferX documentation.

.env
INFERX_API_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: "inferx/Agents-A1"
});

// 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 InferX documentation for details.

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
inferx/Agents-A1262K
inferx/deepseek-v4-flash1.0M
inferx/Devstral-2-123B-Instruct-2512-int4-AutoRound128K
inferx/gemma-4-31B-it-fp8262K
inferx/mimo-v251.0M
inferx/Ornith-1.0-35B-FP8262K
inferx/Qwen3-Coder-Next-FP8256K
inferx/Qwen3-Coder-Next-FP8-no-thinking260K
inferx/Qwen3-Embedding-8B33K
inferx/Qwen3.6-27B-FP8262K
inferx/Qwen3.6-35B-A3B-FP8262K
inferx/Qwen3.6-35B-A3B-fp8-no-thinking262K
12 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://model.inferx.net/endpoints/v1",
id: "inferx/Agents-A1",
apiKey: process.env.INFERX_API_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
? "inferx/mimo-v25"
: "inferx/Agents-A1";
}
});
On this page