Access 337 Kilo Gateway models through Mastra's model router. Authentication is handled automatically using the KILO_API_KEY environment variable.

Learn more in the Kilo Gateway documentation.

Code Example

Environment Variable

.env

KILO_API_KEY=your-api-key

Agent Configuration

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: "kilo/ai21/jamba-large-1.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);
}

API Information

Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the Kilo Gateway documentation for details.

Models Table

Model Context Tools Reasoning Image Audio Video Input $/1M Output $/1M
kilo/ai21/jamba-large-1.7 256K $2 $8
kilo/aion-labs/aion-1.0 131K $4 $8
kilo/aion-labs/aion-1.0-mini 131K $0.70 $1
kilo/aion-labs/aion-2.0 131K $0.80 $2
kilo/aion-labs/aion-rp-llama-3.1-8b 33K $0.80 $2
kilo/alfredpros/codellama-7b-instruct-solidity 4K $0.80 $1
kilo/alibaba/tongyi-deepresearch-30b-a3b 131K $0.09 $0.45
kilo/allenai/olmo-2-0325-32b-instruct 128K $0.05 $0.20
kilo/allenai/olmo-3-32b-think 66K $0.15 $0.50
kilo/allenai/olmo-3.1-32b-instruct 66K $0.20 $0.60
kilo/alpindale/goliath-120b 6K $4 $8
...[REPEATED ENTRY TRUNCATED FOR BREVITY]...
kilo/openrouter/free 200K — —
kilo/perplexity/sonar 127K $1 $1
kilo/qwen/qwen3-30b-a3b 41K $0.08 $0.28
...[REPEATED ENTRY TRUNCATED FOR BREVITY]...
kilo/z-ai/glm-5.1 203K $1 $4

337 available models

Advanced Configuration

Custom Headers

src/mastra/agents/my-agent.ts

const agent = new Agent({
  id: "custom-agent",
  name: "custom-agent",
  model: {
    url: "https://api.kilo.ai/api/gateway",
    id: "kilo/ai21/jamba-large-1.7",
    apiKey: process.env.KILO_API_KEY,
    headers: {
      "X-Custom-Header": "value"
    }
  }
});

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
      ? "kilo/z-ai/glm-5v-turbo"
      : "kilo/ai21/jamba-large-1.7";
  }
});