Anthropic
Ka tango te POST /v1/messages i tētahi tono i te hōputu Anthropic Messages ka whakautu i te hōputu ōrite, e stream ana, kāore rānei. Whakamahia ki te Anthropic SDK me ngā taputapu i hangaia ki runga, pēnei i a Claude Code: tautuhia te base URL, whakamahia tō Shannon API key, ka ingoatia he model id Shannon.
POST https://api.shannon-ai.com/v1/messages
Tohua te Anthropic SDK ki te base URL o Shannon. Ka tāpiri te SDK i te /v1/messages ka tuku i tō key i te header x-api-key.
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.shannon-ai.com",
)
message = client.messages.create(
model="shannon-3",
max_tokens=1024,
messages=[{"role": "user", "content": "Say hello in one sentence."}],
)
for block in message.content:
if block.type == "text":
print(block.text) import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com",
});
const message = await client.messages.create({
model: "shannon-3",
max_tokens: 1024,
messages: [{ role: "user", content: "Say hello in one sentence." }],
});
for (const block of message.content) {
if (block.type === "text") console.log(block.text);
} curl https://api.shannon-ai.com/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "shannon-3",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}' He karere te whakautu e rārangi poraka ana tōna content. Kimihia ngā poraka mā tō rātou type: ina reasoning te model, ko te poraka tuatahi ko thinking, ā, ka whai te kuputuhi i muri.
{
"id": "msg_5f0c1e7a9b3d4c62a8e1f07d2b46c9a3",
"type": "message",
"role": "assistant",
"model": "shannon-3",
"content": [
{
"type": "thinking",
"thinking": "The user wants a greeting in one sentence. Keep it short and friendly."
},
{
"type": "text",
"text": "Hello, it is good to meet you."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 1184,
"output_tokens": 46
}
} Ngā header
| Header | Uara | Whakaahuatanga |
|---|---|---|
x-api-key | YOUR_API_KEY | Tō API key. Ka whakaaetia te Authorization: Bearer YOUR_API_KEY hei whakakapi. |
content-type | application/json | Hiahiatia. |
anthropic-version | 2023-06-01 | Ka whakaaetia, kāore e hiahiatia. Ka tuku te Anthropic SDK i te 2023-06-01; ōrite tonu te hōputu o te whakautu ahakoa te uara. |
anthropic-beta | Ka whakaaetia, kāore e hiahiatia. | |
x-request-id | Kōwhiringa. Tō ake id mō te tono. Ka hoki mai kāore i huri i te whakautu; mēnā kāore, he id 12 tohu hekihekimara tā te whakautu. |
Ngā āpure tono
Ko te messages anake te mea e hiahiatia ana. Ko te pou Whakamahia e e ingoa ana i ngā model e huri ai te whakautu mā tētahi āpure. Ko ngā model open-weight hosted ko ngā id tekau mā rua o te rārangi model; ko te whānau Shannon 3 ko shannon-3, shannon-3-pro, shannon-3.1 me shannon-3.1-pro. Ngā model me ngā utu
| Āpure | Momo | Taunoa | Whakaahuatanga | Whakamahia e |
|---|---|---|---|---|
model | string | shannon-1.6-lite | He model id Shannon mai i te rārangi model. Tukuna i ia tono. Kāore e aro ki te rahi o ngā reta. Ka whakahoki tētahi atu ingoa i te 400 unknown model, nō reira me tautuhi te taputapu e tuku ana i ōna ake ingoa model ki tētahi id Shannon. | Ngā model katoa |
messages | array | Hiahiatia. Te kōrero, te karere tawhito rawa i te tuatahi, me ngā role user me assistant. Tirohia Ngā karere me ngā poraka ihirangi i raro nei. | Ngā model katoa | |
system | string | array | Ngā tohutohu mō te model: he rārangi tuhi, he rārangi poraka kuputuhi rānei. Tirohia System prompt i raro nei. | Ngā model open-weight hosted, shannon-1.6-*, shannon-2-*, shannon-coder-1 | |
max_tokens | integer | 4096 | Te tepe o runga o te whakautu, i roto i ngā tokens. Kōwhiringa i tēnei endpoint; ka tuku tonu te Anthropic SDK. Ka nekehia he uara i waho i te 1 ki te 65,536 ki roto i taua whānui. Koia hoki te nui ka wehea mai i tō toenga i te wā e rere ana te tono. | Ngā model open-weight hosted, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 |
stream | boolean | false | Ka tuku te true i te whakautu hei server-sent events. Tirohia Streaming i raro nei. | Ngā model katoa |
temperature | number | Te pāmahana tauira. I runga i ngā model open-weight hosted ka mau ngā uara ki waenga i te 0 me te 2. | Ngā model open-weight hosted, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | |
top_p | number | Nucleus sampling. | Ngā model open-weight hosted | |
stop_sequences | array | Tae atu ki te 4 aho. Ka mutu te whakautu i mua i te tuatahi e puta ana. Ka noho te stop_reason ko end_turn. | Ngā model open-weight hosted | |
tools | array | Ngā tools ka taea e te model te karanga, ia tētahi hei {"name", "description", "input_schema"}. Tirohia Tools i raro nei. | Ngā model katoa | |
tool_choice | object | Mā te {"type": "auto"} e whakatau te model, mā te {"type": "any"} e karanga ia i tētahi tool, mā te {"type": "tool", "name": "…"} e karanga ia i taua tool. | Ngā model open-weight hosted | |
thinking | object | Te nui o te whakaaro a te model i mua i tana whakautu. Tirohia Thinking i raro nei. | Ngā model open-weight hosted | |
web_search | boolean | false | He tāpiritanga a Shannon ki te hōputu: mā te true e rapu te model i te tukutuku i mua i tana whakautu. | shannon-1.6-*, shannon-2-*, te whānau Shannon 3 |
Mēnā kāore he max_tokens ko te uara 4,096, ā, 65,536 i runga i te shannon-coder-1.
Ka whakaaetia te metadata, te top_k, te service_tier me ngā tohu cache_control i runga i ngā poraka kia kore ai e huri te code kiritaki o nāianei. Kāore ō rātou pānga ki te whakautu; he aunoa te prompt caching i runga i ngā model open-weight hosted.
Ka tonoa he whakautu JSON ki tētahi schema mā te response_format i runga i Chat Completions me te text.format i runga i Responses. Putanga hanganga
He tono me tētahi system prompt me te thinking
Ka tuku tēnei tono i tētahi system prompt, i tētahi tahua thinking, i tētahi temperature me tētahi stop sequence. Ka whakamahi i tētahi model open-weight hosted, ka whakamahi i te katoa.
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.shannon-ai.com",
)
message = client.messages.create(
model="DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
max_tokens=4096,
system="You are a physics teacher. Answer in two sentences.",
thinking={"type": "enabled", "budget_tokens": 2048},
temperature=0.3,
stop_sequences=["\n\n"],
messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
for block in message.content:
if block.type == "thinking":
print("reasoning:", block.thinking)
elif block.type == "text":
print("answer:", block.text)
print(message.usage) import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com",
});
const message = await client.messages.create({
model: "DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
max_tokens: 4096,
system: "You are a physics teacher. Answer in two sentences.",
thinking: { type: "enabled", budget_tokens: 2048 },
temperature: 0.3,
stop_sequences: ["\n\n"],
messages: [{ role: "user", content: "Why is the sky blue?" }],
});
for (const block of message.content) {
if (block.type === "thinking") console.log("reasoning:", block.thinking);
if (block.type === "text") console.log("answer:", block.text);
}
console.log(message.usage); curl https://api.shannon-ai.com/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
"max_tokens": 4096,
"system": "You are a physics teacher. Answer in two sentences.",
"thinking": {"type": "enabled", "budget_tokens": 2048},
"temperature": 0.3,
"stop_sequences": ["\n\n"],
"messages": [{"role": "user", "content": "Why is the sky blue?"}]
}' I runga i ngā model open-weight hosted ka pūrongo te usage i ngā tokens i pānuitia mai i te prompt cache motuhake i ētahi atu input tokens.
{
"usage": {
"input_tokens": 31,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0,
"output_tokens": 62
}
} System prompt
Ko te system he rārangi tuhi, he rārangi poraka kuputuhi rānei i te āhua [{"type": "text", "text": "…"}]. Ka honoa ngā kuputuhi o ngā poraka ki tētahi pae rārangi.
Ka whakamahia e ngā model open-weight hosted, shannon-1.6-lite, shannon-1.6-pro, shannon-2-lite, shannon-2-pro me shannon-coder-1. Me tētahi id o te whānau Shannon 3, whakatōngia ngā tohutohu me mau ki roto i te karere kaiwhakamahi.
Ngā karere me ngā poraka ihirangi
He role tā te karere, user he assistant rānei, me tētahi content. Ko te content he rārangi tuhi, he rārangi poraka rānei.
| Poraka | Whakaahuatanga | Kei |
|---|---|---|
{"type": "text", "text": "…"} | Kuputuhi. | Ngā model katoa |
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "…"}}{"type": "image", "source": {"type": "url", "url": "…"}} | He whakaahua i roto i tētahi karere user, hei base64, mā te URL rānei. | Te whānau Shannon 3, shannon-1.6-lite, shannon-1.6-pro, me ngā model open-weight hosted e whakarārangi ana i te input whakaahua |
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} | He tuhinga (PDF, Word, PowerPoint, Excel rānei) i roto i tētahi karere user, hei base64, mā te URL rānei. | Te whānau Shannon 3 |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | I roto i tētahi karere assistant: he tool call i mahia e te model i tētahi whakautu o mua. | Ngā model katoa |
{"type": "tool_result", "tool_use_id": "toolu_…", "content": "…"} | I roto i tētahi karere user: te hua o taua karanga. Ko te content he rārangi tuhi, he rārangi poraka kuputuhi rānei. | Ngā model katoa |
Ka taea te tuku anō i te content o tētahi whakautu o mua pēnei tonu: ka pānuitia ngā poraka text me tool_use, ka whakaarotia ngā poraka thinking.
I runga i ngā taumata Shannon ka pānuitia ngā whakaahua me ngā tuhinga mai i te karere user whakamutunga. He whārangi motuhake ō ngā rahi me ngā tepe. Ngā whakaahua me ngā kōnae
Thinking
Ka tātai ngā model open-weight hosted i te thinking ki tētahi reasoning effort. Mēnā kāore he āpure, he high te effort.
| Āhua | budget_tokens | Pānga |
|---|---|---|
{"type": "disabled"} | Kāore he reasoning. Kāore he poraka thinking i te whakautu. | |
{"type": "enabled", "budget_tokens": 2048} | ≤ 2,048 | Effort iti. |
{"type": "enabled", "budget_tokens": 8192} | ≤ 8,192 | Effort waenga. |
{"type": "enabled", "budget_tokens": 16000} | > 8,192 | Effort teitei. |
Ka whakahoki te model e reasoning ana i tāna reasoning hei poraka {"type": "thinking", "thinking": "…"} i mua i te kuputuhi. Ka tuku hoki ngā taumata Shannon e reasoning ana.
Kei tō rātou ake whārangi te whakaahuatanga o ngā effort. Reasoning effort
Tools
He tūnga mahi tētahi tool e whakahaerea ana e tō code. Whakaahuatia ia tētahi mā te name, te description me te input_schema. Ina hiahia te model ki tētahi tool, kei te whakautu tētahi poraka tool_use, ā, ko te stop_reason ko tool_use.
He tautuhinga tool i te tools:
[
{
"name": "get_weather",
"description": "Current weather for a city.",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": [
"city"
]
}
}
] Te content o tētahi whakautu e karanga ana i a ia:
[
{
"type": "text",
"text": ""
},
{
"type": "tool_use",
"id": "toolu_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
"name": "get_weather",
"input": {
"city": "Paris"
}
}
] Whakahaerea te tool, kātahi tukuna anō te tono me te karanga me tētahi poraka tool_result kua tāpiria ki te messages:
[
{
"role": "user",
"content": "What is the weather in Paris?"
},
{
"role": "assistant",
"content": [
{
"type": "tool_use",
"id": "toolu_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
"name": "get_weather",
"input": {
"city": "Paris"
}
}
]
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
"content": "{\"temperature_c\": 18, \"sky\": \"cloudy\"}"
}
]
}
] tool_choice
| Āhua | Pānga | Whakamahia e |
|---|---|---|
{"type": "auto"} | Ka whakatau te model me karanga i tētahi tool, kāore rānei. Koia te taunoa. | Ngā model katoa |
{"type": "any"} | Me karanga te model i tētahi o ngā tools. | Ngā model open-weight hosted |
{"type": "tool", "name": "…"} | Me karanga te model i te tool kua ingoatia. | Ngā model open-weight hosted |
Ko ngā tools anake me tētahi input_schema ka pānuitia. Ehara te rapu tukutuku i tētahi tool i tēnei endpoint: tautuhia te āpure web_search.
Kei tōna ake whārangi te whakaahuatanga katoa o te tool loop. Karanga ā‑mahi
Te whakautu
| Āpure | Momo | Whakaahuatanga | Tukuna e |
|---|---|---|---|
id | string | msg_ ka whai i te 32 tohu hekihekimara. | Ngā model katoa |
type | string | Ko message i ngā wā katoa. | Ngā model katoa |
role | string | Ko assistant i ngā wā katoa. | Ngā model katoa |
model | string | Te id ōkawa o te model nāna i whakautu. | Ngā model katoa |
content | array | Ngā poraka o te whakautu, i tēnei raupapa: thinking mēnā i reasoning te model, text, kātahi he tool_use kotahi mō ia tool call. | Ngā model katoa |
stop_reason | string | Te take i mutu ai te whakautu. Tirohia ngā uara i raro nei. | Ngā model katoa |
usage | object | input_tokens me output_tokens. | Ngā model katoa |
sources | array | I runga anake i tētahi tono me te web_search: true i kitea he mea e tana rapu: ngā hua i hoatu ki te model, he index, he title me he url ō ia tētahi. Ko te [1] i te whakautu te tāurunga whai index 1. I roto i te stream ka tae mai me te takunetanga message_delta. | shannon-1.6-*, shannon-2-*, te whānau Shannon 3 |
usage.cache_read_input_tokens | integer | Ko cache_read_input_tokens te wāhanga o te prompt i pānuitia mai i te cache; ko input_tokens te toenga. Ko cache_creation_input_tokens he 0 i ngā wā katoa. | Ngā model open-weight hosted |
Ngā poraka whakautu
| Poraka | Whakaahuatanga |
|---|---|
{"type": "thinking", "thinking": "…"} | Te reasoning a te model. Kāore he mema signature. |
{"type": "text", "text": "…"} | Te kuputuhi whakautu. Ka taea te tūwhera mēnā he tool call te whakautu. |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | He tool call. He JSON object te input. Tukuna anō te hua me te id ōrite. |
stop_reason
| stop_reason | Whakaahuatanga | Tukuna e |
|---|---|---|
end_turn | Kua oti i te model tana whakautu, kua puta rānei tētahi o ō stop_sequences. | Ngā model katoa |
tool_use | Kotahi neke atu rānei ngā tool call kei te whakautu. | Ngā model katoa |
max_tokens | I tapahia te whakautu i te tepe output. | Te whānau Shannon 3, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1, i roto i ngā stream |
Streaming
Tautuhia te stream ki te true mō ngā server-sent events. He rārangi event: tō ia frame me te ingoa o te tuhinga me tētahi rārangi data: me tētahi JSON object e whakahua anō ana i te ingoa i te type. Ka pānui ngā kaiāwhina stream o te Anthropic SDK i ēnei tuhinga mōu:
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.shannon-ai.com",
)
with client.messages.stream(
model="shannon-3",
max_tokens=1024,
messages=[{"role": "user", "content": "Explain server-sent events in three sentences."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
message = stream.get_final_message()
print()
print(message.stop_reason, message.usage) import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com",
});
const stream = client.messages.stream({
model: "shannon-3",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain server-sent events in three sentences." }],
});
stream.on("text", (text) => process.stdout.write(text));
const message = await stream.finalMessage();
console.log("\n", message.stop_reason, message.usage); curl -N https://api.shannon-ai.com/v1/messages \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "shannon-3",
"max_tokens": 1024,
"stream": true,
"messages": [{"role": "user", "content": "Explain server-sent events in three sentences."}]
}' Ngā tuhinga, i te raupapa e tae mai ai:
| Tuhinga | Raraunga | Āhea |
|---|---|---|
message_start | message | Tuatahi i ngā wā katoa. Kei te message te id, te role, te model, tētahi content kau me tētahi usage e tīmata ana i te kore. |
content_block_start | index, content_block | Ka tuwhera tētahi poraka. Ko te content_block he poraka text, thinking kau rānei, he poraka tool_use rānei me tōna id me tōna name. |
content_block_delta | index, delta {"type": "thinking_delta", "thinking"} | He wāhi o te reasoning, mō tētahi poraka thinking. |
content_block_delta | index, delta {"type": "text_delta", "text"} | He wāhi o te whakautu, mō tētahi poraka text. |
content_block_delta | index, delta {"type": "input_json_delta", "partial_json"} | Ngā tohenga o tētahi tool call, oti i tētahi delta, mō tētahi poraka tool_use. |
content_block_stop | index | Kua oti te poraka me tēnei index. |
message_delta | delta {stop_reason, stop_sequence}, usage | Te mutunga o te whakautu: delta.stop_reason, me te usage o te tono. |
message_stop | Whakamutunga i ngā wā katoa. |
Ka tau ngā poraka mā te index i te raupapa o tō rātou tuwhera, ā, ka oti tētahi poraka i mua i te tuwhera o te whai muri. Pānuitia ia poraka mā tōna momo, kaua mā tōna tau: ka tuwhera pea tētahi stream i tētahi poraka text kau tuatahi, kātahi te poraka thinking, ā, ka tuku i te whakautu i tētahi poraka text o muri mai.
event: message_start
data: {"type":"message_start","message":{"id":"msg_5f0c…","type":"message","role":"assistant","model":"shannon-3","content":[],"usage":{"input_tokens":0,"output_tokens":0}}}
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
event: content_block_stop
data: {"type":"content_block_stop","index":0}
event: content_block_start
data: {"type":"content_block_start","index":1,"content_block":{"type":"thinking","thinking":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":1,"delta":{"type":"thinking_delta","thinking":"Three sentences: what it is, how it is framed, why it is used."}}
event: ping
data: {"type": "ping"}
event: content_block_stop
data: {"type":"content_block_stop","index":1}
event: content_block_start
data: {"type":"content_block_start","index":2,"content_block":{"type":"text","text":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":2,"delta":{"type":"text_delta","text":"Server-sent events let a server push text over one HTTP reply."}}
event: content_block_stop
data: {"type":"content_block_stop","index":2}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"input_tokens":1190,"output_tokens":84}}
event: message_stop
data: {"type":"message_stop"} Keep-alive
| Tukuna e | Whakaahuatanga |
|---|---|
Te whānau Shannon 3, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | He tuhinga ping me te raraunga {"type": "ping"}, ia 15 hekona. |
| Ngā model open-weight hosted | He rārangi kōrero : keepalive, ia 15 hekona i te wā e mahi ana te model. |
He stream ka rahua
Ko te rahua i muri i te tīmatanga o te stream he tuhinga error me te tinana ōrite ki te whakautu hapa: {"type": "error", "error": {"type", "message"}}. Ka whai tonu ngā tuhinga whakamutu, message_delta me message_stop. Whakaarohia kua rahua te whakautu ka tuku anō i te tono.
Ngā hapa
Ka whakamahi ngā hapa i te tinana hapa Anthropic: ko te type ko error, ā, kei te error object tētahi type me tētahi message. Ka rārangi te ripanga i ngā mea e hoki mai ana i tēnei endpoint i te nuinga o te wā. He whārangi motuhake tō te rārangi katoa, me ngā mea hei whakamātau anō. Whakahaere hapa
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "unknown model: no-such-model"
}
} | Tūnga | Momo | Karere | Āhea |
|---|---|---|---|
401 | authentication_error | Missing authenticationInvalid API key | Kāore he API key i tukuna, kāore rānei i te mōhiotia te key, kua whakakorea rānei. |
400 | invalid_request_error | unknown model: <id> | Ehara te model i te model id Shannon. |
400 | invalid_request_error | No user message provided | Ngā taumata Shannon: kāore he kuputuhi kaiwhakamahi me he tools i te tono. |
400 | invalid_request_error | <id> does not accept image input | I tukuna he whakaahua ki tētahi model open-weight hosted kāore he input whakaahua. |
422 | invalid_request_error | Failed to deserialize the JSON body into the target type: … | Kua ngaro te messages, he hē rānei te momo JSON o tētahi āpure. |
429 | rate_limit_error | Quota exceeded. Upgrade your plan at shannon-ai.com/plan | He nui ake te max_tokens i te toenga o tō toenga. |
429 | rate_limit_error | Too many requests. Retry in <n>s. | Flood protection: neke atu i te 120 tono i roto i te meneti kotahi i tō pūkete. |
429 | rate_limit_error | Shannon Coder call quota reached. Upgrade your plan at shannon-ai.com/plan | shannon-coder-1: kua pau ngā karanga Shannon Coder o tō mahere mō te matapihi 4-hāora o nāianei. |
500 | server_error | The model backend failed to answer. Please retry. | Kāore te model i hanga whakautu. Tukuna anō te tono. |
502 | api_error | The model backend failed to answer. Please retry. | Kāore te model i hanga whakautu. Tukuna anō te tono. |
Te tātai tokens
Ka tango te POST /v1/messages/count_tokens i te tinana ōrite ki te tono karere (model, system, messages, tools) ka whakahoki i te {"input_tokens": n}: te maha o ngā input tokens ka utua mō te tono. Ka tātaihia mō ngā model open-weight hosted, kore utu, ā, kāore e tātaihia e te flood protection.
import anthropic
client = anthropic.Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.shannon-ai.com",
)
count = client.messages.count_tokens(
model="DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
system="You are a physics teacher. Answer in two sentences.",
messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
print(count.input_tokens) import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com",
});
const count = await client.messages.countTokens({
model: "DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
system: "You are a physics teacher. Answer in two sentences.",
messages: [{ role: "user", content: "Why is the sky blue?" }],
});
console.log(count.input_tokens); curl https://api.shannon-ai.com/v1/messages/count_tokens \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
"system": "You are a physics teacher. Answer in two sentences.",
"messages": [{"role": "user", "content": "Why is the sky blue?"}]
}'
# {"input_tokens": 31} He whārangi motuhake tō te tātai, me te endpoint kuputuhi māmā me ngā tepe. Te tatau token