Skip to content
Mastra

Frameworks and SDKs

Use Mastra with Shannon

Give a Mastra agent a model object with Shannon's URL, key and id; streaming and tools then run on Shannon models.

  • Tested Nov 7, 2026
  • OpenAI Chat Completions
  • About 3 min

About Mastra

Mastra is a TypeScript framework for agents, workflows, memory and retrieval, with a local dev studio. Agents take a model through its model router, which accepts any OpenAI-compatible endpoint given a URL and a key. That lets Mastra agents and workflows run on Shannon models.

What you need

A Shannon API key
Keys & usage
Base URL
https://api.shannon-ai.com/v1 Endpoint: /v1/chat/completions
Every snippet below follows your choice.

Set it up

  1. Install Mastra

    Shell
    npm install @mastra/core zod
  2. Create an agent on Shannon

    id is <any prefix>/<Shannon id>; url is the base URL, not the chat endpoint.

    TypeScript
    import { Agent } from "@mastra/core/agent";
    import { createTool } from "@mastra/core/tools";
    import { z } from "zod";
    
    const getWeather = createTool({
      id: "get-weather",
      description: "Weather for a city",
      inputSchema: z.object({ city: z.string() }),
      execute: async ({ city }) => ({ weather: `Sunny, 18 C in ${city}` }),
    });
    
    export const agent = new Agent({
      id: "assistant",
      name: "assistant",
      instructions: "Answer briefly. Use tools for weather.",
      model: { id: "shannon/Kimi-K3-uncensored-NVFP4", url: "https://api.shannon-ai.com/v1", apiKey: process.env.SHANNON_API_KEY },
      tools: { getWeather },
    });
  3. Stream and generate

    TypeScript
    const stream = await agent.stream("Name three colours a cat can be.");
    for await (const text of stream.textStream) process.stdout.write(text);
    
    const r = await agent.generate("What is the weather in Oslo?");
    console.log(r.text);

Check that it works

Send: Run the sample with SHANNON_API_KEY set.

You should see: The colours stream in, then an answer that uses the tool's weather.

Models that fit Mastra

Every id below meets what Mastra needs. The first one is the default in the snippets.

Model idContext windowMax outputImage input
Kimi-K3-uncensored-NVFP4 1,022,976 262,144 Yes
Kimi-K3-uncensored-3BIT-REAP 225,280 225,280 Yes
shannon-3 196,608 65,536 Yes
shannon-coder-1 131,072 65,536 No

Good to know

  • url must be the base URL ending in /v1; Mastra adds /chat/completions.
  • Add api: "responses" to the model object to use Shannon's /v1/responses instead.

Tips

  1. Register agents in a Mastra instance to see them in the local studio (mastra dev).
  2. The same model object works in workflows and memory processors that take a model.
  3. Pass the key in apiKey, for example from SHANNON_API_KEY; Mastra's docs name no variable it reads on its own for a custom endpoint.

Troubleshooting

SymptomCauseFix
404 Not Found url lacks /v1 or ends in /chat/completions. Use https://api.shannon-ai.com/v1.
401 apiKey is empty. Pass the key in apiKey.
401 Unauthorized The key is missing, mistyped or rotated. Copy the key again from Keys & usage; it starts with sk-.
context_length_exceeded / "prompt is too long" The conversation is longer than the model's window. Start a new chat, let the tool compact it, or pick a model with a larger window.
insufficient_quota Your balance cannot pay for the request. Top up or change plan; the request is not retried by itself.

Questions

Does Mastra work with Shannon?

Yes: an agent model { id, url, apiKey } with url: "https://api.shannon-ai.com/v1" reaches Shannon.

Do Mastra tools work?

Yes; createTool tools are sent as native tool calls.

Choose your language

All languages are equal. Pick the one you want to browse in.

Europe

Middle East & North Africa

South Asia

Southeast Asia

East Asia

Central Asia & Caucasus

Africa

Oceania

Constructed & Classical