Chat Completions
POST /v1/chat/completions imalandira zokambirana ndikubweza message yotsatira ya model mu mtundu wa OpenAI Chat Completions. Igwiritseni ntchito kuchokera ku OpenAI SDK iliyonse kapena pa HTTP yosavuta; tsamba ili ndi reference ya field ndi field.
POST https://api.shannon-ai.com/v1/chat/completions
Pempho laling'ono kwambiri ndi model id ndi message imodzi ya user.
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.shannon-ai.com/v1",
)
response = client.chat.completions.create(
model="shannon-3",
messages=[{"role": "user", "content": "Say hello in one sentence."}],
)
print(response.choices[0].message.content) import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com/v1",
});
const response = await client.chat.completions.create({
model: "shannon-3",
messages: [{ role: "user", content: "Say hello in one sentence." }],
});
console.log(response.choices[0].message.content); curl https://api.shannon-ai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "shannon-3",
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}' Yankho ndi JSON object imodzi:
{
"id": "chatcmpl-5f0c1e7a9b3d4c62a8e1f07d2b46c9a3",
"object": "chat.completion",
"created": 1791625200,
"model": "shannon-3",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello, it is good to meet you.",
"reasoning_content": "The user wants a greeting in one sentence. Keep it short and friendly."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1184,
"completion_tokens": 46,
"total_tokens": 1230
}
} Ma header
Ma header a pempho
| Mutu | Mtengo | Kufotokozera |
|---|---|---|
Authorization | Bearer YOUR_API_KEY | API key yanu. x-api-key: YOUR_API_KEY imalandiridwa m'malo mwake pa endpoint iliyonse. |
Content-Type | application/json | Yofunika. Mtengo wina uliwonse umabweza 415. |
x-request-id | Mwasankha. Id yanu ya pempho. Imabwerera yosasinthika pa yankho. |
Ma header a yankho
| Mutu | Kufotokozera |
|---|---|
x-request-id | Pa yankho lililonse, kuphatikiza zolakwika ndi ma stream: mtengo womwe mwatumiza, kapena zilembo 12 za hexadecimal ngati simunatumize. Utchuleni mukamanena vuto. |
content-type | application/json, kapena text/event-stream pamene stream ndi true. |
Ma field a pempho
messages yokha ndiyofunika. Column ya Imagwira ntchito pa imatchula ma model omwe field imasintha yankho. Hosted open-weight model ndi ma id makumi atatu ndi atatu a mndandanda wa ma model; banja la Shannon 3 ndi shannon-3, shannon-3-pro, shannon-3.1 ndi shannon-3.1-pro. Ma model ndi mitengo
| Munda | Mtundu | Yokhazikika | Kufotokozera | Imagwira ntchito pa |
|---|---|---|---|---|
model | string | shannon-1.6-lite | Model yomwe imayankha: id yochokera mu mndandanda wa ma model. Itumizeni ndi pempho lililonse. Kufanana sikusiyanitsa zilembo zazikulu ndi zazing'ono. Id yomwe sinafalitsidwe imabweza 400 unknown model. | Ma model onse |
messages | array | Yofunika. Zokambirana, message yakale poyamba. Onani Messages pansipa. | Ma model onse | |
stream | boolean | false | true imatumiza yankho ngati server-sent events pamene likulembedwa. | Ma model onse |
max_tokens | integer | 4096 | Malire apamwamba a yankho, mu ma token. Mtengo wopitirira 1 mpaka 65,536 umasunthidwa kulowa mu malirewo. Ndi kuchuluka komwe kumasungidwa pa balance yanu pamene pempho likuyenda. Onani Output length pansipa. | Hosted open-weight model, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 |
max_completion_tokens | integer | Chimodzimodzi ndi max_tokens. Zonse ziwiri zikatumizidwa, max_tokens ndiyo imagwiritsidwa ntchito. | Hosted open-weight model, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | |
temperature | number | Sampling temperature. Pa hosted open-weight model default ndi 1 ndipo mitengo imasungidwa pakati pa 0 ndi 2. | Hosted open-weight model, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | |
top_p | number | 0.95 | Nucleus sampling. Mitengo imasungidwa pakati pa 0 ndi 1. | Hosted open-weight model |
seed | integer | Seed ya sampler, nambala iliyonse yonse. Popanda iyo, seed imachokera ku model ndi zokambirana, kotero pempho lomwelo lotumizidwa kawiri limagwiritsa ntchito seed yomweyo. | Hosted open-weight model | |
stop | string | array | String kapena array ya ma string. Mpaka 4 amagwiritsidwa ntchito. Yankho limatha isanafike yoyamba yomwe yaoneka; text ya stop yokha siibwezedwa. | Hosted open-weight model | |
reasoning_effort | string | high | Momwe model imaganizira isanayankhe: off, low, medium kapena high. none ndi minimal zimatanthauza off, default imatanthauza medium, max imatanthauza high. Mtengo wina uliwonse umabweza 400. | Hosted open-weight model |
reasoning | object | Chikhazikitso chomwecho mu mtundu wa object: {"effort": "low"}. Zonse ziwiri zikatumizidwa, reasoning_effort ndiyo imagwiritsidwa ntchito. | Hosted open-weight model | |
tools | array | Ma function omwe model ingayitane, aliyense ngati {"type": "function", "function": {"name", "description", "parameters"}}. Ma call a model amabwera mu tool_calls; code yanu imawayendetsa. | Ma model onse | |
tool_choice | string | object | auto | "auto" imalola model kusankha. "required" imaipangitsa kuyitana tool. {"type": "function", "function": {"name": "…"}} imaipangitsa kuyitana tool imeneyo. | Hosted open-weight model |
response_format | object | {"type": "json_object"} pa yankho la JSON, kapena {"type": "json_schema", "json_schema": {…}} pa yankho lotsatira schema yanu. | Ma tier onse a Shannon; hosted open-weight model monga mwalembedwera pa id iliyonse | |
web_search | boolean | false | true imalola model kusaka pa web isanayankhe. | shannon-1.6-*, shannon-2-*, banja la Shannon 3 |
Ma field ena a OpenAI, monga n, user, stream_options, presence_penalty, frequency_penalty, logit_bias, logprobs, metadata, store ndi prompt_cache_key, amalandiridwa kuti code ya client yomwe ilipo igwire ntchito popanda kusintha. Sasintha yankho: nthawi zonse pamakhala choice imodzi, ndipo stream imatha nthawi zonse ndi usage. parallel_tool_calls: false imasunga ma hosted open-weight model pa call imodzi ya tool pa turn; ma tier a Shannon amailandira ndikuinyalanyaza.
Field yokhala ndi JSON type yolakwika, mwachitsanzo "max_tokens": "100", imabweza 422. Pempho lopanda messages limabwezanso chimodzimodzi.
Ma tool, structured output, reasoning ndi web search chilichonse chili ndi tsamba lake: Kuyitana mafunkseni, Zotuluka zokonzedwa, Mphamvu ya kuganiza, Kusaka pa web.
Pempho lokhala ndi options
Pempho ili limakhazikitsa system message, ma sampling field ndi reasoning effort. Limagwiritsa ntchito hosted open-weight model, yomwe imagwiritsa ntchito zonsezo.
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.shannon-ai.com/v1",
)
response = client.chat.completions.create(
model="DeepSeek-V4-Flash-0731-uncensored-W4A16-AUTOROUND-REAP",
messages=[
{"role": "system", "content": "You are a physics teacher. Answer in two sentences."},
{"role": "user", "content": "Why is the sky blue?"},
],
max_tokens=512,
temperature=0.3,
top_p=0.9,
seed=7,
stop=["\n\n"],
reasoning_effort="low",
)
message = response.choices[0].message
print(message.reasoning_content) # the reasoning
print(message.content) # the answer
print(response.usage) import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com/v1",
});
const response = await client.chat.completions.create({
model: "DeepSeek-V4-Flash-0731-uncensored-W4A16-AUTOROUND-REAP",
messages: [
{ role: "system", content: "You are a physics teacher. Answer in two sentences." },
{ role: "user", content: "Why is the sky blue?" },
],
max_tokens: 512,
temperature: 0.3,
top_p: 0.9,
seed: 7,
stop: ["\n\n"],
reasoning_effort: "low",
});
const message = response.choices[0].message;
console.log(message.reasoning_content); // the reasoning
console.log(message.content); // the answer
console.log(response.usage); curl https://api.shannon-ai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "DeepSeek-V4-Flash-0731-uncensored-W4A16-AUTOROUND-REAP",
"messages": [
{"role": "system", "content": "You are a physics teacher. Answer in two sentences."},
{"role": "user", "content": "Why is the sky blue?"}
],
"max_tokens": 512,
"temperature": 0.3,
"top_p": 0.9,
"seed": 7,
"stop": ["\n\n"],
"reasoning_effort": "low"
}' Yankho lili ndi mawonekedwe ofanana ndi pamwambapa. usage yake imawonjezera zina ziwiri pa hosted open-weight model: ma prompt token owerengedwa kuchokera ku cache ndi ma token ogwiritsidwa ntchito pa reasoning.
{
"usage": {
"prompt_tokens": 31,
"completion_tokens": 62,
"total_tokens": 93,
"prompt_tokens_details": {
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 21
}
}
} Kutalika kwa output
max_tokens imachita zinthu ziwiri. Choyamba, ndi chiwerengero cha ma token omwe amaikidwa pambali kuchokera ku balance yanu pempho likayamba. Yankho likatha, ndalamayo imasinthidwa ndi ma token omwe pempho lagwiritsa ntchito. Ngati max_tokens ndi yaikulu kuposa balance yotsala, pempho limabweza 429 Not enough API credit ngakhale yankho lokha likanakwana. Tumizani max_tokens yotsika kuti muike pambali zochepa.
shannon-coder-1 imalipiritsidwa ngati mitundu ina yonse pa endpoint iyi: mu ma token, kuchokera ku API credit yanu. Palibe pulani yomwe imaphatikiza mafoni aulere. Malire ndi balance
Chachiwiri, imalepheretsa kutalika kwa yankho pa ma model awa:
| Ma model | Zomwe max_tokens imachita |
|---|---|
shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 | Yankho limaima likafika pa malire. Stream imatha ndi finish_reason length. |
| Hosted open-weight model | Text ya yankho imaima pa max_tokens. Reasoning siiwerengedwa mmenemo. Mitengo yochepera 256 imagwira ntchito ngati 256. |
Popanda max_tokens kapena max_completion_tokens, mtengo ndi 4,096. Pa shannon-coder-1 ndi 65,536.
Mauthenga
Message iliyonse ndi object yokhala ndi role ndi content. content ndi string, kapena array ya ma part pamene message ili ndi zoposa text.
| Udindo | Kufotokozera | Imagwira ntchito pa |
|---|---|---|
system | Malangizo a model. Ikeni poyamba. Pa ma tier a Shannon, message yoyamba ya system ndiyo imagwiritsidwa ntchito. | Hosted open-weight model, shannon-1.6-*, shannon-2-*, shannon-coder-1 |
developer | Imawerengedwa ngati system. | Hosted open-weight model |
user | Zomwe mukufunsa. Pa ma tier a Shannon, message yomaliza ya user ndi prompt ndipo ma message omwe ali patsogolo pake ndi history. | Ma model onse |
assistant | Mayankho akale a model. Sungani tool_calls yake mukatumiza zotsatira za tool pambuyo pake. | Ma model onse |
tool | Zotsatira za call ya tool: tool_call_id ili ndi id ya call ndipo content ili ndi zotsatira ngati string. | Ma model onse |
Ndi id ya banja la Shannon 3, ikani malangizo omwe ayenera kutsatiridwa mu message ya user.
Pa ma tier a Shannon, pempho lopanda text ya user komanso lopanda tools limabweza 400 No user message provided.
Ma content part
| Gawo | Kufotokozera | Ilipo pa |
|---|---|---|
{"type": "text", "text": "…"} | Text yosavuta. | Ma model onse |
{"type": "image_url", "image_url": {"url": "…"}} | Chithunzi, ngati data: URL yokhala ndi zomwe zili mu base64 kapena ngati http(s) URL. | Banja la Shannon 3, shannon-1.6-lite, shannon-1.6-pro, ndi hosted open-weight model zomwe zimalemba input ya zithunzi |
{"type": "file", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} | Chikalata (PDF, Word, PowerPoint kapena Excel), ngati base64 kapena ndi URL. | Banja la Shannon 3, ndi ma hosted open-weight model (otumizidwa mkati, osati ndi URL) |
Kukula, malire ndi mndandanda wathunthu wa mitundu zili patsamba lake. Zithunzi ndi ma file
Object ya yankho
| Munda | Mtundu | Kufotokozera |
|---|---|---|
id | string | chatcmpl- yotsatiridwa ndi zilembo 32 za hexadecimal. |
object | string | Nthawi zonse chat.completion. |
created | integer | Nthawi ya yankho, mu masekondi a Unix. |
model | string | Id yovomerezeka ya model yomwe yayankha. Kalembedwe kake kakhoza kusiyana ndi id yomwe mwatumiza. |
choices | array | Nthawi zonse choice imodzi yokha, ndi index 0. |
choices[0].message.role | string | Nthawi zonse assistant. |
choices[0].message.content | string | null | Text ya yankho. Ndi tool_calls imakhala null pa ma tier a Shannon; hosted open-weight model zimatha kutumiza text pambali pa ma call. |
choices[0].message.reasoning_content | string | null | Reasoning yomwe model idalemba isanayankhe, kapena null ngati palibe. |
choices[0].message.tool_calls | array | Imakhalapo pokhapokha model ikayitana ma tool. Entry iliyonse ili ndi id, type function, ndi function yokhala ndi name ndi arguments ngati JSON string. |
choices[0].message.annotations | array | Pa pempho lokha lokhala ndi web_search: true lomwe kusaka kwake kwapeza kanthu. url_citation imodzi pa gwero lililonse lomwe chizindikiro mu content chatchula, ndi url, title, start_index ndi end_index (malo a chizindikiro, owerengedwa m'zilembo, mapeto sakuphatikizidwa). |
choices[0].finish_reason | string | Chifukwa chomwe yankho linatha. Onani Zifukwa zotsirizira. |
usage | object | Ma token a pempho. Onani Usage. |
sources | array | Pa pempho lokha lokhala ndi web_search: true lomwe kusaka kwake kwapeza kanthu: zotsatira zomwe model idapatsidwa, chilichonse ndi index, title ndi url. [1] mu yankho ndi cholowa chokhala ndi index 1. |
Zifukwa zotsirizira
| finish_reason | Kufotokozera |
|---|---|
stop | Model yamaliza yankho lake, kapena string ya stop yaoneka. |
tool_calls | Model imayitana tool imodzi kapena zingapo. Zigwiritseni ntchito ndipo tumizani zotsatira mu ma message a tool. |
length | Yankho lidadulidwa pa malire a output. Limanenedwa mu ma stream a shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 ndi banja la Shannon 3. |
Yankho losachita stream limanena stop kapena tool_calls.
Kagwiritsidwe
| Munda | Mtundu | Kufotokozera | Ilipo pa |
|---|---|---|---|
usage.prompt_tokens | integer | Ma input token. | Ma model onse |
usage.completion_tokens | integer | Ma output token: reasoning, yankho ndi ma call a tool pamodzi. | Ma model onse |
usage.total_tokens | integer | prompt_tokens kuphatikiza completion_tokens. | Ma model onse |
usage.prompt_tokens_details.cached_tokens | integer | Gawo la prompt_tokens lomwe linawerengedwa kuchokera ku prompt cache. | Hosted open-weight model |
usage.completion_tokens_details.reasoning_tokens | integer | Gawo la completion_tokens lomwe linagwiritsidwa ntchito pa reasoning. | Hosted open-weight model |
Pa hosted open-weight model, prompt_tokens ndi ma message anu ndi matanthauzo a ma tool owerengedwa ndi tokenizer ya model yokha, kuphatikiza ma token a zithunzi zilizonse. Ma endpoint owerengera ma token amabweza nambala yomweyo musanatumize. Kuwerenga ma token
Pa ma tier a Shannon, prompt_tokens imawerenga chilichonse chomwe model idawerenga kuti ilembe yankho, kotero ndi yayikulu kuposa text ya ma message anu yokha.
Kutumiza mosalekeza
Ndi stream yokhazikitsidwa kukhala true yankho limafika ngati ma event a chat.completion.chunk ndipo limatha ndi data: [DONE]. Chunk yomaliza isanafike imanyamula finish_reason ndi usage; palibe stream_options yofunika. Mawonekedwe a ma chunk, mizere ya keep-alive ndi zolakwika mkati mwa stream zili patsamba lawo. Kutsitsa nthawi yeniyeni
Zolakwika
Cholakwika ndi JSON object yokhala ndi member ya error. Kuyang'ana kumachitika motere: API key, body ya pempho, model id, kenako balance. Table imalemba zomwe endpoint iyi imabweza kawirikawiri. Mndandanda wonse, ndi zoyenera kuyesanso, uli patsamba lake. Zolakwika
{
"error": {
"type": "invalid_request_error",
"message": "unknown model: no-such-model"
}
} | Mkhalidwe | Mtundu | Uthenga | Liti |
|---|---|---|---|
401 | authentication_error | Missing authenticationInvalid API key | API key sinatumizidwe, kapena kiyi siidziwika kapena yathetsedwa. |
400 | invalid_request_error | unknown model: <id> | model si id yofalitsidwa. |
400 | invalid_request_error | No user message provided | Ma tier a Shannon: pempho lilibe text ya user ndipo lilibe tools. |
400 | invalid_request_error | <id> does not accept image input | Part ya chithunzi inatumizidwa ku hosted open-weight model yopanda input ya zithunzi. |
400 | invalid_request_error | <id> does not accept response_format | response_format inatumizidwa ku hosted open-weight model yopanda structured output. |
400 | invalid_request_error | unknown reasoning effort '<value>'; expected off, low, medium or high | reasoning_effort ili ndi mtengo wopitirira mndandanda. |
422 | invalid_request_error | Failed to deserialize the JSON body into the target type: … | messages ikusowa, kapena field ili ndi JSON type yolakwika. |
429 | insufficient_quota | Not enough API credit. Top up at shannon-ai.com/tokens or get a GPU plan at shannon-ai.com/docs/api/plans | max_tokens ndi yayikulu kuposa zomwe zatsala pa balance yanu. |
429 | rate_limit_error | Too many requests. Retry in <n>s. | Flood protection: ma pempho opitirira 120 mu mphindi imodzi pa akaunti yanu. |
500 | server_error | The model backend failed to answer. Please retry. | Model sinapange yankho. Tumizaninso pempho. |
502 | api_error | The model backend failed to answer. Please retry. | Chimodzimodzi, pa banja la Shannon 3 ndi hosted open-weight model. |
