Whakamahia a OpenAI SDK me Shannon
Kia mau ki te SDK OpenAI e whakamahia ana e koe: whakawhitia te base URL me te key, ka kōwhiria tētahi id model Shannon.
- I whakamātauria 7 Noe 2026
- OpenAI Chat Completions
- Tata ki te 1 meneti
Mō OpenAI SDK
Ko ngā wharepukapuka whaimana a OpenAI mō Python me Node.js te huarahi noa rawa hei karanga i tētahi API chat mai i te waehere. E whakaae ana ki tētahi base URL, no reira ka mahi te waehere ōrite ki a Shannon: chat completions, te rere, ngā karanga tool me te Responses API.
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 te SDK
pip install openainpm install openai -
Tohua ki a Shannon
Ko te kiritaki anake e huri ana. Ka pānui hoki ngā SDK i te
OPENAI_BASE_URLme teOPENAI_API_KEYmai i te taiao.from openai import OpenAI client = OpenAI(base_url="https://api.shannon-ai.com/v1", api_key="YOUR_API_KEY") stream = client.chat.completions.create( model="Kimi-K3-uncensored-NVFP4", messages=[{"role": "user", "content": "Name three colours a cat can be."}], stream=True, ) for chunk in stream: if chunk.choices and chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="")import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.shannon-ai.com/v1", apiKey: "YOUR_API_KEY" }); const stream = await client.chat.completions.create({ model: "Kimi-K3-uncensored-NVFP4", messages: [{ role: "user", content: "Name three colours a cat can be." }], stream: true, }); for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? ""); -
Karanga i ngā tool
Ka mahi ngā tool pēnei i a OpenAI: ka mutu te whakautu ki te
finish_reason: "tool_calls"me ngā karanga i roto i temessage.tool_calls.Pythontools = [{"type": "function", "function": { "name": "get_weather", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}, }}] r = client.chat.completions.create( model="Kimi-K3-uncensored-NVFP4", messages=[{"role": "user", "content": "What is the weather in Oslo?"}], tools=tools, ) print(r.choices[0].message.tool_calls[0].function.arguments) # {"city": "Oslo"}
Tirohia kei te mahi
Tukuna: Whakahaerehia te tauira rere.
Me kite koe i: Ka taia ngā tae i a rātou e rere mai ana, hei tauira "Cats can be black, white, and orange."
Ngā model e hāngai ana ki OpenAI SDK
Ka tutuki i ia id i raro iho ngā hiahia o OpenAI SDK. 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
- Ka mahi hoki te
client.responses.create(...); ka whakahaere a Shannon i te/v1/responseskāore e tiaki i ngā whakautu, no reira tukuna te kōrero katoa i ia wā. - Ka tae te whakaaro hei
reasoning_contenti runga i tedeltao ia chunk, i te taha o tecontent. - Kāore he
/v1/embeddings; whakamahia tētahi model embedding motuhake mō te rapu.
Ngā tohutohu
- Tautuhia te
OPENAI_BASE_URLme teOPENAI_API_KEYi te taiao ā, ka tiki te kiritaki i a rāua kāore he tohutohu, no reira kāore he huringa mō te waehere o nāianei. - Tukuna te
stream=Truemō ngā whakautu roa; ka tae te kuputuhi me te whakaaro i a ia e tuhia ana. - Tautuhia te
max_retriesme tetimeouti te kiritaki: ka whakamātau anō te SDK i ngā whakautu429me5xxmā tōna ake. - Pānuitia te
usagei ia whakautu hei tuhi i te maha o ngā token i whakamahia e ia karanga, tae atu ki ērā kua tiakina ki te cache.
Te whakatika raruraru
| Tohu | Take | Whakatika |
|---|---|---|
404 Not Found | Kāore i te whai te base_url i te /v1. | Whakamahia https://api.shannon-ai.com/v1. |
400 unknown model | He ingoa model OpenAI pēnei i te gpt-4o. | Whakamahia tētahi id Shannon mai i te GET /v1/models. |
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
He whakakapi tika a Shannon mō te API OpenAI?
Mō ngā chat completions, te Responses API, te rere, ngā tool me ngā output whakaritea, āe: whakawhitia te base_url, te key me te id model.
Ka mahi hoki te SDK Anthropic?
Āe: ka kōrero te Anthropic(base_url="https://api.shannon-ai.com", api_key=...) ki te /v1/messages.