Whakamahia a Anthropic SDK me Shannon
Kia mau ki te SDK Anthropic: tautuhia te base_url ki a Shannon, tukuna tō key, ka karanga i ngā model Shannon mā te Messages API.
- I whakamātauria 7 Noe 2026
- Anthropic Messages
- Tata ki te 1 meneti
Mō Anthropic SDK
Ko te SDK Anthropic te kiritaki whaimana mō te Messages API, e whakamahia ana e ngā taupānga me ngā kaiwhakaahei i hangaia mō Claude. Ka whakahaere a Shannon i taua API ōrite i te /v1/messages, no reira ka rere te waehere i tuhia mō te SDK i runga i ngā model Shannon whai muri i ngā huringa e rua: te base URL me te key. Ka mahi pēnei ano te rere, te whakamahi tool me ngā tohutohu pūnaha.
Ngā mea e hiahiatia ana
- He API key Shannon
- Ngā kī me te whakamahinga
- URL pūtake
-
https://api.shannon-ai.comPito mutunga:/v1/messages - Ka whai ia wāhanga waehere i raro iho i tō kōwhiringa.
Whakaritea
-
Whakaurua te SDK
pip install anthropicnpm install @anthropic-ai/sdk -
Tohua ki a Shannon ka rere
Kāore he
/v1i te base URL: ka tāpiri te SDK i te/v1/messagesmā tōna ake. Hiahiatia ana temax_tokens, pēnei i a Claude.Pythonfrom anthropic import Anthropic client = Anthropic(base_url="https://api.shannon-ai.com", api_key="YOUR_API_KEY") with client.messages.stream( model="Kimi-K3-uncensored-NVFP4", max_tokens=1024, messages=[{"role": "user", "content": "Name three colours a cat can be."}], ) as stream: for text in stream.text_stream: print(text, end="", flush=True) -
Karanga i ngā tool
Ka hoki mai ngā karanga tool hei poraka
tool_useme testop_reason: "tool_use".Pythonr = client.messages.create( model="Kimi-K3-uncensored-NVFP4", max_tokens=1024, tools=[{ "name": "get_weather", "description": "Weather for a city", "input_schema": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}, }], messages=[{"role": "user", "content": "What is the weather in Oslo?"}], ) print(r.stop_reason) # tool_use print([b.input for b in r.content if b.type == "tool_use"]) # [{'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.
Ngā model e hāngai ana ki Anthropic SDK
Ka tutuki i ia id i raro iho ngā hiahia o Anthropic 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
- Ko te
base_urlkohttps://api.shannon-ai.comkāore he/v1; mēnā he/v1, ka karanga te SDK i te/v1/v1/messageska whiwhi i te404. - Ka tuku te SDK i te key hei
x-api-key; ka whakaae hoki a Shannon i teAuthorization: Bearer. - Whakamahia ngā id model Shannon mai i te
GET /v1/models; kāore ngā id Claude e whakahaeretia.
Ngā tohutohu
- Ka pānui hoki te SDK i te
ANTHROPIC_BASE_URLme teANTHROPIC_API_KEY, no reira ka taea e te waehere o nāianei te whakawhiti mā ngā taurangi taiao e rua. - Ka whakamahi ngā taputapu i hangaia mō Claude, pēnei i a Claude Code me ngā kaiwhakaahei i runga i te Claude Agent SDK, i te endpoint ōrite.
- I TypeScript ko ngā kōwhiringa ko
baseURLmeapiKey.
Te whakatika raruraru
| Tohu | Take | Whakatika |
|---|---|---|
404 Not Found | Ka mutu te base_url ki te /v1. | Whakamahia https://api.shannon-ai.com. |
400 unknown model | He id model Claude. | 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
Ka mahi te SDK Anthropic me Shannon?
Āe. Ka whakahaere a Shannon i te Messages API ki https://api.shannon-ai.com/v1/messages; tautuhia te base_url ki https://api.shannon-ai.com.
Ka mahi te rere me te whakamahi tool?
Āe, ngā mea e rua; i whakahaere mātou i tētahi rere me tētahi karanga tool mā te SDK Python.