Shannon સાથે Mastra વાપરો
Mastra એજન્ટને Shannon ના URL, કી અને id સાથેનું મોડેલ ઓબ્જેક્ટ આપો; સ્ટ્રીમિંગ અને ટૂલ્સ પછી Shannon મોડેલ્સ પર ચાલે છે.
- 7 નવે, 2026 એ ટેસ્ટ કરેલ
- OpenAI Chat Completions
- આશરે 3 મિનિટ
Mastra વિશે
Mastra એ એજન્ટ્સ, વર્કફ્લો, મેમરી અને રિટ્રીવલ માટેનું TypeScript ફ્રેમવર્ક છે, જેમાં લોકલ ડેવ સ્ટુડિયો છે. એજન્ટ્સ મોડેલ તેના મોડેલ રાઉટર દ્વારા લે છે, જે URL અને કી આપેલા કોઈ પણ OpenAI-સુસંગત એન્ડપોઇન્ટને સ્વીકારે છે. તેથી Mastra એજન્ટ્સ અને વર્કફ્લો Shannon મોડેલ્સ પર ચાલી શકે છે.
તમને શું જોઈએ
- Shannon API કી
- Keys & usage પેજ
- બેઝ URL
-
https://api.shannon-ai.com/v1એન્ડપોઇન્ટ:/v1/chat/completions - નીચેના બધા સ્નિપેટ્સ તમારી પસંદગી મુજબ બદલાય છે.
સેટઅપ કરો
-
Mastra ઇન્સ્ટોલ કરો
Shellnpm install @mastra/core zod -
Shannon પર એજન્ટ બનાવો
idએટલે<any prefix>/<Shannon id>;urlબેઝ URL છે, ચેટ એન્ડપોઇન્ટ નહીં.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 }, }); -
સ્ટ્રીમ કરો અને જનરેટ કરો
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);
તે કામ કરે છે કે નહીં તપાસો
મોકલો: SHANNON_API_KEY સેટ કરીને સેમ્પલ ચલાવો.
તમને આ દેખાવું જોઈએ: રંગો સ્ટ્રીમ થાય છે, પછી ટૂલના હવામાનનો ઉપયોગ કરતો જવાબ.
Mastra માટે યોગ્ય મોડેલ્સ
નીચેનો દરેક id Mastra ની જરૂરિયાતો પૂરી કરે છે. પહેલો id સ્નિપેટ્સમાં ડિફૉલ્ટ છે.
| મોડેલ id | કોન્ટેક્સ્ટ વિન્ડો | મહત્તમ આઉટપુટ | ઇમેજ ઇનપુટ |
|---|---|---|---|
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/v1થી પૂરું થતું બેઝ URL હોવું જોઈએ; Mastra/chat/completionsઉમેરે છે.- તેના બદલે Shannon નું
/v1/responsesવાપરવા મોડેલ ઓબ્જેક્ટમાંapi: "responses"ઉમેરો.
ટિપ્સ
- એજન્ટ્સને લોકલ સ્ટુડિયોમાં (
mastra dev) જોવા માટેMastraઇન્સ્ટન્સમાં રજિસ્ટર કરો. - મોડેલ લેતા વર્કફ્લો અને મેમરી પ્રોસેસર્સમાં એ જ મોડેલ ઓબ્જેક્ટ કામ કરે છે.
- કી
apiKeyમાં આપો, ઉદાહરણ તરીકેSHANNON_API_KEYમાંથી; Mastra ના ડોક્સ કસ્ટમ એન્ડપોઇન્ટ માટે તે જાતે વાંચતા કોઈ ચલનું નામ આપતા નથી.
મુશ્કેલી નિવારણ
| લક્ષણ | કારણ | ઉકેલ |
|---|---|---|
404 Not Found | url માં /v1 નથી અથવા તે /chat/completions થી પૂરું થાય છે. | https://api.shannon-ai.com/v1 વાપરો. |
401 | apiKey ખાલી છે. | કી apiKey માં આપો. |
401 Unauthorized | કી ખૂટે છે, ખોટી ટાઇપ થઈ છે અથવા રોટેટ થઈ ગઈ છે. | Keys & usage પરથી કી ફરી કોપી કરો; તે sk- થી શરૂ થાય છે. |
context_length_exceeded અથવા "prompt is too long" સંદેશ | વાતચીત મોડેલની કોન્ટેક્સ્ટ વિન્ડો કરતાં લાંબી છે. | નવી ચેટ શરૂ કરો, ટૂલને તેને કૉમ્પેક્ટ કરવા દો અથવા મોટી વિન્ડોવાળું મોડેલ પસંદ કરો. |
insufficient_quota | તમારું બેલેન્સ આ રિક્વેસ્ટની ચુકવણી માટે પૂરતું નથી. | ટોપ-અપ કરો અથવા પ્લાન બદલો; રિક્વેસ્ટ આપમેળે ફરી પ્રયાસ થતી નથી. |
પ્રશ્નો
શું Mastra Shannon સાથે કામ કરે છે?
હા: url: "https://api.shannon-ai.com/v1" સાથેનું એજન્ટ મોડેલ { id, url, apiKey } Shannon સુધી પહોંચે છે.
શું Mastra ટૂલ્સ કામ કરે છે?
હા; createTool ટૂલ્સ નેટિવ ટૂલ કોલ્સ તરીકે મોકલાય છે.