InferX
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.
ModelsDirect link to Models
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|---|---|---|---|---|---|---|---|---|
inferx/Agents-A1 | 262K | — | — | |||||
inferx/deepseek-v4-flash | 1.0M | — | — | |||||
inferx/Devstral-2-123B-Instruct-2512-int4-AutoRound | 128K | — | — | |||||
inferx/gemma-4-31B-it-fp8 | 262K | — | — | |||||
inferx/mimo-v25 | 1.0M | — | — | |||||
inferx/Ornith-1.0-35B-FP8 | 262K | — | — | |||||
inferx/Qwen3-Coder-Next-FP8 | 256K | — | — | |||||
inferx/Qwen3-Coder-Next-FP8-no-thinking | 260K | — | — | |||||
inferx/Qwen3-Embedding-8B | 33K | — | — | |||||
inferx/Qwen3.6-27B-FP8 | 262K | — | — | |||||
inferx/Qwen3.6-35B-A3B-FP8 | 262K | — | — | |||||
inferx/Qwen3.6-35B-A3B-fp8-no-thinking | 262K | — | — |
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://model.inferx.net/endpoints/v1",
id: "inferx/Agents-A1",
apiKey: process.env.INFERX_API_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
? "inferx/mimo-v25"
: "inferx/Agents-A1";
}
});