ຂ້າມໄປຫາເນື້ອຫາ
Mastra

Framework ແລະ SDK

ໃຊ້ Mastra ກັບ Shannon

ໃຫ້ agent ຂອງ Mastra ມີ object model ທີ່ມີ URL, key ແລະ id ຂອງ Shannon; streaming ແລະ tool ຈະແລ່ນເທິງ model ຂອງ Shannon.

  • ທົດສອບແລ້ວ 7 ພ.ຈ. 2026
  • OpenAI Chat Completions
  • ປະມານ 3 ນາທີ

ກ່ຽວກັບ Mastra

Mastra ແມ່ນ framework TypeScript ສຳລັບ agent, workflow, ຄວາມຈຳ ແລະ ການດຶງຂໍ້ມູນ, ພ້ອມ dev studio ໃນເຄື່ອງ. agent ຮັບ model ຜ່ານ model router ຂອງມັນ, ເຊິ່ງຮັບ endpoint ທີ່ເຂົ້າກັນໄດ້ກັບ OpenAI ໃດກໍໄດ້ເມື່ອໃສ່ URL ແລະ key. ດັ່ງນັ້ນ agent ແລະ workflow ຂອງ Mastra ຈຶ່ງແລ່ນເທິງ model ຂອງ Shannon ໄດ້.

ສິ່ງທີ່ທ່ານຕ້ອງການ

Shannon API key ໜຶ່ງອັນ
ໜ້າ Keys & usage
Base URL
https://api.shannon-ai.com/v1 Endpoint: /v1/chat/completions
ທຸກ snippet ດ້ານລຸ່ມປ່ຽນຕາມທີ່ທ່ານເລືອກ.

ຕັ້ງຄ່າ

  1. ຕິດຕັ້ງ Mastra

    Shell
    npm install @mastra/core zod
  2. ສ້າງ agent ເທິງ Shannon

    id ແມ່ນ <any prefix>/<Shannon id>; url ແມ່ນ base URL, ບໍ່ແມ່ນ endpoint ຂອງ chat.

    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 ແລະ 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);

ກວດວ່າມັນໃຊ້ໄດ້

ສົ່ງ: ແລ່ນຕົວຢ່າງໂດຍຕັ້ງ SHANNON_API_KEY ໄວ້.

ທ່ານຄວນເຫັນ: ສີ stream ເຂົ້າມາ, ແລ້ວຄຳຕອບທີ່ໃຊ້ອາກາດຈາກ tool.

model ທີ່ເໝາະກັບ Mastra

ທຸກ id ດ້ານລຸ່ມຕອບສະໜອງສິ່ງທີ່ Mastra ຕ້ອງການ. ອັນທຳອິດເປັນຄ່າເລີ່ມຕົ້ນໃນ snippet.

id ຂອງ modelໜ້າຕ່າງ contextoutput ສູງສຸດຮູບພາບເປັນ input
Kimi-K3-uncensored-NVFP4 1,022,976 262,144 ມີ
Kimi-K3-uncensored-3BIT-REAP 225,280 225,280 ມີ
shannon-3 196,608 65,536 ມີ
shannon-coder-1 131,072 65,536 ບໍ່ມີ

ຄວນຮູ້

  • url ຕ້ອງເປັນ base URL ທີ່ລົງທ້າຍດ້ວຍ /v1; Mastra ເພີ່ມ /chat/completions ເອງ.
  • ເພີ່ມ api: "responses" ໃນ object model ເພື່ອໃຊ້ /v1/responses ຂອງ Shannon ແທນ.

ເຄັດລັບ

  1. ລົງທະບຽນ agent ໃນ instance Mastra ເພື່ອເບິ່ງໃນ studio ໃນເຄື່ອງ (mastra dev).
  2. object model ດຽວກັນໃຊ້ໄດ້ໃນ workflow ແລະ memory processor ທີ່ຮັບ model.
  3. ສົ່ງ key ໃນ apiKey, ຕົວຢ່າງຈາກ SHANNON_API_KEY; ເອກະສານຂອງ Mastra ບໍ່ໄດ້ບອກຊື່ຕົວແປທີ່ມັນອ່ານເອງສຳລັບ endpoint ກຳນົດເອງ.

ການແກ້ໄຂບັນຫາ

ອາການສາເຫດວິທີແກ້
404 Not Found url ຂາດ /v1 ຫຼື ລົງທ້າຍດ້ວຍ /chat/completions. ໃຊ້ https://api.shannon-ai.com/v1.
401 apiKey ຫວ່າງ. ສົ່ງ key ໃນ apiKey.
401 Unauthorized ບໍ່ມີ key, ພິມຜິດ ຫຼື ຖືກປ່ຽນແລ້ວ. ຄັດລອກ key ໃໝ່ຈາກ Keys & usage; ມັນຂຶ້ນຕົ້ນດ້ວຍ sk-.
context_length_exceeded ຫຼື ຂໍ້ຄວາມ "prompt is too long" ການສົນທະນາຍາວກວ່າ context window ຂອງ model. ເລີ່ມ chat ໃໝ່, ໃຫ້ tool ບີບອັດມັນ, ຫຼື ເລືອກ model ທີ່ມີ window ໃຫຍ່ກວ່າ.
insufficient_quota ຍອດເງິນຂອງທ່ານບໍ່ພໍຈ່າຍສຳລັບຄຳຮ້ອງຂໍນີ້. ເຕີມເຄຣດິດ ຫຼື ປ່ຽນແຜນ; ຄຳຮ້ອງຂໍຈະບໍ່ຖືກລອງໃໝ່ເອງ.

ຄຳຖາມ

Mastra ໃຊ້ກັບ Shannon ໄດ້ບໍ?

ໄດ້: model ຂອງ agent { id, url, apiKey } ທີ່ມີ url: "https://api.shannon-ai.com/v1" ເຂົ້າເຖິງ Shannon.

tool ຂອງ Mastra ໃຊ້ໄດ້ບໍ?

ໄດ້; tool ຈາກ createTool ຖືກສົ່ງເປັນ tool call ແບບ native.

ເລືອກພາສາຂອງທ່ານ

ພາສາທຸກພາສາເທົ່າທຽມກັນ. ເລືອກພາສາທີ່ທ່ານຕ້ອງການໃຊ້.

ເອີຣົບ

ຕາເວັນອອກກາງ ແລະ ອາຟຣິກາເໜືອ

ອາຊີໃຕ້

ອາຊີຕາເວັນອອກສຽງໃຕ້

ອາຊີຕາເວັນອອກ

ອາຊີກາງ ແລະ ເທືອກເຂົາຄອກາຊັສ

ອາຟຣິກາ

ໂອເຊຍເນຍ

ພາສາສ້າງຂຶ້ນ ແລະ ພາສາບູຮານ