Sebelisa Vercel AI SDK le Shannon
Theha mofani ea lumellanang le OpenAI bakeng sa Shannon ka @ai-sdk/openai-compatible 'me u o sebelise ho streamText, generateText le li-tool.
- E lekiloe 2026 Pun 7
- OpenAI Chat Completions
- Metsotso e ka bang 2
Mabapi le Vercel AI SDK
AI SDK ke laeborari ea TypeScript ea Vercel ea ho haha likarolo tsa AI ho Node.js, Next.js le li-framework tse ling. E phuthela bafani ka sebopeho se le seng sa mongolo, streaming, li-tool le structured output. Phutheho ea @ai-sdk/openai-compatible e e hokela ho OpenAI-compatible API efe kapa efe, ho kenyeletsoa Shannon.
Seo u se hlokang
- Senotlolo sa API sa Shannon
- Linotlolo le tšebeliso
- Base URL
-
https://api.shannon-ai.com/v1Endpoint:/v1/chat/completions - Snippet e 'ngoe le e 'ngoe e ka tlase e latela khetho ea hau.
E hlophise
-
Kenya liphutheho
Shellnpm install ai @ai-sdk/openai-compatible zod -
Theha mofani 'me u etse streaming
namee bitsa mofani ho liphoso le metadata;baseURLe qetella ka/v1.TypeScriptimport { createOpenAICompatible } from "@ai-sdk/openai-compatible"; import { streamText } from "ai"; const shannon = createOpenAICompatible({ name: "shannon", baseURL: "https://api.shannon-ai.com/v1", apiKey: process.env.SHANNON_API_KEY, }); const result = streamText({ model: shannon("Kimi-K3-uncensored-NVFP4"), prompt: "Name three colours a cat can be.", }); for await (const text of result.textStream) process.stdout.write(text); -
Bitsa li-tool
TypeScriptimport { generateText, tool } from "ai"; import { z } from "zod"; const { toolCalls } = await generateText({ model: shannon("Kimi-K3-uncensored-NVFP4"), prompt: "What is the weather in Oslo?", tools: { getWeather: tool({ description: "Weather for a city", inputSchema: z.object({ city: z.string() }), }), }, }); console.log(toolCalls[0].input); // { city: "Oslo" }
Hlahloba hore e a sebetsa
Romela: Tsamaisa sampole ea streaming ha SHANNON_API_KEY e setiloe.
U lokela ho bona: Mebala e hatisoa ha e ntse e fihla.
Li-model tse loketseng Vercel AI SDK
Id e 'ngoe le e 'ngoe e ka tlase e khotsofatsa seo Vercel AI SDK e se hlokang. Ea pele ke default ho li-snippet.
| Id ea model | Fensetere ea context | Tsoa e kholo ka ho fetisisa | Kenyo ea setšoantšo |
|---|---|---|---|
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 | Che |
Ho molemo ho tseba
- Sebelisa
@ai-sdk/openai-compatible, phutheho ea AI SDK bakeng sa li-API tse lumellanang le OpenAI;@ai-sdk/openaie hahiloe mabapi le API ea OpenAI ka boeona le likhetho tsa eona. - Li-schema tsa li-tool li sebelisa
inputSchemaho lithuto tsa hajoale tsa AI SDK (litataiso tsa khale li bontšaparameters).
Malebela
- Eketsa
executeho tool 'me u setastopWhenhore SDK e tsamaise tool 'me e khutlisetse sephetho pitsong e le 'ngoe. shannon.chatModel(id)e tšoana leshannon(id);namee boetse e kenyelletsa pele likhetho tse khethehileng tsa mofani.- Boloka senotlolo ho
SHANNON_API_KEY'me u se bale kaprocess.env, ho se ke ha e ba ho code ea ka lehlakoreng la client.
Ho rarolla mathata
| Matšoao | Lebaka | Tokiso |
|---|---|---|
404 Not Found | baseURL ha e na /v1. | Sebelisa https://api.shannon-ai.com/v1. |
toolCalls e se na letho | Model e arabileng ka mongolo. | Sebelisa model e nang le tool calls ho tsoa ho picker, kapa u seta toolChoice: "required". |
401 Unauthorized | Senotlolo ha se eo, se ngotsoe hampe kapa se fetotsoe. | Kopitsa senotlolo hape ho tsoa ho Keys & usage; se qala ka sk-. |
context_length_exceeded / “prompt is too long” | Puisano e telele ho feta window ea model. | Qala chat e ncha, tlohela tool e e compact, kapa khetha model e nang le window e kholoanyane. |
insufficient_quota | Balance ea hau e ke ke ea lefella kopo. | Eketsa credit kapa fetola plan; kopo ha e lekoe hape ka boeona. |
Lipotso
Na Vercel AI SDK e sebetsa le Shannon?
E, ka createOpenAICompatible e nang le baseURL: "https://api.shannon-ai.com/v1".
Na nka e sebelisa ho li-route handler tsa Next.js?
E; theha mofani ho server 'me u etse stream ea sephetho ho browser.