Tumia Mastra na Shannon
Mpe wakala wa Mastra model object yenye URL, key na id ya Shannon; streaming na tools kisha huendeshwa kwenye model za Shannon.
- Imejaribiwa 7 Nov 2026
- OpenAI Chat Completions
- Takriban dakika 3
Kuhusu Mastra
Mastra ni framework ya TypeScript ya mawakala, workflows, kumbukumbu na retrieval, yenye dev studio ya ndani. Mawakala huchukua model kupitia model router yake, inayokubali endpoint yoyote inayooana na OpenAI ikipewa URL na key. Hilo huruhusu mawakala na workflows za Mastra kuendeshwa kwenye model za Shannon.
Unachohitaji
- API key ya Shannon
- Keys na matumizi
- URL ya msingi
-
https://api.shannon-ai.com/v1Endpoint:/v1/chat/completions - Kila snippet hapa chini inafuata chaguo lako.
Kuweka mipangilio
-
Sakinisha Mastra
Shellnpm install @mastra/core zod -
Tengeneza wakala kwenye Shannon
idni<any prefix>/<Shannon id>;urlni base URL, si endpoint ya chat.TypeScriptimport { 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 }, }); -
Tiririsha na uzalishe
TypeScriptconst 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);
Hakikisha inafanya kazi
Tuma: Endesha sampuli ukiwa umeweka SHANNON_API_KEY.
Unapaswa kuona: Rangi zinatiririka, kisha jibu linalotumia hali ya hewa ya tool.
Models zinazofaa Mastra
Kila id hapa chini inakidhi mahitaji ya Mastra. Ya kwanza ndiyo chaguo-msingi kwenye snippets.
| Kitambulisho cha modeli | Dirisha la muktadha | Output ya juu | Input ya picha |
|---|---|---|---|
Kimi-K3-uncensored-NVFP4 | 1,022,976 | 262,144 | Ndiyo |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | Ndiyo |
shannon-3 | 196,608 | 65,536 | Ndiyo |
shannon-coder-1 | 131,072 | 65,536 | Hapana |
Vizuri kujua
urllazima iwe base URL inayoishia na/v1; Mastra huongeza/chat/completions.- Ongeza
api: "responses"kwenye model object ili kutumia/v1/responsesya Shannon badala yake.
Vidokezo
- Sajili mawakala kwenye instance ya
Mastraili kuwaona kwenye studio ya ndani (mastra dev). - Model object ile ile hufanya kazi kwenye workflows na memory processors zinazochukua model.
- Pitisha key kwenye
apiKey, kwa mfano kutokaSHANNON_API_KEY; nyaraka za Mastra hazitaji variable yoyote inayosoma yenyewe kwa endpoint maalum.
Utatuzi wa matatizo
| Dalili | Sababu | Suluhisho |
|---|---|---|
404 Not Found | url haina /v1 au inaishia na /chat/completions. | Tumia https://api.shannon-ai.com/v1. |
401 | apiKey ni tupu. | Pitisha key kwenye apiKey. |
401 Unauthorized | Key haipo, imeandikwa vibaya au imebadilishwa. | Nakili key tena kutoka Keys na matumizi; inaanza na sk-. |
context_length_exceeded au "prompt is too long" | Mazungumzo ni marefu kuliko dirisha la muktadha la model. | Anza chat mpya, acha tool iyafupishe, au chagua model yenye dirisha kubwa zaidi. |
insufficient_quota | Salio lako haliwezi kulipia ombi. | Ongeza salio au badilisha mpango; ombi halirudiwi lenyewe. |
Maswali
Je, Mastra inafanya kazi na Shannon?
Ndiyo: model ya wakala { id, url, apiKey } yenye url: "https://api.shannon-ai.com/v1" hufika Shannon.
Je, tools za Mastra zinafanya kazi?
Ndiyo; tools za createTool hutumwa kama tool calls asilia.