Gwiritsani ntchito Mastra ndi Shannon
Patsani agent ya Mastra model object yokhala ndi URL, kiyi ndi id ya Shannon; streaming ndi ma tool kenako zimayenda pa ma model a Shannon.
- Yayesedwa Nov 7, 2026
- OpenAI Chat Completions
- Pafupifupi mphindi 3
Za Mastra
Mastra ndi framework ya TypeScript ya ma agent, ma workflow, memory ndi retrieval, yokhala ndi studio yakomweko yopangira. Ma agent amalandira model kudzera mu model router yake, yomwe imalandira endpoint iliyonse yogwirizana ndi OpenAI poperekedwa URL ndi kiyi. Zimenezo zimalola ma agent ndi ma workflow a Mastra kuyenda pa ma model a Shannon.
Zomwe mukufuna
- API key ya Shannon
- Makiyi ndi kagwiritsidwe
- Base URL
-
https://api.shannon-ai.com/v1Endpoint:/v1/chat/completions - Snippet iliyonse m'munsiyi imatsatira zomwe mwasankha.
Kukhazikitsa
-
Ikani Mastra
Shellnpm install @mastra/core zod -
Pangani agent pa Shannon
idndi<any prefix>/<Shannon id>;urlndi base URL, osati chat endpoint.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 }, }); -
Stream ndi generate
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);
Onani ngati ikugwira ntchito
Tumizani: Yendetsani chitsanzo ndi SHANNON_API_KEY itakhazikitsidwa.
Muyenera kuona: Mitundu imafika ndi stream, kenako yankho logwiritsa ntchito nyengo ya tool.
Ma model oyenera Mastra
Id iliyonse m'munsiyi imakwaniritsa zomwe Mastra imafuna. Yoyamba ndi default mu ma snippet.
| Model id | Context window | Zotuluka zapamwamba | Input ya zithunzi |
|---|---|---|---|
Kimi-K3-uncensored-NVFP4 | 1,022,976 | 262,144 | Inde |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | Inde |
shannon-3 | 196,608 | 65,536 | Inde |
shannon-coder-1 | 131,072 | 65,536 | Ayi |
Zabwino kudziwa
urliyenera kukhala base URL yothera ndi/v1; Mastra imawonjezera/chat/completions.- Onjezani
api: "responses"ku model object kuti mugwiritse ntchito/v1/responsesya Shannon m'malo mwake.
Maupangiri
- Lembetsani ma agent mu instance ya
Mastrakuti muwawone mu studio yakomweko (mastra dev). - Model object yomweyo imagwira ntchito mu ma workflow ndi memory processor omwe amalandira model.
- Tumizani kiyi mu
apiKey, mwachitsanzo kuchokera kuSHANNON_API_KEY; zolemba za Mastra sizitchula variable yomwe imaiwerenga yokha pa endpoint yachizolowezi.
Kuthetsa mavuto
| Chizindikiro | Chifukwa | Njira yothetsera |
|---|---|---|
404 Not Found | url ilibe /v1 kapena imathera ndi /chat/completions. | Gwiritsani ntchito https://api.shannon-ai.com/v1. |
401 | apiKey ilibe kanthu. | Tumizani kiyi mu apiKey. |
401 Unauthorized | Kiyi ikusowa, yalembedwa molakwika kapena yasinthidwa. | Koperaninso kiyi kuchokera ku Keys & usage; imayamba ndi sk-. |
context_length_exceeded kapena "prompt is too long" | Zokambirana ndi zazitali kuposa context window ya model. | Yambani chat yatsopano, lolani tool ifupikitse zokambiranazo, kapena sankhani model yokhala ndi window yaikulu. |
insufficient_quota | Balance yanu siingathe kulipira pempho. | Wonjezani balance kapena sinthani plan; pempho silibwerezedwa lokha. |
Mafunso
Kodi Mastra imagwira ntchito ndi Shannon?
Inde: model ya agent { id, url, apiKey } ndi url: "https://api.shannon-ai.com/v1" imafika ku Shannon.
Kodi ma tool a Mastra amagwira ntchito?
Inde; ma tool a createTool amatumizidwa ngati tool calls zachilengedwe.