Skip to main content

Impossibl logoImpossibl

Access 76 Impossibl models through Mastra's model router. Authentication is handled automatically using the IMPOSSIBL_API_KEY environment variable.

Learn more in the Impossibl documentation.

.env
IMPOSSIBL_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: "impossibl/anthropic/claude-fable-5"
});

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

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
impossibl/anthropic/claude-fable-51.0M$10$50
impossibl/anthropic/claude-haiku-4-5200K$1$5
impossibl/anthropic/claude-opus-4-5200K$5$25
impossibl/anthropic/claude-opus-4-61.0M$5$25
impossibl/anthropic/claude-opus-4-71.0M$5$25
impossibl/anthropic/claude-opus-4-81.0M$5$25
impossibl/anthropic/claude-sonnet-4-5200K$3$15
impossibl/anthropic/claude-sonnet-4-61.0M$3$15
impossibl/anthropic/claude-sonnet-51.0M$2$10
impossibl/cerebras/gpt-oss-120b131K$0.35$0.75
impossibl/deepseek/deepseek-v4-flash1.0M$0.19$0.51
impossibl/deepseek/deepseek-v4-pro1.0M$2$3
impossibl/fireworks/glm-5.21.0M$1$4
impossibl/fireworks/gpt-oss-120b131K$0.15$0.60
impossibl/fireworks/gpt-oss-20b131K$0.07$0.30
impossibl/google/gemini-2.5-flash1.0M$0.30$3
impossibl/google/gemini-2.5-flash-lite1.0M$0.10$0.40
impossibl/google/gemini-2.5-pro1.0M$1$10
impossibl/google/gemini-3.1-flash-lite1.0M$0.25$2
impossibl/google/gemini-3.1-pro-preview1.0M$2$12
impossibl/google/gemini-3.5-flash1.0M$2$9
impossibl/google/gemini-3.5-flash-lite1.0M$0.30$3
impossibl/google/gemini-3.6-flash1.0M$2$8
impossibl/groq/gpt-oss-120b131K$0.15$0.60
impossibl/groq/gpt-oss-20b131K$0.07$0.30
impossibl/moonshotai/kimi-k31.0M$3$15
impossibl/openai/gpt-3.5-turbo16K$0.50$2
impossibl/openai/gpt-4-turbo128K$10$30
impossibl/openai/gpt-4.11.0M$2$8
impossibl/openai/gpt-4.1-mini1.0M$0.40$2
impossibl/openai/gpt-4.1-nano1.0M$0.10$0.40
impossibl/openai/gpt-4o128K$3$10
impossibl/openai/gpt-4o-mini128K$0.15$0.60
impossibl/openai/gpt-5400K$1$10
impossibl/openai/gpt-5-codex400K$1$10
impossibl/openai/gpt-5-mini400K$0.25$2
impossibl/openai/gpt-5-nano400K$0.05$0.40
impossibl/openai/gpt-5-pro400K$15$120
impossibl/openai/gpt-5.1400K$1$10
impossibl/openai/gpt-5.1-codex400K$1$10
impossibl/openai/gpt-5.1-codex-mini400K$0.25$2
impossibl/openai/gpt-5.2400K$2$14
impossibl/openai/gpt-5.2-codex400K$2$14
impossibl/openai/gpt-5.3-codex400K$2$14
impossibl/openai/gpt-5.41.1M$3$15
impossibl/openai/gpt-5.4-mini400K$0.75$5
impossibl/openai/gpt-5.4-nano400K$0.20$1
impossibl/openai/gpt-5.4-pro1.1M$30$180
impossibl/openai/gpt-5.51.1M$5$30
impossibl/openai/gpt-5.5-pro1.1M$30$180
impossibl/openai/gpt-5.6-luna1.1M$0.20$1
impossibl/openai/gpt-5.6-sol1.1M$5$30
impossibl/openai/gpt-5.6-terra1.1M$2$12
impossibl/openai/o1200K$15$60
impossibl/openai/o3200K$2$8
impossibl/openai/o3-mini200K$1$4
impossibl/openai/o4-mini200K$1$4
impossibl/qwen/qwen3.6-flash1.0M$0.25$2
impossibl/qwen/qwen3.7-max1.0M$3$8
impossibl/qwen/qwen3.7-plus1.0M$0.40$2
impossibl/qwen/qwen3.8-max-preview1.0M$3$8
impossibl/thinkingmachines/inkling66K$2$5
impossibl/xai/grok-4.20-0309-non-reasoning1.0M$1$3
impossibl/xai/grok-4.20-0309-reasoning1.0M$1$3
impossibl/xai/grok-4.31.0M$1$3
impossibl/xai/grok-4.5500K$2$6
impossibl/xai/grok-build-0.1256K$1$2
impossibl/xiaomi/mimo-v2.51.0M$0.14$0.28
impossibl/zai/glm-4.5131K$0.60$2
impossibl/zai/glm-4.5-air131K$0.20$1
impossibl/zai/glm-4.6205K$0.60$2
impossibl/zai/glm-4.7205K$0.60$2
impossibl/zai/glm-5205K$1$3
impossibl/zai/glm-5-turbo200K$1$4
impossibl/zai/glm-5.1200K$1$4
impossibl/zai/glm-5.21.0M$1$4
76 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.impossibl.com/v1",
id: "impossibl/anthropic/claude-fable-5",
apiKey: process.env.IMPOSSIBL_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
? "impossibl/zai/glm-5.2"
: "impossibl/anthropic/claude-fable-5";
}
});
On this page