Anthropic
POST /v1/messages သည် Anthropic Messages format ဖြင့် request ကို လက်ခံပြီး stream လုပ်သည်ဖြစ်စေ မလုပ်သည်ဖြစ်စေ တူညီသော format ဖြင့် ပြန်ဖြေသည်။ Anthropic SDK နှင့် ၎င်းအပေါ်တည်ဆောက်ထားသော Claude Code ကဲ့သို့ tool များနှင့် အသုံးပြုပါ- base URL ကို သတ်မှတ်ပါ၊ သင့် Shannon API key ကို အသုံးပြုပါ၊ Shannon model id တစ်ခုကို ပေးပါ။
POST https://api.shannon-ai.com/v1/messages
Anthropic SDK ကို Shannon base URL သို့ ညွှန်ပါ။ SDK က /v1/messages ကို ထပ်ထည့်ပေးပြီး သင့် key ကို 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."}]
}' Reply သည် content ကို block စာရင်းအဖြစ်ပါရှိသော message ဖြစ်သည်။ Block များကို ၎င်းတို့၏ 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 key။ ၎င်းအစား Authorization: Bearer YOUR_API_KEY ကို လက်ခံသည်။ |
content-type | application/json | လိုအပ်သည်။ |
anthropic-version | 2023-06-01 | လက်ခံသည်၊ မလိုအပ်ပါ။ Anthropic SDK က 2023-06-01 ကို ပို့သည်။ တန်ဖိုးမည်သို့ပင်ဖြစ်စေ reply ၏ format တူညီသည်။ |
anthropic-beta | လက်ခံသည်၊ မလိုအပ်ပါ။ | |
x-request-id | မဖြည့်လည်းရသည်။ Request အတွက် သင့်ကိုယ်ပိုင် id။ reply တွင် မပြောင်းလဲဘဲ ပြန်ပါလာသည်။ မပါလျှင် reply တွင် hexadecimal စာလုံး 12 လုံးပါသော id ပါလာသည်။ |
Request fields
messages တစ်ခုတည်းသာ လိုအပ်သည်။ Applied by ကော်လံတွင် field တစ်ခုက reply ကို ပြောင်းလဲစေသည့် model များကို ဖော်ပြထားသည်။ Hosted open-weight models များသည် model စာရင်းရှိ id ဆယ့်နှစ်ခု ဖြစ်သည်။ Shannon 3 မိသားစုမှာ shannon-3၊ shannon-3-pro၊ shannon-3.1 နှင့် shannon-3.1-pro ဖြစ်သည်။ Model များနှင့် ဈေးနှုန်း
| Field | Type | Default | ဖော်ပြချက် | အသုံးပြုသော model |
|---|---|---|---|---|
model | string | shannon-1.6-lite | Model စာရင်းမှ Shannon model id။ Request တိုင်းနှင့်အတူ ပို့ပါ။ ကိုက်ညီမှုစစ်ရာတွင် စာလုံးအကြီးအသေး မခွဲပါ။ အခြားအမည်မည်သည့်အရာမဆို 400 unknown model ကို ပြန်ပေးသဖြင့် ကိုယ်ပိုင် model အမည်များ ပို့သည့် tool ကို Shannon id သို့ သတ်မှတ်ရမည်။ | Model အားလုံး |
messages | array | လိုအပ်သည်။ user နှင့် assistant role များပါသော စကားပြောဆိုမှု၊ အဟောင်းဆုံး message ကို ရှေ့ဆုံးတွင်။ အောက်ရှိ Messages and content blocks ကို ကြည့်ပါ။ | Model အားလုံး | |
system | string | array | Model အတွက် ညွှန်ကြားချက်များ- string သို့မဟုတ် text block များ၏ array။ အောက်ရှိ System prompt ကို ကြည့်ပါ။ | Host လုပ်ထားသော open-weight မော်ဒယ်များနှင့် shannon-1.6-*၊ shannon-2-*၊ shannon-coder-1 | |
max_tokens | integer | 4096 | Reply ၏ အထက်ကန့်သတ်ချက်ကို token ဖြင့် ဖော်ပြသည်။ ဤ endpoint တွင် မဖြည့်လည်းရသည်။ Anthropic SDK က အမြဲပို့သည်။ 1 မှ 65,536 အပြင်ဘက်ရှိ တန်ဖိုးကို ထိုအတိုင်းအတာအတွင်းသို့ ရွှေ့ပေးသည်။ Request လုပ်ဆောင်နေစဉ် သင့်လက်ကျန်မှ ဖယ်ထားသည့် ပမာဏလည်း ဖြစ်သည်။ | Host လုပ်ထားသော open-weight မော်ဒယ်များနှင့် shannon-1.6-lite၊ shannon-1.6-pro၊ shannon-coder-1 |
stream | boolean | false | true သည် reply ကို server-sent events အဖြစ် ပို့သည်။ အောက်ရှိ Streaming ကို ကြည့်ပါ။ | Model အားလုံး |
temperature | number | Sampling temperature ဖြစ်သည်။ Hosted open-weight models တွင် တန်ဖိုးများကို 0 မှ 2 အတွင်း ထိန်းထားပါသည်။ | Host လုပ်ထားသော open-weight မော်ဒယ်များနှင့် shannon-1.6-lite၊ shannon-1.6-pro၊ shannon-coder-1 | |
top_p | number | Nucleus sampling။ | Hosted open-weight models | |
stop_sequences | array | String 4 ခုအထိ။ ပထမဆုံးပေါ်လာသည့် string မတိုင်မီတွင် အဖြေ ပြီးဆုံးသည်။ stop_reason သည် end_turn အတိုင်း ဆက်ရှိနေသည်။ | Hosted open-weight models | |
tools | array | Model ခေါ်နိုင်သော tool များ၊ တစ်ခုစီကို {"name", "description", "input_schema"} ပုံစံဖြင့်။ အောက်ရှိ Tools ကို ကြည့်ပါ။ | Model အားလုံး | |
tool_choice | object | {"type": "auto"} သည် model ကို ဆုံးဖြတ်ခွင့်ပေးသည်၊ {"type": "any"} သည် tool တစ်ခုခုကို ခေါ်စေသည်၊ {"type": "tool", "name": "…"} သည် ထို tool ကို ခေါ်စေသည်။ | Hosted open-weight models | |
thinking | object | Model က မဖြေမီ မည်မျှ reasoning လုပ်မည်ကို သတ်မှတ်သည်။ အောက်ရှိ Thinking ကို ကြည့်ပါ။ | Hosted open-weight models | |
web_search | boolean | false | ဤ format သို့ Shannon က ထပ်ထည့်ထားသည်- true သည် model ကို မဖြေမီ web တွင် ရှာဖွေခွင့်ပေးသည်။ | shannon-1.6-*၊ shannon-2-*၊ Shannon 3 မိသားစု |
max_tokens မပါလျှင် တန်ဖိုးမှာ 4,096 ဖြစ်ပြီး shannon-coder-1 တွင် 65,536 ဖြစ်သည်။
metadata၊ top_k၊ service_tier နှင့် block များပေါ်ရှိ cache_control marker များကို လက်ခံသဖြင့် ရှိပြီးသား client code များ ပြောင်းလဲမှုမလိုဘဲ အလုပ်လုပ်ပါသည်။ ၎င်းတို့သည် reply ကို မပြောင်းလဲစေပါ။ hosted open-weight models တွင် prompt caching သည် အလိုအလျောက်ဖြစ်သည်။
Schema အတိုင်း JSON အဖြေကို Chat Completions တွင် response_format ဖြင့်၊ Responses တွင် text.format ဖြင့် တောင်းဆိုသည်။ ဖွဲ့စည်းထားသော အထွက်
System prompt နှင့် thinking ပါဝင်သည့် တောင်းဆိုမှု (request) တစ်ခု
ဤ request တွင် system prompt၊ thinking budget၊ temperature နှင့် stop sequence တစ်ခု ပါဝင်ပါသည်။ ၎င်းတို့အားလုံးကို လက်ခံအသုံးပြုသည့် hosted open-weight model ကို သုံးထားပါသည်။
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 models တွင် usage သည် prompt cache မှ ဖတ်ထားသော token များကို အခြား input token များနှင့် သီးခြားစီ ဖော်ပြသည်။
{
"usage": {
"input_tokens": 31,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0,
"output_tokens": 62
}
} System prompt
system သည် string သို့မဟုတ် [{"type": "text", "text": "…"}] ပုံစံရှိ text block များ၏ array ဖြစ်သည်။ Block များ၏ စာသားများကို line break ဖြင့် ပေါင်းစပ်သည်။
၎င်းကို host လုပ်ထားသော open-weight မော်ဒယ်များ၊ shannon-1.6-lite၊ shannon-1.6-pro၊ shannon-2-lite၊ shannon-2-pro နှင့် shannon-coder-1 တို့က အသုံးပြုသည်။ Shannon 3 မိသားစု id ဖြင့်ဆိုလျှင် မဖြစ်မနေ စောင့်ထိန်းရမည့် ညွှန်ကြားချက်များကို user message ထဲသို့ ထည့်ပါ။
Messages and content blocks
Message တစ်ခုတွင် user သို့မဟုတ် assistant ဖြစ်သော role နှင့် content ပါရှိသည်။ content သည် string သို့မဟုတ် block များ၏ array ဖြစ်သည်။
| Block | ဖော်ပြချက် | ရရှိနိုင်သည့်နေရာ |
|---|---|---|
{"type": "text", "text": "…"} | စာသား။ | Model အားလုံး |
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "…"}}{"type": "image", "source": {"type": "url", "url": "…"}} | user message ထဲရှိ ပုံကို base64 သို့မဟုတ် URL ဖြင့်။ | Shannon 3 မိသားစု၊ shannon-1.6-lite၊ shannon-1.6-pro နှင့် ပုံ input ပါဝင်ကြောင်း ဖော်ပြထားသော hosted open-weight models |
{"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} | user message ထဲရှိ စာရွက်စာတမ်း (PDF၊ Word၊ PowerPoint သို့မဟုတ် Excel) ကို base64 သို့မဟုတ် URL ဖြင့်။ | Shannon 3 မိသားစု |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | assistant message ထဲတွင်- model က အစောပိုင်း reply တွင် ပြုလုပ်ခဲ့သော tool call။ | Model အားလုံး |
{"type": "tool_result", "tool_use_id": "toolu_…", "content": "…"} | user message ထဲတွင်- ထို call ၏ ရလဒ်။ content သည် string သို့မဟုတ် text block စာရင်း ဖြစ်သည်။ | Model အားလုံး |
အစောပိုင်း reply တစ်ခု၏ content ကို မပြောင်းလဲဘဲ ပြန်ပို့နိုင်ပါသည်- text နှင့် tool_use block များကို ဖတ်ပြီး thinking block များကို ကျော်သွားပါသည်။
Shannon အဆင့်များတွင် ပုံများနှင့် စာရွက်စာတမ်းများကို နောက်ဆုံး user message မှ ဖတ်ပါသည်။ အရွယ်အစားနှင့် ကန့်သတ်ချက်များအတွက် သီးခြားစာမျက်နှာ ရှိပါသည်။ ပုံများနှင့် ဖိုင်များ
Thinking
Host လုပ်ထားသော open-weight မော်ဒယ်များက thinking ကို reasoning effort သို့ ပြောင်းပေးသည်။ Field မပါလျှင် effort သည် high ဖြစ်သည်။
| ပုံစံ | budget_tokens | သက်ရောက်မှု |
|---|---|---|
{"type": "disabled"} | Reasoning မလုပ်ပါ။ Reply တွင် 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 အဆင့်များကလည်း ၎င်းကို ပို့ပေးသည်။
Effort အဆင့်များကို ၎င်းတို့၏ သီးခြားစာမျက်နှာတွင် ဖော်ပြထားသည်။ Reasoning effort
Tools
Tool ဆိုသည်မှာ သင့် code က run သော function တစ်ခုဖြစ်သည်။ တစ်ခုစီကို name၊ description နှင့် input_schema ဖြင့် ဖော်ပြပါ။ မော်ဒယ်က tool တစ်ခု လိုချင်သည့်အခါ reply တွင် 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"
]
}
}
] ၎င်းကို ခေါ်သော reply ၏ content-
[
{
"type": "text",
"text": ""
},
{
"type": "tool_use",
"id": "toolu_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
"name": "get_weather",
"input": {
"city": "Paris"
}
}
] Tool ကို run ပါ၊ ထို့နောက် call နှင့် tool_result block ကို messages ထဲသို့ ထည့်ပြီး request ကို ထပ်ပို့ပါ-
[
{
"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
| ပုံစံ | သက်ရောက်မှု | အသုံးပြုသော model |
|---|---|---|
{"type": "auto"} | Tool ကို ခေါ်မည်၊ မခေါ်မည်ကို မော်ဒယ်က ဆုံးဖြတ်သည်။ ဤသည်မှာ default ဖြစ်သည်။ | Model အားလုံး |
{"type": "any"} | မော်ဒယ်သည် tool များထဲမှ တစ်ခုကို မဖြစ်မနေ ခေါ်ရမည်။ | Hosted open-weight models |
{"type": "tool", "name": "…"} | မော်ဒယ်သည် အမည်ပေးထားသော tool ကို မဖြစ်မနေ ခေါ်ရမည်။ | Hosted open-weight models |
input_schema ပါသော tool များကိုသာ ဖတ်သည်။ Web search သည် ဤ endpoint တွင် tool မဟုတ်ပါ- web_search field ကို သတ်မှတ်ပါ။
Tool loop ကို ၎င်း၏ သီးခြားစာမျက်နှာတွင် အပြည့်အစုံ ဖော်ပြထားသည်။ လုပ်ဆောင်ချက် ခေါ်ဆိုမှု
Reply
| Field | Type | ဖော်ပြချက် | ပို့သူ |
|---|---|---|---|
id | string | msg_ နောက်တွင် hexadecimal စာလုံး 32 လုံး လိုက်သည်။ | Model အားလုံး |
type | string | အမြဲတမ်း message ဖြစ်သည်။ | Model အားလုံး |
role | string | အမြဲတမ်း assistant ဖြစ်သည်။ | Model အားလုံး |
model | string | ဖြေကြားခဲ့သော မော်ဒယ်၏ canonical id။ | Model အားလုံး |
content | array | Reply ၏ block များကို ဤအစီအစဉ်အတိုင်း ပြသည်- မော်ဒယ်က reasoning လုပ်ခဲ့လျှင် thinking၊ ထို့နောက် text၊ ထို့နောက် tool call တစ်ခုစီအတွက် tool_use တစ်ခုစီ။ | Model အားလုံး |
stop_reason | string | Reply ပြီးဆုံးရသည့် အကြောင်းရင်း။ အောက်ရှိ တန်ဖိုးများကို ကြည့်ပါ။ | Model အားလုံး |
usage | object | input_tokens နှင့် output_tokens။ | Model အားလုံး |
sources | array | ရှာဖွေမှုတွင် တစ်စုံတစ်ရာ တွေ့ခဲ့သော web_search: true request တွင်သာ ပါသည်- model ကို ပေးခဲ့သော ရလဒ်များ၊ တစ်ခုစီတွင် index၊ title နှင့် url ပါသည်။ အဖြေထဲရှိ [1] သည် index 1 ရှိသော entry ဖြစ်သည်။ stream တွင် ၎င်းသည် message_delta event နှင့်အတူ လာသည်။ | 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 models |
Reply blocks
| Block | ဖော်ပြချက် |
|---|---|
{"type": "thinking", "thinking": "…"} | မော်ဒယ်၏ တွေးခေါ်မှု (reasoning) စာသား။ signature member မပါဝင်ပါ။ |
{"type": "text", "text": "…"} | အဖြေစာသား။ Reply သည် tool call ဖြစ်ပါက ဗလာဖြစ်နိုင်သည်။ |
{"type": "tool_use", "id": "toolu_…", "name": "…", "input": {…}} | Tool call တစ်ခု။ input သည် JSON object ဖြစ်သည်။ ရလဒ်ကို တူညီသော id ဖြင့် ပြန်ပို့ပါ။ |
stop_reason
| stop_reason | ဖော်ပြချက် | ပို့သူ |
|---|---|---|
end_turn | မော်ဒယ်က အဖြေကို အပြီးသတ်ခဲ့သည်၊ သို့မဟုတ် သင့် stop_sequences တစ်ခုခု ပေါ်လာခဲ့သည်။ | Model အားလုံး |
tool_use | Reply တွင် tool call တစ်ခု သို့မဟုတ် တစ်ခုထက်ပို၍ ပါဝင်သည်။ | Model အားလုံး |
max_tokens | Output ကန့်သတ်ချက်တွင် reply ကို ဖြတ်တောက်လိုက်သည်။ | Shannon 3 မိသားစု၊ shannon-1.6-lite၊ shannon-1.6-pro၊ shannon-coder-1၊ stream များတွင် |
Streaming
Server-sent events ရရန် stream ကို true သတ်မှတ်ပါ။ Frame တစ်ခုစီတွင် event အမည်ပါသော event: လိုင်းနှင့် type တွင် ထိုအမည်ကို ထပ်ဖော်ပြသော JSON object ပါသည့် data: လိုင်း ပါဝင်သည်။ Anthropic SDK ၏ stream helper များက ဤ event များကို သင့်အတွက် ဖတ်ပေးသည်-
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."}]
}' Event များကို ရောက်ရှိလာသည့် အစီအစဉ်အတိုင်း-
| Event | Data | ဘယ်အချိန် |
|---|---|---|
message_start | message | အမြဲတမ်း ပထမဆုံး။ message တွင် id၊ role၊ မော်ဒယ်၊ ဗလာ 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_use block အတွက် tool call ၏ argument များကို delta တစ်ခုတည်းဖြင့် ပြည့်စုံစွာ ပို့သည်။ |
content_block_stop | index | ဤ index ရှိ block ပြီးဆုံးသည်။ |
message_delta | delta {stop_reason, stop_sequence}, usage | Reply ၏ အဆုံးသတ်ပိုင်း- delta.stop_reason နှင့် ဤ request ၏ usage တို့ကို ပို့သည်။ |
message_stop | အမြဲတမ်း နောက်ဆုံး။ |
Block များကို ၎င်းတို့ ပွင့်လာသည့် အစီအစဉ်အတိုင်း index ဖြင့် နံပါတ်ပေးထားပြီး block တစ်ခု မပြီးမချင်း နောက်တစ်ခု မပွင့်ပါ။ Block တစ်ခုစီကို နံပါတ်ဖြင့် မဟုတ်ဘဲ type ဖြင့် ဖတ်ပါ- 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 | ဒေတာ {"type": "ping"} ပါသော ping event၊ 15 စက္ကန့်တိုင်း။ |
| Hosted open-weight models | မော်ဒယ် အလုပ်လုပ်နေစဉ် 15 စက္ကန့်တိုင်း : keepalive ဟူသော comment လိုင်း။ |
မအောင်မြင်သော stream
Stream စတင်ပြီးနောက် ဖြစ်ပေါ်သော ချို့ယွင်းမှုသည် error reply နှင့် တူညီသော body ပါသည့် error event ဖြစ်သည်- {"type": "error", "error": {"type", "message"}}။ နိဂုံးချုပ် event များဖြစ်သော message_delta နှင့် message_stop တို့ကား ဆက်လက်လိုက်လာသည်။ Reply ကို မအောင်မြင်ဟု သတ်မှတ်ပြီး request ကို ထပ်ပို့ပါ။
Errors
Error များသည် Anthropic error body ကို အသုံးပြုသည်- type သည် error ဖြစ်ပြီး error object တွင် type နှင့် message ပါရှိသည်။ ဇယားတွင် ဤ endpoint က အမြဲတမ်းနီးပါး ပြန်ပေးသည့် error များကို ဖော်ပြထားသည်။ ထပ်ကြိုးစားရမည့် အရာများပါသည့် စာရင်းအပြည့်အစုံအတွက် သီးခြားစာမျက်နှာ ရှိပါသည်။ အမှားကိုင်တွယ်မှု
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "unknown model: no-such-model"
}
} | Status | Type | Message | ဘယ်အချိန် |
|---|---|---|---|
401 | authentication_error | Missing authenticationInvalid API key | API key မပို့ခဲ့ပါ၊ သို့မဟုတ် key သည် မသိရှိသော သို့မဟုတ် ပယ်ဖျက်ထားသော key ဖြစ်သည်။ |
400 | invalid_request_error | unknown model: <id> | model သည် Shannon model id မဟုတ်ပါ။ |
400 | invalid_request_error | No user message provided | Shannon အဆင့်များ- request တွင် user စာသား မပါဝင်ပါ၊ tools လည်း မပါဝင်ပါ။ |
400 | invalid_request_error | <id> does not accept image input | ပုံ input မပါသော hosted open-weight model သို့ ပုံတစ်ခု ပို့ခဲ့သည်။ |
422 | invalid_request_error | Failed to deserialize the JSON body into the target type: … | messages မပါဝင်ပါ၊ သို့မဟုတ် field တစ်ခု၏ JSON type မှားနေသည်။ |
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- သင့်အကောင့်တွင် တစ်မိနစ်အတွင်း request 120 ထက်ပို၍ ပို့ခဲ့သည်။ |
429 | rate_limit_error | Shannon Coder call quota reached. Upgrade your plan at shannon-ai.com/plan | shannon-coder-1- လက်ရှိ 4 နာရီ window အတွက် သင့် plan ၏ Shannon Coder call များကို သုံးစွဲပြီးဖြစ်သည်။ |
500 | server_error | The model backend failed to answer. Please retry. | Model က reply မထုတ်ပေးခဲ့ပါ။ Request ကို ထပ်ပို့ပါ။ |
502 | api_error | The model backend failed to answer. Please retry. | Model က reply မထုတ်ပေးခဲ့ပါ။ Request ကို ထပ်ပို့ပါ။ |
Token ရေတွက်ခြင်း
POST /v1/messages/count_tokens သည် message request နှင့် တူညီသော body (model၊ system၊ messages၊ tools) ကို လက်ခံပြီး {"input_tokens": n} ကို ပြန်ပေးသည်- request အတွက် ကောက်ခံမည့် input token အရေအတွက်။ ၎င်းသည် hosted open-weight models အတွက် ရေတွက်ပေးပြီး အခမဲ့ဖြစ်ကာ 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} ရေတွက်ခြင်းအတွက် plain-text endpoint နှင့် ကန့်သတ်ချက်များပါသော သီးခြားစာမျက်နှာ ရှိပါသည်။ Token ရေတွက်ခြင်း