Whakamahia a Mastra me Shannon
Hoatu ki tētahi kaiwhakaahei Mastra tētahi ahanoa model me te URL, key me te id a Shannon; ka rere te rere me ngā tool i runga i ngā model Shannon.
- I whakamātauria 7 Noe 2026
- OpenAI Chat Completions
- Tata ki te 3 meneti
Mō Mastra
He anga TypeScript a Mastra mō ngā kaiwhakaahei, ngā rerekētanga mahi, te mahara me te rapu, me tētahi taiwhanga whanake rohe. Ka tango ngā kaiwhakaahei i tētahi model mā tana ara-model, e whakaae ana ki tētahi endpoint hototahi ki OpenAI ina hoatu he URL me tētahi key. Nā tērā ka taea e ngā kaiwhakaahei me ngā rerekētanga mahi a Mastra te rere i runga i ngā model Shannon.
Ngā mea e hiahiatia ana
- He API key Shannon
- Ngā kī me te whakamahinga
- URL pūtake
-
https://api.shannon-ai.com/v1Pito mutunga:/v1/chat/completions - Ka whai ia wāhanga waehere i raro iho i tō kōwhiringa.
Whakaritea
-
Whakaurua a Mastra
Shellnpm install @mastra/core zod -
Hangaia tētahi kaiwhakaahei i runga i a Shannon
Ko te
idko<any prefix>/<Shannon id>; ko teurlte base URL, ehara i te endpoint 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 }, }); -
Rere me te whakaputa
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);
Tirohia kei te mahi
Tukuna: Whakahaerehia te tauira me te SHANNON_API_KEY kua tautuhia.
Me kite koe i: Ka rere ngā tae, ka whai tētahi whakautu e whakamahi ana i te huarere a te tool.
Ngā model e hāngai ana ki Mastra
Ka tutuki i ia id i raro iho ngā hiahia o Mastra. Ko te tuatahi te taunoa i ngā wāhanga waehere.
| Id tauira | Matapihi horopaki | Output nui rawa | Input whakaahua |
|---|---|---|---|
Kimi-K3-uncensored-NVFP4 | 1,022,976 | 262,144 | Āe |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | Āe |
shannon-3 | 196,608 | 65,536 | Āe |
shannon-coder-1 | 131,072 | 65,536 | Kāo |
He pai kia mōhio
- Me mutu te
urlki te base URL e mutu ana ki te/v1; ka tāpiri a Mastra i te/chat/completions. - Tāpirihia te
api: "responses"ki te ahanoa model hei whakamahi i te/v1/responsesa Shannon hei utu.
Ngā tohutohu
- Rēhitatia ngā kaiwhakaahei ki tētahi tauira
Mastrakia kitea i te taiwhanga rohe (mastra dev). - Ka mahi te ahanoa model ōrite i ngā rerekētanga mahi me ngā tukatuka mahara e tango ana i tētahi model.
- Tukuna te key ki te
apiKey, hei tauira mai i teSHANNON_API_KEY; kāore ngā tuhinga a Mastra e whakaingoa i tētahi taurangi e pānuitia ana e ia mō tētahi endpoint ritenga.
Te whakatika raruraru
| Tohu | Take | Whakatika |
|---|---|---|
404 Not Found | Kāore i te whai te url i te /v1, e mutu ana rānei ki te /chat/completions. | Whakamahia https://api.shannon-ai.com/v1. |
401 | He kau te apiKey. | Tukuna te key ki te apiKey. |
401 Unauthorized | Kei te ngaro te key, kua hē te pato, kua hurihia rānei. | Tāruatia anō te key mai i Keys & usage; ka tīmata ki te sk-. |
context_length_exceeded, te karere "prompt is too long" rānei | He roa ake te kōrero i te matapihi horopaki o te model. | Tīmatahia he kōrerorero hou, tukuna te taputapu kia whakamāmā, kōwhiria rānei he model he nui ake te matapihi. |
insufficient_quota | Kāore e rawaka tō toenga hei utu i te tono. | Tāpiri nama, huri mahere rānei; kāore te tono e ngana anō ko ia anake. |
Ngā pātai
Ka mahi a Mastra me Shannon?
Āe: ka tae tētahi model kaiwhakaahei { id, url, apiKey } me te url: "https://api.shannon-ai.com/v1" ki a Shannon.
Ka mahi ngā tool Mastra?
Āe; ka tukuna ngā tool createTool hei karanga tool taketake.