Anthropic ձևաչափ
POST /v1/messages-ը ընդունում է Anthropic Messages ձևաչափով հարցում և պատասխանում է նույն ձևաչափով՝ streaming-ով կամ առանց։ Օգտագործեք այն 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-ը բլոկների ցանկ է։ Բլոկները գտեք ըստ իրենց type-ի. երբ մոդելը տրամաբանել է, առաջին բլոկը 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-ը։ Կիրառվում է սյունը նշում է այն մոդելները, որոնց վրա դաշտը փոխում է պատասխանը։ Hosted open-weight մոդելները մոդելների ցանկի տասներկու id-ներն են. 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 դերերով։ Տես ստորև «Հաղորդագրություններ և բովանդակության բլոկներ»։ | Բոլոր մոդելները | |
system | string | array | Հրահանգներ մոդելի համար՝ տող կամ տեքստային բլոկների զանգված։ Տես ստորև «System prompt»։ | Hosted open-weight մոդելներ, shannon-1.6-*, shannon-2-*, shannon-coder-1 | |
max_tokens | integer | 4096 | Պատասխանի վերին սահմանը՝ թոքեններով։ Այս endpoint-ում պարտադիր չէ. Anthropic SDK-ն միշտ ուղարկում է այն։ 1-ից 65,536 միջակայքից դուրս արժեքը տեղափոխվում է այդ միջակայք։ Սա նաև այն քանակն է, որը հարցման ընթացքում առանձնացվում է ձեր մնացորդից։ | Hosted 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։ Hosted open-weight մոդելների վրա արժեքները պահվում են 0-ից 2 միջակայքում։ | Hosted open-weight մոդելներ, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | |
top_p | number | Nucleus sampling։ | Hosted open-weight մոդելներ | |
stop_sequences | array | Մինչև 4 տող։ Պատասխանը ավարտվում է դրանցից առաջինի հայտնվելուց առաջ։ stop_reason-ը մնում է end_turn։ | Hosted open-weight մոդելներ | |
tools | array | Գործիքները, որոնք մոդելը կարող է կանչել, յուրաքանչյուրը՝ որպես {"name", "description", "input_schema"}։ Տես ստորև «Գործիքներ»։ | Բոլոր մոդելները | |
tool_choice | object | {"type": "auto"}-ը թողնում է, որ մոդելը որոշի, {"type": "any"}-ը ստիպում է կանչել գործիք, {"type": "tool", "name": "…"}-ը ստիպում է կանչել հենց այդ գործիքը։ | Hosted open-weight մոդելներ | |
thinking | object | Որքան է մոդելը տրամաբանում պատասխանելուց առաջ։ Տես ստորև «Thinking»։ | Hosted 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 և բլոկների վրա cache_control նշիչները ընդունվում են, որպեսզի առկա կլիենտային կոդը աշխատի առանց փոփոխության։ Դրանք չեն փոխում պատասխանը. hosted open-weight մոդելների prompt caching-ը ավտոմատ է։
Սխեմային համապատասխան JSON պատասխանը հարցվում է response_format-ով Chat Completions-ում և text.format-ով Responses-ում։ Կառուցվածքային արդյունքներ
Հարցում system prompt-ով և thinking-ով
Այս հարցումն ուղարկում է system prompt, thinking բյուջե, temperature և stop sequence։ Այն օգտագործում է hosted 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?"}]
}' Hosted open-weight մոդելների վրա usage-ը prompt cache-ից կարդացված թոքենները ցույց է տալիս մուտքի մյուս թոքեններից առանձին։
{
"usage": {
"input_tokens": 31,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0,
"output_tokens": 62
}
} System prompt
system-ը տող է կամ տեքստային բլոկների զանգված [{"type": "text", "text": "…"}] ձևով։ Բլոկների տեքստերը միացվում են տողադարձով։
Այն կիրառվում է hosted open-weight մոդելներում, ինչպես նաև shannon-1.6-lite, shannon-1.6-pro, shannon-2-lite, shannon-2-pro և shannon-coder-1 մոդելներում։ Shannon 3 ընտանիքի id-ի դեպքում պարտադիր հրահանգները դրեք օգտատիրոջ հաղորդագրության մեջ։
Հաղորդագրություններ և բովանդակության բլոկներ
Հաղորդագրությունն ունի role՝ user կամ assistant, և content։ content-ը տող է կամ բլոկների զանգված։
| Բլոկ | Նկարագրություն | Հասանելի է |
|---|---|---|
{"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 և այն hosted open-weight մոդելները, որոնք նշում են պատկերի մուտքը |
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} | Փաստաթուղթ (PDF, Word, PowerPoint կամ Excel) user հաղորդագրության մեջ՝ base64-ով կամ URL-ով։ | Shannon 3 ընտանիք |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | assistant հաղորդագրության մեջ՝ գործիքի կանչ, որը մոդելը կատարել է նախորդ պատասխանում։ | Բոլոր մոդելները |
{"type": "tool_result", "tool_use_id": "toolu_…", "content": "…"} | user հաղորդագրության մեջ՝ այդ կանչի արդյունքը։ content-ը տող է կամ տեքստային բլոկների ցանկ։ | Բոլոր մոդելները |
Նախորդ պատասխանի content-ը կարող եք ուղարկել հետ այնպես, ինչպես կա. text և tool_use բլոկները կարդացվում են, thinking բլոկները բաց են թողնվում։
Shannon մակարդակներում պատկերներն ու փաստաթղթերը կարդացվում են վերջին user հաղորդագրությունից։ Չափերն ու սահմանաչափերն ունեն իրենց էջը։ Պատկերներ և ֆայլեր
Thinking
Hosted open-weight մոդելները thinking-ը համապատասխանեցնում են reasoning effort-ին։ Առանց այս դաշտի effort-ը բարձր է։
| Ձև | budget_tokens | Ազդեցություն |
|---|---|---|
{"type": "disabled"} | Առանց reasoning-ի։ Պատասխանում thinking բլոկ չկա։ | |
{"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-ը վերադարձնում է {"type": "thinking", "thinking": "…"} բլոկով՝ տեքստից առաջ։ Տրամաբանող Shannon մակարդակներն այն ուղարկում են նույնպես։
Effort-ների նկարագրությունը գտնվում է իրենց էջում։ Reasoning effort
Գործիքներ
Գործիքը ֆունկցիա է, որը կատարում է ձեր կոդը։ Նկարագրեք յուրաքանչյուրը name-ով, description-ով և input_schema-ով։ Երբ մոդելին գործիք է պետք, պատասխանը պարունակում է tool_use բլոկ, և stop_reason-ը tool_use է։
Գործիքի սահմանում tools-ում.
[
{
"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_result բլոկը ավելացնելով 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"} | Մոդելն ինքն է որոշում՝ կանչել գործիք, թե ոչ։ Սա լռելյայն արժեքն է։ | Բոլոր մոդելները |
{"type": "any"} | Մոդելը պետք է կանչի գործիքներից մեկը։ | Hosted open-weight մոդելներ |
{"type": "tool", "name": "…"} | Մոդելը պետք է կանչի նշված գործիքը։ | Hosted open-weight մոդելներ |
Կարդացվում են միայն input_schema ունեցող գործիքները։ Վեբ որոնումն այս endpoint-ում գործիք չէ. սահմանեք web_search դաշտը։
Գործիքային ցիկլն ամբողջությամբ նկարագրված է իր էջում։ Ֆունկցիայի կանչ
Պատասխանը
| Դաշտ | Տեսակ | Նկարագրություն | Ուղարկողը |
|---|---|---|---|
id | string | msg_, որին հաջորդում են 32 տասնվեցական նիշ։ | Բոլոր մոդելները |
type | string | Միշտ message։ | Բոլոր մոդելները |
role | string | Միշտ assistant։ | Բոլոր մոդելները |
model | string | Պատասխանած մոդելի կանոնական id-ն։ | Բոլոր մոդելները |
content | array | Պատասխանի բլոկները՝ այս հերթականությամբ. thinking՝ երբ մոդելը տրամաբանել է, text, ապա մեկական tool_use յուրաքանչյուր գործիքի կանչի համար։ | Բոլոր մոդելները |
stop_reason | string | Ինչու է պատասխանն ավարտվել։ Տես ստորև արժեքները։ | Բոլոր մոդելները |
usage | object | input_tokens և output_tokens։ | Բոլոր մոդելները |
sources | array | Միայն web_search: true ունեցող հարցման վրա, որի որոնումը ինչ-որ բան է գտել. մոդելին տրված արդյունքները, յուրաքանչյուրը index, title և url դաշտերով։ Պատասխանում [1]-ը այն գրառումն է, որի index-ը 1 է։ Հոսքում այն գալիս է message_delta իրադարձության հետ։ | shannon-1.6-*, shannon-2-*, Shannon 3 ընտանիք |
usage.cache_read_input_tokens | integer | cache_read_input_tokens-ը prompt-ի այն մասն է, որը կարդացվել է cache-ից. input_tokens-ը մնացածն է։ cache_creation_input_tokens-ը միշտ 0 է։ | Hosted open-weight մոդելներ |
Պատասխանի բլոկներ
| Բլոկ | Նկարագրություն |
|---|---|
{"type": "thinking", "thinking": "…"} | Մոդելի reasoning-ը։ signature անդամ չկա։ |
{"type": "text", "text": "…"} | Պատասխանի տեքստը։ Այն կարող է դատարկ լինել, երբ պատասխանը գործիքի կանչ է։ |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | Գործիքի կանչ։ input-ը JSON օբյեկտ է։ Արդյունքը ուղարկեք հետ նույն id-ով։ |
stop_reason
| stop_reason | Նկարագրություն | Ուղարկողը |
|---|---|---|
end_turn | Մոդելն ավարտել է իր պատասխանը, կամ հայտնվել է ձեր stop_sequences-ից մեկը։ | Բոլոր մոդելները |
tool_use | Պատասխանը պարունակում է գործիքի մեկ կամ մի քանի կանչ։ | Բոլոր մոդելները |
max_tokens | Պատասխանը կտրվել է ելքի սահմանաչափում։ | Shannon 3 ընտանիք, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1՝ հոսքերում |
Streaming
Սահմանեք stream-ը true՝ server-sent events ստանալու համար։ Յուրաքանչյուր շրջանակ ունի event: տող՝ իրադարձության անունով, և data: տող՝ JSON օբյեկտով, որը կրկնում է անունը type-ում։ Anthropic SDK-ի stream օգնականներն այս իրադարձությունները կարդում են ձեր փոխարեն.
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."}]
}' Իրադարձությունները՝ ըստ ժամանման հերթականության.
| Իրադարձություն | Տվյալներ | Երբ |
|---|---|---|
message_start | message | Միշտ առաջինն է։ message-ը պարունակում է id-ն, դերը, մոդելը, դատարկ content և զրոյից սկսվող usage։ |
content_block_start | index, content_block | Բլոկ է բացվում։ content_block-ը դատարկ text կամ thinking բլոկ է, կամ tool_use բլոկ՝ իր id-ով և name-ով։ |
content_block_delta | index, delta {"type": "thinking_delta", "thinking"} | Reasoning-ի մի հատված՝ thinking բլոկի համար։ |
content_block_delta | index, delta {"type": "text_delta", "text"} | Պատասխանի մի հատված՝ text բլոկի համար։ |
content_block_delta | index, delta {"type": "input_json_delta", "partial_json"} | tool_use բլոկի համար՝ գործիքի կանչի արգումենտները, ամբողջությամբ մեկ delta-ում։ |
content_block_stop | index | Այս index-ով բլոկն ավարտված է։ |
message_delta | delta {stop_reason, stop_sequence}, usage | Պատասխանի ավարտը՝ delta.stop_reason և հարցման usage-ը։ |
message_stop | Միշտ վերջինն է։ |
Բլոկները համարակալվում են index-ով՝ բացվելու հերթականությամբ, և յուրաքանչյուր բլոկ ավարտվում է մինչև հաջորդի բացվելը։ Բլոկը կարդացեք ըստ տեսակի, ոչ թե ըստ համարի. հոսքը կարող է սկզբում բացել դատարկ text բլոկ, ապա thinking բլոկ, և պատասխանը հասցնել հետագա 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
| Ուղարկողը | Նկարագրություն |
|---|---|
Shannon 3 ընտանիք, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | ping իրադարձություն՝ {"type": "ping"} տվյալներով, ամեն 15 վայրկյանը մեկ։ |
| Hosted open-weight մոդելներ | Մեկնաբանության տող : keepalive՝ ամեն 15 վայրկյանը մեկ, մինչ մոդելը աշխատում է։ |
Ձախողվող հոսք
Հոսքի սկսվելուց հետո տեղի ունեցած ձախողումը error իրադարձություն է, որի մարմինը նույնն է, ինչ սխալի պատասխանինը՝ {"type": "error", "error": {"type", "message"}}։ Փակող իրադարձությունները՝ 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 | Պատկեր է ուղարկվել hosted 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-պաշտպանություն. ձեր հաշվից մեկ րոպեում ավելի քան 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. | Մոդելը պատասխան չի ստեղծել։ Ուղարկեք հարցումը կրկին։ |
Թոքենների հաշվարկ
POST /v1/messages/count_tokens-ը ընդունում է նույն մարմինը, ինչ հաղորդագրության հարցումը (model, system, messages, tools), և վերադարձնում է {"input_tokens": n}՝ մուտքի այն թոքենների քանակը, որի համար հարցումից վճար կգանձվեր։ Այն աշխատում է hosted open-weight մոդելների համար, անվճար է և չի հաշվվում flood-պաշտպանության մեջ։
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-ով և սահմանաչափերով։ Թոքենների հաշվարկ