Skip to main content

302.AI logo302.AI

Access 116 302.AI models through Mastra's model router. Authentication is handled automatically using the 302AI_API_KEY environment variable.

Learn more in the 302.AI documentation.

.env
302AI_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: "302ai/MiniMax-M1"
});

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

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
302ai/claude-fable-51.0M$10$50
302ai/claude-fable-5-11.0M$10$50
302ai/claude-haiku-4-5200K$1$5
302ai/claude-haiku-4-5-20251001200K$1$5
302ai/claude-opus-4-1-20250805200K$15$75
302ai/claude-opus-4-1-20250805-thinking200K$15$75
302ai/claude-opus-4-5-20251101200K$5$25
302ai/claude-opus-4-71.0M$5$25
302ai/claude-opus-4-7-thinking1.0M$5$25
302ai/claude-opus-4-81.0M$5$25
302ai/claude-opus-51.0M$5$25
302ai/claude-opus-5-thinking1.0M$5$25
302ai/claude-sonnet-4-5-20250929200K$3$15
302ai/claude-sonnet-4-5-20250929-thinking200K$3$15
302ai/claude-sonnet-4-61.0M$3$15
302ai/claude-sonnet-4-6-thinking1.0M$3$15
302ai/claude-sonnet-51.0M$2$10
302ai/deepseek-v3.2128K$0.29$0.43
302ai/deepseek-v3.2-thinking128K$0.29$0.43
302ai/doubao-seed-1-6-thinking-250715256K$0.12$1
302ai/doubao-seed-1-6-vision-250815256K$0.11$1
302ai/doubao-seed-1-8-251215224K$0.11$0.29
302ai/gemini-2.0-flash-lite2.0M$0.07$0.30
302ai/gemini-2.5-flash1.0M$0.30$3
302ai/gemini-2.5-flash-image33K$0.30$30
302ai/gemini-2.5-flash-lite-preview-09-20251.0M$0.10$0.40
302ai/gemini-2.5-flash-nothink1.0M$0.30$3
302ai/gemini-2.5-flash-preview-09-20251.0M$0.30$3
302ai/gemini-2.5-pro1.0M$1$10
302ai/gemini-3-flash-preview1.0M$0.50$3
302ai/gemini-3-pro-image-preview33K$2$120
302ai/gemini-3-pro-preview1.0M$2$12
302ai/gemini-3.1-flash-image-preview131K$0.50$60
302ai/gemini-3.1-flash-lite1.0M$0.25$2
302ai/gemini-3.1-flash-lite-preview1.0M$0.25$2
302ai/gemini-3.1-pro-preview1.0M$2$12
302ai/gemini-3.5-flash1.0M$2$9
302ai/gemini-3.5-flash-lite1.0M$0.30$3
302ai/gemini-3.5-flash-thinking1.0M$2$9
302ai/gemini-3.6-flash1.0M$2$8
302ai/gemini-3.7-flash1.0M$0.75$4
302ai/gemini-3.8-flash1.0M$0.75$4
302ai/glm-4.5131K$0.29$1
302ai/glm-4.5v64K$0.29$0.86
302ai/glm-4.6205K$0.29$1
302ai/glm-4.6v128K$0.14$0.43
302ai/glm-4.7205K$0.29$1
302ai/glm-5205K$0.60$3
302ai/glm-5-turbo200K$0.72$3
302ai/glm-5.1200K$1$4
302ai/glm-5.21.0M$1$4
302ai/glm-5.31.0M$1$4
302ai/glm-5.3-flash1.0M$0.07$0.25
302ai/glm-5v-turbo200K$0.72$3
302ai/gpt-4.11.0M$2$8
302ai/gpt-4.1-mini1.0M$0.40$2
302ai/gpt-4.1-nano1.0M$0.10$0.40
302ai/gpt-4o128K$3$10
302ai/gpt-5400K$1$10
302ai/gpt-5-mini400K$0.25$2
302ai/gpt-5-pro400K$15$120
302ai/gpt-5-thinking400K$1$10
302ai/gpt-5.1400K$1$10
302ai/gpt-5.1-chat-latest128K$1$10
302ai/gpt-5.2400K$2$14
302ai/gpt-5.2-chat-latest128K$2$14
302ai/gpt-5.3-chat-latest128K$2$14
302ai/gpt-5.41.1M$3$15
302ai/gpt-5.4-mini400K$0.75$5
302ai/gpt-5.4-nano400K$0.20$1
302ai/gpt-5.51.1M$5$30
302ai/gpt-5.6-luna1.1M$0.20$1
302ai/gpt-5.6-luna-pro1.1M$0.20$1
302ai/gpt-5.6-sol1.1M$5$30
302ai/gpt-5.6-sol-pro1.1M$5$30
302ai/gpt-5.6-terra1.1M$2$12
302ai/gpt-5.6-terra-pro1.1M$2$12
302ai/gpt-6-astra1.1M$10$50
302ai/grok-4-1-fast-reasoning2.0M$0.20$0.50
302ai/grok-4-fast-non-reasoning2.0M$0.20$0.50
302ai/grok-4-fast-reasoning2.0M$0.20$0.50
302ai/grok-4.1200K$2$10
302ai/grok-4.20-beta-0309-reasoning2.0M$2$6
302ai/grok-4.31.0M$1$3
302ai/grok-4.5500K$2$6
302ai/grok-4.6500K$2$6
302ai/kimi-k2-0905-preview262K$0.63$3
302ai/kimi-k2-thinking262K$0.57$2
302ai/kimi-k2.5262K$0.66$3
302ai/kimi-k2.6262K$0.95$4
302ai/kimi-k2.7-code262K$0.95$4
302ai/kimi-k31.0M$3$15
302ai/MiniMax-M11.0M$0.13$1
302ai/MiniMax-M21.0M$0.33$1
302ai/MiniMax-M2.1205K$0.30$1
302ai/MiniMax-M2.5205K$0.30$1
302ai/MiniMax-M2.7205K$0.30$1
302ai/MiniMax-M31.0M$0.72$3
302ai/ministral-14b-2512128K$0.33$0.33
302ai/mistral-large-2512128K$1$3
302ai/o3200K$2$8
302ai/qwen3-235b-a22b128K$0.29$3
302ai/qwen3-235b-a22b-instruct-2507128K$0.29$1
302ai/qwen3-30b-a3b128K$0.11$1
302ai/qwen3-coder-480b-a35b-instruct262K$0.86$3
302ai/qwen3-max-2025-09-23258K$0.86$3
302ai/qwen3.5-35b-a3b262K$0.06$0.46
302ai/qwen3.5-plus1.0M$0.12$0.69
302ai/qwen3.6-35b-a3b262K$0.28$2
302ai/qwen3.6-flash1.0M$0.19$1
302ai/qwen3.6-plus1.0M$0.30$2
302ai/qwen3.7-max1.0M$2$5
302ai/qwen3.7-max-2026-06-081.0M$2$5
302ai/qwen3.7-plus1.0M$0.28$1
302ai/qwen3.8-flash1.0M$0.18$0.56
302ai/qwen3.8-max1.0M$2$6
116 available models

Model availability, capabilities, context windows, and pricing are sourced from models.dev and may change.

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.302.ai/v1",
id: "302ai/MiniMax-M1",
apiKey: process.env.302AI_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
? "302ai/qwen3.8-max"
: "302ai/MiniMax-M1";
}
});
On this page