Anthropic
POST /v1/messages e amohela kopo ka sebopeho sa Anthropic Messages mme e araba ka sebopeho se tšoanang, ka streaming kapa ntle le eona. E sebelise le Anthropic SDK le lisebelisoa tse hahiloeng ho eona, tse kang Claude Code: beha base URL, sebelisa senotlolo sa hau sa Shannon API mme u reye id ea model ea Shannon.
POST https://api.shannon-ai.com/v1/messages
Supa Anthropic SDK ho base URL ea Shannon. SDK e eketsa /v1/messages mme e romela senotlolo sa hau ho header ea 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."}]
}' Karabo ke molaetsa oo content ea ona e leng lenane la li-block. Fumana li-block ka type ea tsona: ha model e nahanne, block ea pele ke thinking mme mongolo o e latela.
{
"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
}
} Li-header
| Header | Boleng | Tlhaloso |
|---|---|---|
x-api-key | YOUR_API_KEY | Senotlolo sa hau sa API. Authorization: Bearer YOUR_API_KEY e amohelwa sebakeng sa sona. |
content-type | application/json | E hlokahala. |
anthropic-version | 2023-06-01 | E amohelwa, ha e hlokahale. Anthropic SDK e romela 2023-06-01; karabo e na le sebopeho se tšoanang ho sa tsotellehe boleng. |
anthropic-beta | E amohelwa, ha e hlokahale. | |
x-request-id | Ha e hlokahale. Id ea hau ea kopo. E khutla e sa fetohang karabong; ntle le eona karabo e na le id ea litlhaku tse 12 tsa hexadecimal. |
Li-field tsa kopo
messages feela e hlokahala. Kholomo ea E sebelisoa ke e reha li-model tseo field e fetolang karabo ho tsona. Li-model tse hosted tsa open-weight ke li-id tse leshome le metso e 'meli tsa lenane la li-model; lelapa la Shannon 3 ke shannon-3, shannon-3-pro, shannon-3.1 le shannon-3.1-pro. Li-model le litheko
| Field | Mofuta | Default | Tlhaloso | E sebelisoa ke |
|---|---|---|---|---|
model | string | shannon-1.6-lite | Id ea model ea Shannon ho tsoa lenaneng la li-model. E romele ho kopo e 'ngoe le e 'ngoe. Ho lekanya ha ho tsotelle litlhaku tse kholo le tse nyane. Lebitso le leng lefe kapa lefe le khutlisa 400 unknown model, kahoo sesebelisoa se romelang mabitso a sona a model se tlameha ho behoa ho id ea Shannon. | Li-model tsohle |
messages | array | E hlokahala. Moqoqo, molaetsa o moholo ka ho fetisisa pele, o nang le li-role user le assistant. Bona Messages le content blocks ka tlase. | Li-model tsohle | |
system | string | array | Litaelo tsa model: string, kapa array ea li-block tsa mongolo. Bona System prompt ka tlase. | Li-model tse hosted tsa open-weight, shannon-1.6-*, shannon-2-*, shannon-coder-1 | |
max_tokens | integer | 4096 | Moeli o phahameng oa karabo, ka tokens. Ha o hlokahale ho endpoint ena; Anthropic SDK kamehla e o romela. Boleng bo kantle ho 1 ho isa ho 65,536 bo fetoleloa ka har'a moeli oo. Ke hape palo e behelloang thoko ho balance ea hau ha kopo e ntse e sebetsa. | Li-model tse hosted tsa open-weight, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 |
stream | boolean | false | true e romela karabo e le server-sent events. Bona Streaming ka tlase. | Li-model tsohle |
temperature | number | Sampling temperature. Ho li-model tse hosted tsa open-weight litekanyo li bolokoa pakeng tsa 0 le 2. | Li-model tse hosted tsa open-weight, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | |
top_p | number | Nucleus sampling. | Li-model tse hosted tsa open-weight | |
stop_sequences | array | Ho fihlela ho li-string tse 4. Karabo e fela pele ho ea pele e hlahang. stop_reason e lula e le end_turn. | Li-model tse hosted tsa open-weight | |
tools | array | Lisebelisoa tseo model e ka li bitsang, e 'ngoe le e 'ngoe e le {"name", "description", "input_schema"}. Bona Tools ka tlase. | Li-model tsohle | |
tool_choice | object | {"type": "auto"} e lumella model hore e iketsetse qeto, {"type": "any"} e e qobella ho bitsa tool, {"type": "tool", "name": "…"} e e qobella ho bitsa tool eo. | Li-model tse hosted tsa open-weight | |
thinking | object | Hore na model e nahana hakae pele e araba. Bona Thinking ka tlase. | Li-model tse hosted tsa open-weight | |
web_search | boolean | false | Tlatsetso ea Shannon ho sebopeho: true e lumella model hore e batle webeng pele e araba. | shannon-1.6-*, shannon-2-*, lelapa la Shannon 3 |
Ntle le max_tokens boleng ke 4,096, le 65,536 ho shannon-coder-1.
Li-marker tsa metadata, top_k, service_tier le cache_control ho li-block lia amohelwa e le hore code ea moreki e teng e sebetse ntle le phetoho. Ha li fetole karabo; prompt caching ho li-model tse hosted tsa open-weight ke automatic.
Karabo ea JSON e latelang schema e kopuoa ka response_format ho Chat Completions le ka text.format ho Responses. Diphumo tse hlophisitsoeng
Kopo e nang le system prompt le thinking
Kopo ena e romela system prompt, thinking budget, temperature le stop sequence. E sebelisa model e hosted ea open-weight, e sebelisang tsohle.
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?"}]
}' Ho li-model tse hosted tsa open-weight usage e tlaleha tokens tse baloang ho prompt cache ka thoko ho input tokens tse ling.
{
"usage": {
"input_tokens": 31,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0,
"output_tokens": 62
}
} System prompt
system ke string, kapa array ea li-block tsa mongolo ka sebopeho [{"type": "text", "text": "…"}]. Mengolo ea li-block e kopanngoa ka mohala o mocha.
E sebelisoa ke li-model tse hosted tsa open-weight, shannon-1.6-lite, shannon-1.6-pro, shannon-2-lite, shannon-2-pro le shannon-coder-1. Ka id ea lelapa la Shannon 3, kenya litaelo tse lokelang ho latelloa molaetsa oa user.
Melaetsa le content blocks
Molaetsa o na le role, user kapa assistant, le content. content ke string, kapa array ea li-block.
| Block | Tlhaloso | E fumaneha ho |
|---|---|---|
{"type": "text", "text": "…"} | Mongolo. | Li-model tsohle |
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "…"}}{"type": "image", "source": {"type": "url", "url": "…"}} | Setšoantšo molaetsa oa user, e le base64 kapa ka URL. | Lelapa la Shannon 3, shannon-1.6-lite, shannon-1.6-pro, le li-model tse hosted tsa open-weight tse ngotsoeng input ea setšoantšo |
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} | Tokomane (PDF, Word, PowerPoint kapa Excel) molaetsa oa user, e le base64 kapa ka URL. | Lelapa la Shannon 3 |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | Molaetsa oa assistant: kopo ea tool eo model e e entseng karabong e fetileng. | Li-model tsohle |
{"type": "tool_result", "tool_use_id": "toolu_…", "content": "…"} | Molaetsa oa user: sephetho sa kopo eo. content ke string, kapa lenane la li-block tsa mongolo. | Li-model tsohle |
U ka romela content ea karabo e fetileng hape joalo ka ha e le: li-block tsa text le tool_use lia baloa, li-block tsa thinking lia tlolloa.
Ho li-tier tsa Shannon litšoantšo le litokomane li baloa molaetsa oa ho qetela oa user. Boholo le meeli li na le leqephe la tsona. Litšoantšo le lifaele
Thinking
Li-model tse hosted tsa open-weight li fetolela thinking ho reasoning effort. Ntle le field effort ke high.
| Sebopeho | budget_tokens | Phello |
|---|---|---|
{"type": "disabled"} | Ha ho reasoning. Karabo ha e na block ea thinking. | |
{"type": "enabled", "budget_tokens": 2048} | ≤ 2,048 | Effort e tlase. |
{"type": "enabled", "budget_tokens": 8192} | ≤ 8,192 | Effort e bohareng. |
{"type": "enabled", "budget_tokens": 16000} | > 8,192 | Effort e phahameng. |
Model e nahanang e khutlisa reasoning ea eona e le block {"type": "thinking", "thinking": "…"} pele ho mongolo. Li-tier tsa Shannon tse nahanang li e romela hape.
Li-effort li hlalositsoe leqepheng la tsona. Effort ea reasoning
Tools
Tool ke function eo code ea hau e e etsang. Hlalosa e 'ngoe le e 'ngoe ka name, description le input_schema. Ha model e batla tool, karabo e na le block ea tool_use mme stop_reason ke tool_use.
Tlhaloso ea tool ho tools:
[
{
"name": "get_weather",
"description": "Current weather for a city.",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": [
"city"
]
}
}
] content ea karabo e e bitsang:
[
{
"type": "text",
"text": ""
},
{
"type": "tool_use",
"id": "toolu_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
"name": "get_weather",
"input": {
"city": "Paris"
}
}
] Etsa tool, ebe u romela kopo hape le kopo ea tool le block ea tool_result e kentsoeng ho 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
| Sebopeho | Phello | E sebelisoa ke |
|---|---|---|
{"type": "auto"} | Model e iketsetsa qeto ea hore na e bitse tool. Ena ke default. | Li-model tsohle |
{"type": "any"} | Model e tlameha ho bitsa e 'ngoe ea lisebelisoa. | Li-model tse hosted tsa open-weight |
{"type": "tool", "name": "…"} | Model e tlameha ho bitsa tool e rehiloeng. | Li-model tse hosted tsa open-weight |
Ke lisebelisoa feela tse nang le input_schema tse baloang. Web search hase tool endpoint-ng ena: beha field ea web_search.
Tool loop e hlalositsoe ka botlalo leqepheng la eona. Mekhosi ya mesebetsi
Karabo
| Field | Mofuta | Tlhaloso | E rometsoe ke |
|---|---|---|---|
id | string | msg_ e latelwa ke litlhaku tse 32 tsa hexadecimal. | Li-model tsohle |
type | string | Kamehla ke message. | Li-model tsohle |
role | string | Kamehla ke assistant. | Li-model tsohle |
model | string | Id ea canonical ea model e arabileng. | Li-model tsohle |
content | array | Li-block tsa karabo, ka tatellano ena: thinking ha model e nahanne, text, ebe tool_use e le 'ngoe bakeng sa kopo e 'ngoe le e 'ngoe ea tool. | Li-model tsohle |
stop_reason | string | Hobaneng karabo e felile. Bona litekanyo tse ka tlase. | Li-model tsohle |
usage | object | input_tokens le output_tokens. | Li-model tsohle |
sources | array | Feela ho kopo e nang le web_search: true eo patlo ea eona e fumaneng eng kapa eng: liphetho tseo model e li file, e 'ngoe le e 'ngoe e na le index, title le url. [1] karabong ke entry e nang le index 1. Ho stream e tla le event ea message_delta. | shannon-1.6-*, shannon-2-*, lelapa la Shannon 3 |
usage.cache_read_input_tokens | integer | cache_read_input_tokens ke karolo ea prompt e baloang ho cache; input_tokens ke karolo e setseng. cache_creation_input_tokens kamehla ke 0. | Li-model tse hosted tsa open-weight |
Li-block tsa karabo
| Block | Tlhaloso |
|---|---|
{"type": "thinking", "thinking": "…"} | Reasoning ea model. Ha ho setho sa signature. |
{"type": "text", "text": "…"} | Mongolo oa karabo. O ka ba o se na letho ha karabo e le kopo ea tool. |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | Kopo ea tool. input ke ntho ea JSON. Romela sephetho hape ka id e tšoanang. |
stop_reason
| stop_reason | Tlhaloso | E rometsoe ke |
|---|---|---|
end_turn | Model e qetile karabo ea eona, kapa e 'ngoe ea stop_sequences tsa hau e hlahile. | Li-model tsohle |
tool_use | Karabo e na le kopo e le 'ngoe kapa tse ngata tsa tool. | Li-model tsohle |
max_tokens | Karabo e khaoloe moeling oa output. | Lelapa la Shannon 3, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1, ho li-stream |
Streaming
Beha stream ho true bakeng sa server-sent events. Frame e 'ngoe le e 'ngoe e na le mohala oa event: o nang le lebitso la event le mohala oa data: o nang le ntho ea JSON e pheta lebitso ho type. Li-helper tsa stream tsa Anthropic SDK li bala li-event tsena bakeng sa hau:
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."}]
}' Li-event, ka tatellano eo li fihlang ka eona:
| Event | Data | Neng |
|---|---|---|
message_start | message | Kamehla ke ea pele. message e na le id, role, model, content e se nang letho le usage e qalang ho zero. |
content_block_start | index, content_block | Block e a buleha. content_block ke block e se nang letho ea text kapa thinking, kapa block ea tool_use e nang le id le name ea eona. |
content_block_delta | index, delta {"type": "thinking_delta", "thinking"} | Karolo ea reasoning, bakeng sa block ea thinking. |
content_block_delta | index, delta {"type": "text_delta", "text"} | Karolo ea karabo, bakeng sa block ea text. |
content_block_delta | index, delta {"type": "input_json_delta", "partial_json"} | Li-argument tsa kopo ea tool, li felletse delta e le 'ngoe, bakeng sa block ea tool_use. |
content_block_stop | index | Block e nang le index ena e phethahetse. |
message_delta | delta {stop_reason, stop_sequence}, usage | Qetello ea karabo: delta.stop_reason, le usage ea kopo. |
message_stop | Kamehla ke ea ho qetela. |
Li-block li bokelloa ka index ka tatellano eo li buloang ka eona, mme block e le 'ngoe e phethahala pele e latelang e buloa. Bala block e 'ngoe le e 'ngoe ka mofuta oa eona, eseng ka nomoro ea eona: stream e ka bula block e se nang letho ea text pele, ebe block ea thinking, mme ea fana ka karabo ho block e latelang ea text.
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
| E rometsoe ke | Tlhaloso |
|---|---|
Lelapa la Shannon 3, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | Event ea ping e nang le data {"type": "ping"}, ka mor'a metsotsoana e 15 e 'ngoe le e 'ngoe. |
| Li-model tse hosted tsa open-weight | Mohala oa maikutlo : keepalive, ka mor'a metsotsoana e 15 e 'ngoe le e 'ngoe ha model e ntse e sebetsa. |
Stream e hlolehang
Phoso ka mor'a hore stream e qale ke event ea error e nang le body e tšoanang le ea karabo ea phoso: {"type": "error", "error": {"type", "message"}}. Li-event tsa ho koala, message_delta le message_stop, li ntse li latela. Nka karabo e le e hlolehileng mme u romele kopo hape.
Liphoso
Liphoso li sebelisa body ea phoso ea Anthropic: type ke error, mme ntho ea error e na le type le message. Tafole e thathamisa seo endpoint ena e se khutlisang hangata. Lenane le felletseng, le se ka lekoang hape, le na le leqephe la lona. Diphoso
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "unknown model: no-such-model"
}
} | Boemo | Mofuta | Molaetsa | Neng |
|---|---|---|---|
401 | authentication_error | Missing authenticationInvalid API key | Ha ho senotlolo sa API se rometsoeng, kapa senotlolo ha se tsejoe kapa se hlakotsoe. |
400 | invalid_request_error | unknown model: <id> | model hase id ea model ea Shannon. |
400 | invalid_request_error | No user message provided | Li-tier tsa Shannon: kopo ha e na mongolo oa user kapa tools. |
400 | invalid_request_error | <id> does not accept image input | Setšoantšo se rometsoe ho model e hosted ea open-weight e se nang input ea setšoantšo. |
422 | invalid_request_error | Failed to deserialize the JSON body into the target type: … | messages ha e eo, kapa field e na le mofuta o fosahetseng oa JSON. |
429 | rate_limit_error | Quota exceeded. Upgrade your plan at shannon-ai.com/plan | max_tokens e kholo ho feta se setseng ho balance ea hau. |
429 | rate_limit_error | Too many requests. Retry in <n>s. | Flood protection: likopo tse fetang 120 ka motsotso o le mong ho akhaonte ea hau. |
429 | rate_limit_error | Shannon Coder call quota reached. Upgrade your plan at shannon-ai.com/plan | shannon-coder-1: likopo tsa Shannon Coder tsa plan ea hau bakeng sa fensetere ea hajoale ea lihora tse 4 li felile. |
500 | server_error | The model backend failed to answer. Please retry. | Model ha ea ka ea hlahisa karabo. Romela kopo hape. |
502 | api_error | The model backend failed to answer. Please retry. | Model ha ea ka ea hlahisa karabo. Romela kopo hape. |
Ho bala tokens
POST /v1/messages/count_tokens e amohela body e tšoanang le ea kopo ea molaetsa (model, system, messages, tools) mme e khutlisa {"input_tokens": n}: palo ea input tokens tseo kopo e ka lefisoang ka tsona. E bala bakeng sa li-model tse hosted tsa open-weight, ke mahala mme ha e baloe ke 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} Ho bala ho na le leqephe la ho eona, le endpoint ea mongolo o hlakileng le meeli. Ho bala tokens