Anthropic ፎርማት
POST /v1/messages በAnthropic Messages ቅርጸት ጥያቄ ተቀብሎ በተመሳሳይ ቅርጸት ይመልሳል፣ በstream ወይም ያለ stream። ከAnthropic SDK እና በእሱ ላይ ከተገነቡ እንደ Claude Code ካሉ መሣሪያዎች ጋር ይጠቀሙት፦ base URL ያዘጋጁ፣ የShannon API ቁልፍዎን ይጠቀሙ እና የShannon ሞዴል id ይሰይሙ።
POST https://api.shannon-ai.com/v1/messages
የAnthropic SDKን ወደ Shannon base URL ያመልክቱ። SDKው /v1/messages ይጨምራል እና ቁልፍዎን በx-api-key header ይልካል።
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."}]
}' ምላሹ contentው የblocks ዝርዝር የሆነ መልእክት ነው። Blocksን በtype ያግኙ፦ ሞዴሉ reasoning ሲያደርግ የመጀመሪያው block thinking ነው እና ጽሑፉ ከእሱ በኋላ ይመጣል።
{
"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 | እሴት | መግለጫ |
|---|---|---|
x-api-key | YOUR_API_KEY | የእርስዎ API ቁልፍ። በቦታው Authorization: Bearer YOUR_API_KEY ተቀባይነት አለው። |
content-type | application/json | ያስፈልጋል። |
anthropic-version | 2023-06-01 | ይቀበላል፣ አያስፈልግም። የAnthropic SDK 2023-06-01 ይልካል፤ እሴቱ ምንም ይሁን ምላሹ ተመሳሳይ ቅርጸት አለው። |
anthropic-beta | ይቀበላል፣ አያስፈልግም። | |
x-request-id | አማራጭ። ለጥያቄው የራስዎ id። በምላሹ ላይ ሳይቀየር ይመለሳል፤ ከሌለ ምላሹ 12 ሄክሳዴሲማል ቁምፊዎች ያሉት id ይይዛል። |
የጥያቄ መስኮች
የሚያስፈልገው messages ብቻ ነው። የሚተገብሩት ዓምድ መስኩ ምላሹን የሚለውጥባቸውን ሞዴሎች ይጠራል። የሆስት open-weight ሞዴሎች በሞዴል ዝርዝሩ ውስጥ ያሉት አስራ ሁለት ids ናቸው፤ የShannon 3 ቤተሰብ shannon-3, shannon-3-pro, shannon-3.1 እና shannon-3.1-pro ነው። ሞዴሎችና ዋጋ
| መስክ | ዓይነት | ነባሪ | መግለጫ | የሚተገብሩት |
|---|---|---|---|---|
model | string | shannon-1.6-lite | ከሞዴል ዝርዝሩ የShannon ሞዴል id። በእያንዳንዱ ጥያቄ ይላኩት። ማዛመዱ ለአቢይ/ትንሽ ፊደል ግድ የለውም። ማንኛውም ሌላ ስም 400 unknown model ይመልሳል፣ ስለዚህ የራሱን የሞዴል ስሞች የሚልክ መሣሪያ ወደ Shannon id መዋቀር አለበት። | ሁሉም ሞዴሎች |
messages | array | ያስፈልጋል። ውይይቱ፣ የቆየው መልእክት መጀመሪያ፣ በuser እና assistant ሚናዎች። ከታች ያለውን መልእክቶችና የይዘት blocks ይመልከቱ። | ሁሉም ሞዴሎች | |
system | string | array | ለሞዴሉ መመሪያዎች፦ string ወይም የጽሑፍ blocks array። ከታች ያለውን System prompt ይመልከቱ። | የሆስት open-weight ሞዴሎች፣ shannon-1.6-*, shannon-2-*, shannon-coder-1 | |
max_tokens | integer | 4096 | የምላሹ ከፍተኛ ገደብ፣ በtokens። በዚህ endpoint ላይ አማራጭ ነው፤ የAnthropic SDK ሁልጊዜ ይልከዋል። ከ 1 እስከ 65,536 ውጭ ያለ እሴት ወደዚያ ክልል ይወሰዳል። ጥያቄው በሚሰራበት ጊዜ ከቀሪ ሂሳብዎ ተለይቶ የሚቀመጠውም መጠን ነው። | የሆስት open-weight ሞዴሎች፣ shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 |
stream | boolean | false | true ምላሹን እንደ server-sent events ይልካል። ከታች ያለውን Streaming ይመልከቱ። | ሁሉም ሞዴሎች |
temperature | number | Sampling temperature። በሆስት open-weight ሞዴሎች ላይ እሴቶች ከ 0 እስከ 2 መካከል ይቆያሉ። | የሆስት open-weight ሞዴሎች፣ shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | |
top_p | number | Nucleus sampling። | የሆስት open-weight ሞዴሎች | |
stop_sequences | array | እስከ 4 strings። መልሱ ከሚታየው የመጀመሪያው በፊት ያበቃል። stop_reason end_turn ሆኖ ይቆያል። | የሆስት open-weight ሞዴሎች | |
tools | array | ሞዴሉ ሊጠራቸው የሚችሉ tools፣ እያንዳንዱ እንደ {"name", "description", "input_schema"}። ከታች ያለውን Tools ይመልከቱ። | ሁሉም ሞዴሎች | |
tool_choice | object | {"type": "auto"} ሞዴሉ እንዲወስን ያደርጋል፣ {"type": "any"} tool እንዲጠራ ያደርገዋል፣ {"type": "tool", "name": "…"} ያንን tool እንዲጠራ ያደርገዋል። | የሆስት open-weight ሞዴሎች | |
thinking | object | ሞዴሉ ከመመለሱ በፊት ምን ያህል reasoning እንደሚያደርግ። ከታች ያለውን Thinking ይመልከቱ። | የሆስት open-weight ሞዴሎች | |
web_search | boolean | false | በቅርጸቱ ላይ የShannon መጨመሪያ፦ true ሞዴሉ ከመመለሱ በፊት ድሩን እንዲፈልግ ያደርገዋል። | shannon-1.6-*, shannon-2-*, Shannon 3 ቤተሰብ |
max_tokens ከሌለ እሴቱ 4,096 ነው፣ በshannon-coder-1 ደግሞ 65,536።
metadata, top_k, service_tier እና በblocks ላይ ያሉ cache_control ምልክቶች ነባር የክላይንት ኮድ ሳይቀየር እንዲሰራ ይቀበላሉ። ምላሹን አይለውጡም፤ በሆስት open-weight ሞዴሎች ላይ prompt caching ራስ-ሰር ነው።
ለschema የJSON መልስ በChat Completions ላይ በresponse_format እና በResponses ላይ በtext.format ይጠየቃል። የተዋቀሩ ውጤቶች
ከsystem prompt እና ከthinking ጋር የተላከ ጥያቄ
ይህ ጥያቄ system prompt፣ thinking budget፣ temperature እና stop sequence ይልካል። ሁሉንም የሚተገብር የሆስት open-weight ሞዴል ይጠቀማል።
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?"}]
}' በሆስት open-weight ሞዴሎች ላይ usage ከprompt cache የተነበቡ tokens ከሌሎቹ input tokens ተለይተው ያሳያል።
{
"usage": {
"input_tokens": 31,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0,
"output_tokens": 62
}
} System prompt
system string ነው፣ ወይም በ[{"type": "text", "text": "…"}] ቅርጽ የጽሑፍ blocks array። የblocks ጽሑፎች በመስመር መግቻ ይገናኛሉ።
የሚተገብሩት የሆስት open-weight ሞዴሎች፣ shannon-1.6-lite, shannon-1.6-pro, shannon-2-lite, shannon-2-pro እና shannon-coder-1 ናቸው። የShannon 3 ቤተሰብ id ሲጠቀሙ፣ መከበር ያለባቸውን መመሪያዎች በተጠቃሚው መልእክት ውስጥ ያስገቡ።
መልእክቶችና የይዘት blocks
መልእክት role አለው፣ user ወይም assistant፣ እና content። content string ነው፣ ወይም የblocks array።
| Block | መግለጫ | የሚገኘው በ |
|---|---|---|
{"type": "text", "text": "…"} | ጽሑፍ። | ሁሉም ሞዴሎች |
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "…"}}{"type": "image", "source": {"type": "url", "url": "…"}} | በ user መልእክት ውስጥ ያለ ምስል፣ እንደ base64 ወይም በURL። | Shannon 3 ቤተሰብ፣ shannon-1.6-lite, shannon-1.6-pro, እና የምስል input የሚዘረዝሩ የሆስት open-weight ሞዴሎች |
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} | በ user መልእክት ውስጥ ያለ ሰነድ (PDF፣ Word፣ PowerPoint ወይም Excel)፣ እንደ base64 ወይም በURL። | Shannon 3 ቤተሰብ |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | በ assistant መልእክት ውስጥ፦ ሞዴሉ በቀድሞ ምላሽ ያደረገው የtool ጥሪ። | ሁሉም ሞዴሎች |
{"type": "tool_result", "tool_use_id": "toolu_…", "content": "…"} | በ user መልእክት ውስጥ፦ የዚያ ጥሪ ውጤት። content string ነው፣ ወይም የጽሑፍ blocks ዝርዝር። | ሁሉም ሞዴሎች |
የቀድሞ ምላሽ contentን እንዳለ መልሰው መላክ ይችላሉ፦ text እና tool_use blocks ይነበባሉ፣ thinking blocks ይዘለላሉ።
በShannon ደረጃዎች ምስሎችና ሰነዶች ከመጨረሻው user መልእክት ይነበባሉ። መጠኖችና ገደቦች የራሳቸው ገጽ አላቸው። ምስሎች እና ፋይሎች
Thinking
የሆስት open-weight ሞዴሎች thinkingን ወደ reasoning effort ይቀይሩታል። መስኩ ከሌለ effort ከፍተኛ ነው።
| ቅርጽ | budget_tokens | ተጽእኖ |
|---|---|---|
{"type": "disabled"} | reasoning የለም። ምላሹ thinking block የለውም። | |
{"type": "enabled", "budget_tokens": 2048} | ≤ 2,048 | ዝቅተኛ effort። |
{"type": "enabled", "budget_tokens": 8192} | ≤ 8,192 | መካከለኛ effort። |
{"type": "enabled", "budget_tokens": 16000} | > 8,192 | ከፍተኛ effort። |
reasoning የሚያደርግ ሞዴል reasoningውን ከጽሑፉ ፊት እንደ {"type": "thinking", "thinking": "…"} block ይመልሳል። reasoning የሚያደርጉ የShannon ደረጃዎችም ይልኩታል።
Efforts የራሳቸው ገጽ ላይ ተብራርተዋል። Reasoning effort
Tools
Tool ኮድዎ የሚያስኬደው ፋንክሽን ነው። እያንዳንዱን በname፣ በdescription እና በinput_schema ይግለጹ። ሞዴሉ tool ሲፈልግ ምላሹ tool_use block ይይዛል እና stop_reason tool_use ነው።
በtools ውስጥ የtool ትርጉም፦
[
{
"name": "get_weather",
"description": "Current weather for a city.",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": [
"city"
]
}
}
] ጥሪውን የሚያደርግ ምላሽ content፦
[
{
"type": "text",
"text": ""
},
{
"type": "tool_use",
"id": "toolu_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
"name": "get_weather",
"input": {
"city": "Paris"
}
}
] Toolን ያስኬዱ፣ ከዚያ ጥሪውንና tool_result blockን ወደ 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
| ቅርጽ | ተጽእኖ | የሚተገብሩት |
|---|---|---|
{"type": "auto"} | ሞዴሉ tool መጥራት አለመጥራቱን ይወስናል። ይህ ነባሪው ነው። | ሁሉም ሞዴሎች |
{"type": "any"} | ሞዴሉ ከtools አንዱን መጥራት አለበት። | የሆስት open-weight ሞዴሎች |
{"type": "tool", "name": "…"} | ሞዴሉ የተሰየመውን tool መጥራት አለበት። | የሆስት open-weight ሞዴሎች |
input_schema ያላቸው tools ብቻ ይነበባሉ። ድር ፍለጋ በዚህ endpoint ላይ tool አይደለም፦ የweb_search መስኩን ያዘጋጁ።
የtool ዑደት በራሱ ገጽ ላይ ሙሉ በሙሉ ተብራርቷል። ፋንክሽን ጥራት
ምላሹ
| መስክ | ዓይነት | መግለጫ | የሚልከው |
|---|---|---|---|
id | string | msg_ እና ከዚያ 32 ሄክሳዴሲማል ቁምፊዎች። | ሁሉም ሞዴሎች |
type | string | ሁልጊዜ message። | ሁሉም ሞዴሎች |
role | string | ሁልጊዜ assistant። | ሁሉም ሞዴሎች |
model | string | የመለሰው ሞዴል ትክክለኛ id። | ሁሉም ሞዴሎች |
content | array | የምላሹ blocks፣ በዚህ ቅደም ተከተል፦ ሞዴሉ reasoning ካደረገ thinking፣ text፣ ከዚያ ለእያንዳንዱ የtool ጥሪ አንድ tool_use። | ሁሉም ሞዴሎች |
stop_reason | string | ምላሹ ለምን እንዳበቃ። ከታች ያሉትን እሴቶች ይመልከቱ። | ሁሉም ሞዴሎች |
usage | object | input_tokens እና output_tokens። | ሁሉም ሞዴሎች |
sources | array | ፍለጋው አንድ ነገር ባገኘ web_search: true ባለው ጥያቄ ላይ ብቻ፦ ለሞዴሉ የተሰጡት ውጤቶች፣ እያንዳንዳቸው ከindex፣ title እና url ጋር። በመልሱ ውስጥ ያለው [1] index 1 ያለው ግቤት ነው። በstream ውስጥ ከmessage_delta ክስተት ጋር ይመጣል። | shannon-1.6-*, shannon-2-*, Shannon 3 ቤተሰብ |
usage.cache_read_input_tokens | integer | cache_read_input_tokens ከcache የተነበበው የprompt ክፍል ነው፤ input_tokens የቀረው ነው። cache_creation_input_tokens ሁልጊዜ 0 ነው። | የሆስት open-weight ሞዴሎች |
የምላሽ blocks
| Block | መግለጫ |
|---|---|
{"type": "thinking", "thinking": "…"} | የሞዴሉ reasoning። signature አባል የለም። |
{"type": "text", "text": "…"} | የመልሱ ጽሑፍ። ምላሹ የtool ጥሪ ሲሆን ባዶ ሊሆን ይችላል። |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | የtool ጥሪ። input የJSON ነገር ነው። ውጤቱን በተመሳሳይ id መልሰው ይላኩ። |
stop_reason
| stop_reason | መግለጫ | የሚልከው |
|---|---|---|
end_turn | ሞዴሉ መልሱን ጨርሷል፣ ወይም ከstop_sequences ውስጥ አንዱ ታይቷል። | ሁሉም ሞዴሎች |
tool_use | ምላሹ አንድ ወይም ከዚያ በላይ የtool ጥሪዎችን ይዟል። | ሁሉም ሞዴሎች |
max_tokens | ምላሹ በውጤት ገደቡ ላይ ተቆርጧል። | Shannon 3 ቤተሰብ፣ shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1፣ በstreams ውስጥ |
Streaming
ለserver-sent events streamን true ያድርጉ። እያንዳንዱ frame የevent ስም ያለው event: መስመር እና ስሙን በtype የሚደግም የJSON ነገር ያለው data: መስመር አለው። የAnthropic SDK stream አጋዦች እነዚህን events ያነቡልዎታል፦
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."}]
}' Events በሚደርሱበት ቅደም ተከተል፦
| Event | ዳታ | መቼ |
|---|---|---|
message_start | message | ሁልጊዜ የመጀመሪያ። message id፣ ሚናውን፣ ሞዴሉን፣ ባዶ contentን እና ከዜሮ የሚጀምር usageን ይዟል። |
content_block_start | index, content_block | አንድ block ይከፈታል። content_block ባዶ text ወይም thinking block ነው፣ ወይም id እና name ያለው tool_use block። |
content_block_delta | index, delta {"type": "thinking_delta", "thinking"} | ለthinking block የreasoning አንድ ቁራጭ። |
content_block_delta | index, delta {"type": "text_delta", "text"} | ለtext block የመልሱ አንድ ቁራጭ። |
content_block_delta | index, delta {"type": "input_json_delta", "partial_json"} | የtool ጥሪ arguments፣ ለtool_use block በአንድ delta ተሟልተው። |
content_block_stop | index | በዚህ index ያለው block ተጠናቋል። |
message_delta | delta {stop_reason, stop_sequence}, usage | የምላሹ መጨረሻ፦ delta.stop_reason እና የጥያቄው usage። |
message_stop | ሁልጊዜ የመጨረሻ። |
Blocks በሚከፈቱበት ቅደም ተከተል በindex ተቆጥረዋል፤ ቀጣዩ ከመከፈቱ በፊት አንዱ block ይጠናቀቃል። እያንዳንዱን block በዓይነቱ ያንብቡ እንጂ በቁጥሩ አይደለም፦ stream መጀመሪያ ባዶ text block፣ ከዚያ thinking block ሊከፍት እና መልሱን በኋላ ባለ text block ሊያደርስ ይችላል።
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
| የሚልከው | መግለጫ |
|---|---|
Shannon 3 ቤተሰብ፣ shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | በየ15 ሰከንዱ {"type": "ping"} ዳታ ያለው ping event። |
| የሆስት open-weight ሞዴሎች | ሞዴሉ በሚሰራበት ጊዜ በየ15 ሰከንዱ የ: keepalive አስተያየት መስመር። |
የሚወድቅ stream
stream ከተጀመረ በኋላ የሚከሰት ስህተት እንደ የስህተት ምላሽ ተመሳሳይ አካል ያለው error event ነው፦ {"type": "error", "error": {"type", "message"}}። የመዝጊያ events፣ message_delta እና message_stop፣ አሁንም ይከተላሉ። ምላሹን እንደ ወድቆ ይቁጠሩት እና ጥያቄውን እንደገና ይላኩ።
ስህተቶች
ስህተቶች የAnthropic የስህተት አካልን ይጠቀማሉ፦ type error ነው፣ እና error ነገሩ type እና message ይይዛል። ሠንጠረዡ ይህ endpoint ብዙ ጊዜ የሚመልሰውን ይዘረዝራል። ሙሉ ዝርዝሩ፣ ምን እንደገና መሞከር እንዳለበት ጋር፣ የራሱ ገጽ አለው። ስህተት አስተዳደር
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "unknown model: no-such-model"
}
} | ሁኔታ | ዓይነት | መልእክት | መቼ |
|---|---|---|---|
401 | authentication_error | Missing authenticationInvalid API key | API ቁልፍ አልተላከም፣ ወይም ቁልፉ የማይታወቅ ወይም የተሰረዘ ነው። |
400 | invalid_request_error | unknown model: <id> | model የShannon ሞዴል id አይደለም። |
400 | invalid_request_error | No user message provided | የShannon ደረጃዎች፦ ጥያቄው የተጠቃሚ ጽሑፍ የለውም እና tools የለውም። |
400 | invalid_request_error | <id> does not accept image input | ምስል ለምስል input ለሌለው የሆስት open-weight ሞዴል ተልኳል። |
422 | invalid_request_error | Failed to deserialize the JSON body into the target type: … | messages የለም፣ ወይም አንድ መስክ የተሳሳተ የJSON ዓይነት አለው። |
429 | rate_limit_error | Quota exceeded. Upgrade your plan at shannon-ai.com/plan | max_tokens ከቀሪ ሂሳብዎ ከቀረው ይበልጣል። |
429 | rate_limit_error | Too many requests. Retry in <n>s. | Flood protection፦ በመለያዎ በአንድ ደቂቃ ከ120 በላይ ጥያቄዎች። |
429 | rate_limit_error | Shannon Coder call quota reached. Upgrade your plan at shannon-ai.com/plan | shannon-coder-1፦ የፕላንዎ የShannon Coder ጥሪዎች ለአሁኑ የ4-ሰዓት መስኮት ተጠቅመው አልቀዋል። |
500 | server_error | The model backend failed to answer. Please retry. | ሞዴሉ ምላሽ አላመረተም። ጥያቄውን እንደገና ይላኩ። |
502 | api_error | The model backend failed to answer. Please retry. | ሞዴሉ ምላሽ አላመረተም። ጥያቄውን እንደገና ይላኩ። |
Tokens መቁጠር
POST /v1/messages/count_tokens ልክ እንደ መልእክት ጥያቄ ተመሳሳይ አካል (model, system, messages, tools) ይቀበላል እና {"input_tokens": n} ይመልሳል፦ ጥያቄው የሚያስከፍለው የinput tokens ብዛት። ለሆስት open-weight ሞዴሎች ይቆጥራል፣ ነጻ ነው፣ እና በ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} ቆጠራ ከግልጽ ጽሑፍ endpoint እና ከገደቦች ጋር የራሱ ገጽ አለው። የToken ቆጠራ