Anthropic
Ny POST /v1/messages dia mandray fangatahana amin'ny endrika Anthropic Messages ary mamaly amin'ny endrika mitovy, streamed na tsia. Ampiasao miaraka amin'ny SDK Anthropic sy ny fitaovana naorina amin'izany, toy ny Claude Code: apetraho ny base URL, ampiasao ny API key Shannon-nao ary lazao ny model id Shannon.
POST https://api.shannon-ai.com/v1/messages
Ampitondrao any amin'ny base URL Shannon ny SDK Anthropic. Ny SDK no manampy ny /v1/messages ary mandefa ny key-nao ao amin'ny 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."}]
}' Ny valiny dia hafatra izay ny content-ny dia lisitry ny blocks. Tadiavo ny blocks araka ny type-ny: raha nanao reasoning ny model, thinking ny block voalohany ary ny soratra manaraka azy.
{
"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
}
} Headers
| Header | Sanda | Famaritana |
|---|---|---|
x-api-key | YOUR_API_KEY | Ny API key-nao. Ekena ho solony ny Authorization: Bearer YOUR_API_KEY. |
content-type | application/json | Ilaina. |
anthropic-version | 2023-06-01 | Ekena, tsy voatery. Ny SDK Anthropic dia mandefa 2023-06-01; mitovy foana ny endrika ny valiny na inona na inona ny sanda. |
anthropic-beta | Ekena, tsy voatery. | |
x-request-id | Tsy voatery. Ny id anao manokana ho an'ny fangatahana. Averina tsy miova ao amin'ny valiny; raha tsy misy dia misy id misy tarehintsoratra hexadecimal 12 ny valiny. |
Sahan'ny fangatahana
Ny messages ihany no ilaina. Ny tsanganana Ampiharin'ny dia manonona ny model izay anovan'ny saha ny valiny. Ny model open-weight hosted dia ny id roa ambin'ny folo ao amin'ny lisitry ny model; ny fianakavian'i Shannon 3 dia shannon-3, shannon-3-pro, shannon-3.1 ary shannon-3.1-pro. Model & vidiny
| Saha | Karazana | Default | Famaritana | Ampiharin'ny |
|---|---|---|---|---|
model | string | shannon-1.6-lite | Model id Shannon avy amin'ny lisitry ny model. Alefaso isaky ny fangatahana. Tsy mijery ny litera lehibe/kely ny fampitahana. Ny anarana hafa rehetra dia mamerina 400 unknown model, ka ny fitaovana mandefa anaran'ny model azy manokana dia tsy maintsy apetraka amin'ny id Shannon. | Model rehetra |
messages | array | Ilaina. Ny resaka, hafatra taloha indrindra no voalohany, miaraka amin'ny role user sy assistant. Jereo ny Hafatra sy content blocks etsy ambany. | Model rehetra | |
system | string | array | Toromarika ho an'ny model: string, na array misy text blocks. Jereo ny System prompt etsy ambany. | Model open-weight hosted, shannon-1.6-*, shannon-2-*, shannon-coder-1 | |
max_tokens | integer | 4096 | Fetra ambony indrindra ny valiny, amin'ny tokens. Tsy voatery amin'ity endpoint ity; ny SDK Anthropic dia mandefa azy foana. Ny sanda ivelan'ny 1 hatramin'ny 65,536 dia entina ao anatin'io elanelana io. Io ihany koa no habetsaky ny balance-nao tazonina raha mbola mandeha ny fangatahana. | Model open-weight hosted, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 |
stream | boolean | false | Ny true dia mandefa ny valiny ho server-sent events. Jereo ny Streaming etsy ambany. | Model rehetra |
temperature | number | Sampling temperature. Amin'ny model open-weight hosted dia tazonina eo anelanelan'ny 0 sy 2 ny sanda. | Model open-weight hosted, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | |
top_p | number | Nucleus sampling. | Model open-weight hosted | |
stop_sequences | array | Hatramin'ny string 4. Mifarana alohan'ny voalohany miseho ny valiny. Mijanona ho end_turn ny stop_reason. | Model open-weight hosted | |
tools | array | Ny tools azon'ny model antsoina, tsirairay amin'ny endrika {"name", "description", "input_schema"}. Jereo ny Tools etsy ambany. | Model rehetra | |
tool_choice | object | Ny {"type": "auto"} dia avela hanapa-kevitra ny model, ny {"type": "any"} dia manery azy hiantso tool, ny {"type": "tool", "name": "…"} dia manery azy hiantso io tool io. | Model open-weight hosted | |
thinking | object | Hamafiso hoatrinona ny reasoning alohan'ny hamaliany. Jereo ny Thinking etsy ambany. | Model open-weight hosted | |
web_search | boolean | false | Fanampiana avy amin'i Shannon amin'ny endrika: ny true dia avela hikaroka ao amin'ny web ny model alohan'ny hamaliany. | shannon-1.6-*, shannon-2-*, fianakavian'i Shannon 3 |
Raha tsy misy max_tokens dia 4,096 ny sanda, ary 65,536 amin'ny shannon-coder-1.
Ekena ny metadata, top_k, service_tier ary ny marika cache_control amin'ny blocks mba hiasa tsy miova ny kaody client efa misy. Tsy manova ny valiny izy ireo; ny prompt caching amin'ny model open-weight hosted dia automatika.
Ny valiny JSON araka ny schema dia angatahana amin'ny response_format ao amin'ny Chat Completions ary amin'ny text.format ao amin'ny Responses. Vokatra voarafitra
Fangatahana misy system prompt sy thinking
Ity fangatahana ity dia mandefa system prompt, thinking budget, temperature ary stop sequence. Mampiasa model open-weight hosted izy, izay mampihatra azy rehetra.
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?"}]
}' Amin'ny model open-weight hosted dia ampitain'ny usage mitokana amin'ny input tokens hafa ny tokens novakina avy amin'ny prompt cache.
{
"usage": {
"input_tokens": 31,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0,
"output_tokens": 62
}
} System prompt
Ny system dia string, na array misy text blocks amin'ny endrika [{"type": "text", "text": "…"}]. Ny soratry ny blocks dia ampiarahina amin'ny fisian'ny fanapahana andalana.
Ampiharin'ny model open-weight hosted, shannon-1.6-lite, shannon-1.6-pro, shannon-2-lite, shannon-2-pro ary shannon-coder-1 izy. Amin'ny id ao amin'ny fianakavian'i Shannon 3 dia apetraho ao amin'ny hafatra user ny toromarika tsy maintsy arahina.
Hafatra sy content blocks
Ny hafatra dia manana role, user na assistant, ary content. Ny content dia string, na array misy blocks.
| Block | Famaritana | Azo ampiasaina amin'ny |
|---|---|---|
{"type": "text", "text": "…"} | Soratra. | Model rehetra |
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "…"}}{"type": "image", "source": {"type": "url", "url": "…"}} | Sary ao amin'ny hafatra user, amin'ny base64 na URL. | Fianakavian'i Shannon 3, shannon-1.6-lite, shannon-1.6-pro, ary ny model open-weight hosted izay milaza image input |
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} | Antontan-taratasy (PDF, Word, PowerPoint na Excel) ao amin'ny hafatra user, amin'ny base64 na URL. | Fianakavian'i Shannon 3 |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | Ao amin'ny hafatra assistant: antso tool nataon'ny model tamin'ny valiny teo aloha. | Model rehetra |
{"type": "tool_result", "tool_use_id": "toolu_…", "content": "…"} | Ao amin'ny hafatra user: ny vokatry ny antso. Ny content dia string, na lisitry ny text blocks. | Model rehetra |
Azonao averina araka izay misy ny content an'ny valiny teo aloha: vakiana ny blocks text sy tool_use, afaka ny blocks thinking.
Amin'ny tier Shannon dia vakiana avy amin'ny hafatra user farany ny sary sy ny antontan-taratasy. Manana pejy manokana ny habe sy ny fetra. Sary sy rakitra
Thinking
Ny model open-weight hosted dia mamadika ny thinking ho reasoning effort. Raha tsy misy ny saha dia avo ny effort.
| Endrika | budget_tokens | Vokany |
|---|---|---|
{"type": "disabled"} | Tsy misy reasoning. Tsy misy block thinking ny valiny. | |
{"type": "enabled", "budget_tokens": 2048} | ≤ 2,048 | Effort ambany. |
{"type": "enabled", "budget_tokens": 8192} | ≤ 8,192 | Effort antonony. |
{"type": "enabled", "budget_tokens": 16000} | > 8,192 | Effort avo. |
Ny model manao reasoning dia mamerina ny reasoning-ny ho block {"type": "thinking", "thinking": "…"} eo alohan'ny soratra. Ny tier Shannon manao reasoning koa dia mandefa azy.
Ny effort dia faritana amin'ny pejy manokana. Reasoning effort
Tools
Ny tool dia function ampandehanin'ny kaody-nao. Faritana tsirairay amin'ny name, description ary input_schema. Rehefa mila tool ny model dia misy block tool_use ny valiny ary tool_use ny stop_reason.
Famaritana tool ao amin'ny tools:
[
{
"name": "get_weather",
"description": "Current weather for a city.",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": [
"city"
]
}
}
] Ny content an'ny valiny miantso azy:
[
{
"type": "text",
"text": ""
},
{
"type": "tool_use",
"id": "toolu_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
"name": "get_weather",
"input": {
"city": "Paris"
}
}
] Ampandehano ny tool, avy eo alefaso indray ny fangatahana miaraka amin'ny antso sy block tool_result nampiana ao amin'ny 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
| Endrika | Vokany | Ampiharin'ny |
|---|---|---|
{"type": "auto"} | Ny model no mitsara raha hiantso tool. Izany no default. | Model rehetra |
{"type": "any"} | Tsy maintsy miantso iray amin'ny tools ny model. | Model open-weight hosted |
{"type": "tool", "name": "…"} | Tsy maintsy miantso ny tool voatonona ny model. | Model open-weight hosted |
Ny tools manana input_schema ihany no vakiana. Tsy tool amin'ity endpoint ity ny web search: apetraho ny saha web_search.
Ny tool loop dia faritana tanteraka amin'ny pejy manokana. Antso fiasa
Ny valiny
| Saha | Karazana | Famaritana | Alefan'ny |
|---|---|---|---|
id | string | msg_ arahin'ny tarehintsoratra hexadecimal 32. | Model rehetra |
type | string | Foana ny message. | Model rehetra |
role | string | Foana ny assistant. | Model rehetra |
model | string | Ny id canonical an'ilay model namaly. | Model rehetra |
content | array | Ny blocks amin'ny valiny, araka ity filaharana ity: thinking raha nanao reasoning ny model, text, avy eo tool_use iray isaky ny tool call. | Model rehetra |
stop_reason | string | Nahoana no nifarana ny valiny. Jereo ny sanda etsy ambany. | Model rehetra |
usage | object | input_tokens sy output_tokens. | Model rehetra |
sources | array | Amin'ny fangatahana misy web_search: true ihany izay nahita zavatra ny fikarohany: ny vokatra nomena ny model, samy manana index, title ary url. Ny [1] ao amin'ny valiny dia ilay andalana manana index 1. Ao anaty stream dia tonga miaraka amin'ny event message_delta izy. | shannon-1.6-*, shannon-2-*, fianakavian'i Shannon 3 |
usage.cache_read_input_tokens | integer | Ny cache_read_input_tokens dia ny ampahany amin'ny prompt novakina avy ao amin'ny cache; ny input_tokens no sisa. Ny cache_creation_input_tokens dia 0 foana. | Model open-weight hosted |
Blocks amin'ny valiny
| Block | Famaritana |
|---|---|
{"type": "thinking", "thinking": "…"} | Ny reasoning an'ny model. Tsy misy mpikambana signature. |
{"type": "text", "text": "…"} | Ny soratry ny valiny. Mety ho foana izy rehefa tool call ny valiny. |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | Tool call. Ny input dia objet JSON. Alefaso miverina ny vokatra miaraka amin'ny id mitovy. |
stop_reason
| stop_reason | Famaritana | Alefan'ny |
|---|---|---|
end_turn | Vita ny valin'ny model, na nisy niseho ny iray amin'ny stop_sequences-nao. | Model rehetra |
tool_use | Misy tool call iray na maromaro ny valiny. | Model rehetra |
max_tokens | Notapahina tamin'ny fetra output ny valiny. | Fianakavian'i Shannon 3, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1, ao anaty streams |
Streaming
Apetraho true ny stream raha mila server-sent events. Ny frame tsirairay dia manana andalana event: misy ny anaran'ny event ary andalana data: misy objet JSON izay mamerina ny anarana ao amin'ny type. Ny stream helpers an'ny SDK Anthropic no mamaky ireo event ireo ho anao:
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."}]
}' Ny event, araka ny filaharan'ny fahatongavany:
| Event | Data | Rehefa |
|---|---|---|
message_start | message | Foana no voalohany. Ny message dia misy ny id, ny role, ny model, content foana ary usage manomboka amin'ny aotra. |
content_block_start | index, content_block | Misokatra block. Ny content_block dia block text na thinking foana, na block tool_use miaraka amin'ny id sy name-ny. |
content_block_delta | index, delta {"type": "thinking_delta", "thinking"} | Ampahany amin'ny reasoning, ho an'ny block thinking. |
content_block_delta | index, delta {"type": "text_delta", "text"} | Ampahany amin'ny valiny, ho an'ny block text. |
content_block_delta | index, delta {"type": "input_json_delta", "partial_json"} | Ny arguments an'ny tool call, feno ao anaty delta iray, ho an'ny block tool_use. |
content_block_stop | index | Vita ny block manana io index io. |
message_delta | delta {stop_reason, stop_sequence}, usage | Ny faran'ny valiny: delta.stop_reason, ary ny usage an'ny fangatahana. |
message_stop | Foana no farany. |
Ny blocks dia isaina amin'ny index araka ny filaharan'ny fisokafany, ary vita ny block iray alohan'ny hisokafan'ny manaraka. Vakio ny block tsirairay araka ny karazany, fa tsy araka ny laharany: mety hanokatra block text foana aloha ny stream, avy eo ny block thinking, ary mandefa ny valiny ao amin'ny block text aoriana.
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
| Alefan'ny | Famaritana |
|---|---|
Fianakavian'i Shannon 3, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | Event ping misy ny data {"type": "ping"}, isaky ny 15 segondra. |
| Model open-weight hosted | Andalana fanamarihana : keepalive, isaky ny 15 segondra raha mbola miasa ny model. |
Stream tsy mahomby
Ny tsy fahombiazana aorian'ny nanombohan'ny stream dia event error misy vatana mitovy amin'ny valin'ny hadisoana: {"type": "error", "error": {"type", "message"}}. Mbola manaraka ihany ny event famaranana, message_delta sy message_stop. Raiso ho tsy nahomby ny valiny ary alefaso indray ny fangatahana.
Hadisoana
Ny hadisoana dia mampiasa ny vatan'ny hadisoana Anthropic: ny type dia error, ary ny objet error dia misy type sy message. Ny tabilao dia mampiseho izay averin'ity endpoint ity matetika indrindra. Ny lisitra feno, miaraka amin'izay tokony hoeranina, dia manana pejy manokana. Fitantanana hadisoana
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "unknown model: no-such-model"
}
} | Status | Karazana | Hafatra | Rehefa |
|---|---|---|---|
401 | authentication_error | Missing authenticationInvalid API key | Tsy nisy API key nalefa, na tsy fantatra na voafafa ny key. |
400 | invalid_request_error | unknown model: <id> | Tsy model id Shannon ny model. |
400 | invalid_request_error | No user message provided | Tier Shannon: tsy misy soratra user ny fangatahana ary tsy misy tools. |
400 | invalid_request_error | <id> does not accept image input | Nisy sary nalefa tamin'ny model open-weight hosted tsy manana image input. |
422 | invalid_request_error | Failed to deserialize the JSON body into the target type: … | Tsy misy ny messages, na diso ny karazana JSON an'ny saha iray. |
429 | rate_limit_error | Quota exceeded. Upgrade your plan at shannon-ai.com/plan | Lehibe noho ny sisa amin'ny balance-nao ny max_tokens. |
429 | rate_limit_error | Too many requests. Retry in <n>s. | Flood protection: mihoatra ny 120 ny fangatahana tao anatin'ny iray minitra tamin'ny kaonty-nao. |
429 | rate_limit_error | Shannon Coder call quota reached. Upgrade your plan at shannon-ai.com/plan | shannon-coder-1: lany ny antso Shannon Coder an'ny plan-nao ho an'ny fe-potoana 4 ora ankehitriny. |
500 | server_error | The model backend failed to answer. Please retry. | Tsy namoaka valiny ny model. Alefaso indray ny fangatahana. |
502 | api_error | The model backend failed to answer. Please retry. | Tsy namoaka valiny ny model. Alefaso indray ny fangatahana. |
Fanisana tokens
Ny POST /v1/messages/count_tokens dia mandray vatana mitovy amin'ny fangatahana hafatra (model, system, messages, tools) ary mamerina {"input_tokens": n}: ny isan'ny input tokens halaina amin'ny fangatahana. Mihatra amin'ny model open-weight hosted izy, maimaim-poana ary tsy isain'ny 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} Manana pejy manokana ny fanisana, miaraka amin'ny endpoint plain-text sy ny fetra. Fanisana token