Skip to main content

Kenari logoKenari

Access 23 Kenari models through Mastra's model router. Authentication is handled automatically using the KENARI_API_KEY environment variable.

Learn more in the Kenari documentation.

.env
KENARI_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: "kenari/claude-opus-4-7"
});

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

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
kenari/claude-opus-4-71.0M
kenari/claude-opus-4-81.0M
kenari/claude-sonnet-4-61.0M
kenari/deepseek-v4-flash1.0M
kenari/deepseek-v4-flash:free1.0M
kenari/deepseek-v4-pro1.0M
kenari/deepseek-v4-pro:free1.0M
kenari/gemma-4-31b-it262K
kenari/glm-5-1200K
kenari/glm-5-21.0M
kenari/gpt-5-4-mini400K
kenari/gpt-5-51.1M
kenari/gpt-image-2272K
kenari/gpt-oss-120b131K
kenari/gpt-oss-20b131K
kenari/grok-4-31.0M
kenari/grok-build-0-1256K
kenari/kimi-k2-6262K
kenari/kimi-k2-7-code262K
kenari/mimo-v2-51.0M
kenari/mimo-v2-5-pro1.0M
kenari/minimax-m3512K
kenari/qwen3-7-plus1.0M
23 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://kenari.id/v1",
id: "kenari/claude-opus-4-7",
apiKey: process.env.KENARI_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
? "kenari/qwen3-7-plus"
: "kenari/claude-opus-4-7";
}
});
On this page