Skip to main content
Mastra 1.0 is available 🎉 Read announcement

302.AI logo302.AI

Access 64 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);
}
info

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/chatgpt-4o-latest128K$5$15
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-5-20251101-thinking200K$5$25
302ai/claude-sonnet-4-5-20250929200K$3$15
302ai/claude-sonnet-4-5-20250929-thinking200K$3$15
302ai/deepseek-chat128K$0.29$0.43
302ai/deepseek-reasoner128K$0.29$0.43
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/doubao-seed-code-preview-251028256K$0.17$1
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/glm-4.5128K$0.29$1
302ai/glm-4.5v64K$0.29$0.86
302ai/glm-4.6200K$0.29$1
302ai/glm-4.6v128K$0.14$0.43
302ai/glm-4.7200K$0.29$1
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/grok-4-1-fast-non-reasoning2.0M$0.20$0.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/kimi-k2-0905-preview262K$0.63$3
302ai/kimi-k2-thinking262K$0.57$2
302ai/kimi-k2-thinking-turbo262K$1$9
302ai/MiniMax-M11.0M$0.13$1
302ai/MiniMax-M21.0M$0.33$1
302ai/MiniMax-M2.11.0M$0.30$1
302ai/ministral-14b-2512128K$0.33$0.33
302ai/mistral-large-2512128K$1$3
302ai/qwen-flash1.0M$0.02$0.22
302ai/qwen-max-latest131K$0.34$1
302ai/qwen-plus1.0M$0.12$1
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
64 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.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-max-2025-09-23"
: "302ai/MiniMax-M1";
}
});
On this page