Ampiasao amin'i Shannon ny Anthropic SDK
Tazony ny SDK Anthropic: apetraho any amin'i Shannon ny base_url, ampio ny key-nao, ary antsoy ny model Shannon amin'ny Messages API.
- Notsapaina tamin'ny 7 Nov 2026
- Anthropic Messages
- Manodidina ny 1 min
Momba ny Anthropic SDK
Ny SDK Anthropic dia ny client ofisialy ho an'ny Messages API, ampiasain'ny application sy agent natao ho an'i Claude. Shannon dia manome ny API mitovy ao amin'ny /v1/messages, ka mandeha amin'ny model Shannon ny code nosoratana ho an'ny SDK aorian'ny fanovana roa: ny base URL sy ny key. Mitovy ny fandehany amin'ny streaming, tool use ary system prompt.
Izay ilainao
- API key Shannon
- Fanalahidy sy fampiasana
- Base URL
-
https://api.shannon-ai.comEndpoint:/v1/messages - Manaraka ny safidinao ny ohatra rehetra etsy ambany.
Fametrahana
-
Apetraho ny SDK
pip install anthropicnpm install @anthropic-ai/sdk -
Ampitondrao any amin'i Shannon ary manaova stream
Tsy misy
/v1ny base URL: ny SDK mihitsy no manampy ny/v1/messages. Ilaina nymax_tokens, tahaka ny amin'i 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) -
Miantso tool
Miverina ho block
tool_usemiaraka amin'nystop_reason: "tool_use"ny antso tool.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'}]
Hamarino fa miasa
Alefaso: Alefaso ny santionany streaming.
Tokony ho hitanao: Voaonta mandritra ny stream ny loko.
Model mifanaraka amin'ny Anthropic SDK
Mahafeno izay ilain'ny Anthropic SDK ny id rehetra etsy ambany. Ny voalohany no default ao amin'ny ohatra kaody.
| Id model | Context window | Output farany | Sary ho fidirana |
|---|---|---|---|
Kimi-K3-uncensored-NVFP4 | 1,022,976 | 262,144 | Eny |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | Eny |
shannon-3 | 196,608 | 65,536 | Eny |
shannon-coder-1 | 131,072 | 65,536 | Tsia |
Tsara ho fantatra
- Ny
base_urldiahttps://api.shannon-ai.comtsy misy/v1; raha misy/v1, antsoin'ny SDK ny/v1/v1/messagesary mahazo404. - Mandefa ny key ho
x-api-keyny SDK; Shannon koa dia mandray nyAuthorization: Bearer. - Ampiasao id model Shannon avy amin'ny
GET /v1/models; tsy omena ny id Claude.
Toro-hevitra
- Mamaky koa ny
ANTHROPIC_BASE_URLsyANTHROPIC_API_KEYny SDK, ka afaka mifindra amin'ny environment variable roa ny code efa misy. - Ny tool natao ho an'i Claude, toy ny Claude Code sy ny agent amin'ny Claude Agent SDK, dia mampiasa ny endpoint mitovy.
- Amin'ny TypeScript dia
baseURLsyapiKeyny option.
Famahana olana
| Soritr'aretina | Antony | Vahaolana |
|---|---|---|
404 Not Found | Mifarana amin'ny /v1 ny base_url. | Ampiasao ny https://api.shannon-ai.com. |
400 unknown model | Id model Claude. | Ampiasao id Shannon avy amin'ny GET /v1/models. |
401 Unauthorized | Tsy ao ny key, diso soratra, na efa novaina. | Adikao indray ny key avy ao amin'ny Keys & usage; manomboka amin'ny sk- izy. |
context_length_exceeded na "prompt is too long" | Lava noho ny context window an'ny model ny resaka. | Manombohy chat vaovao, avelao ny fitaovana hanafohy azy, na misafidiana model manana window lehibe kokoa. |
insufficient_quota | Tsy ampy handoavana ny fangatahana ny balance-nao. | Ampio ny balance na ovay ny plan; tsy averina ho azy ny fangatahana. |
Fanontaniana
Mandeha miaraka amin'i Shannon ve ny SDK Anthropic?
Eny. Shannon dia manome ny Messages API ao amin'ny https://api.shannon-ai.com/v1/messages; apetraho ho https://api.shannon-ai.com ny base_url.
Mandeha ve ny streaming sy tool use?
Eny, roa daholo; nampandehanay stream sy tool call tamin'ny SDK Python.