Fò lọ sí àkóónú
Chat Completions

Chat Completions

POST /v1/chat/completions gba ìjíròrò, ó sì dá ìfiránṣẹ́ model tó kàn padà ní ọ̀nà OpenAI Chat Completions. Lò ó láti inú SDK OpenAI èyíkéyìí tàbí lórí HTTP lásán; ojú-ìwé yìí ni ìtọ́kasí field-by-field.

POST https://api.shannon-ai.com/v1/chat/completions

Ìbéèrè tó kéré jù jẹ́ id model àti ìfiránṣẹ́ user kan.

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)

Èsì náà jẹ́ object JSON kan:

200 JSON
{
  "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
  }
}

Àwọn header

Àwọn header ìbéèrè

Header Iye Àpèjúwe
Authorization Bearer YOUR_API_KEY API key rẹ. A gba x-api-key: YOUR_API_KEY dípò rẹ̀ lórí gbogbo endpoint.
Content-Type application/json Dandan. Iye mìíràn yòówù yóò dá 415 padà.
x-request-id Àṣàyàn. Id tìrẹ fún ìbéèrè náà. Ó padà wá láìyípadà lórí èsì.

Àwọn header èsì

Header Àpèjúwe
x-request-id Lórí gbogbo èsì, pẹ̀lú àwọn àṣìṣe àti stream: iye tí o fi ránṣẹ́, tàbí àwọn ọ̀rọ̀ hexadecimal 12 nígbà tí o kò fi nǹkan ránṣẹ́. Dárúkọ rẹ̀ nígbà tí o bá ròyìn ìṣòro.
content-type application/json, tàbí text/event-stream nígbà tí stream bá jẹ́ true.

Àwọn field ìbéèrè

messages nìkan ni a nílò. Ọ̀wọ́n Ó ń ṣiṣẹ́ lórí ń dárúkọ àwọn model tí field kan ti yí èsì padà. Àwọn model open-weight tí a gbàlejò ni id méjìlá inú àtòkọ model; ìdílé Shannon 3 jẹ́ shannon-3, shannon-3-pro, shannon-3.1 àti shannon-3.1-pro. Àwọn model àti iye owó

Field Irú Default Àpèjúwe Ó ń ṣiṣẹ́ lórí
model string shannon-1.6-lite Model tó ń dáhùn: id láti inú àtòkọ model. Fi ránṣẹ́ pẹ̀lú gbogbo ìbéèrè. Ìbáramu kì í ṣe ti ìwọ̀n lẹ́tà. Id tí a kò tẹ̀jáde máa ń dá 400 unknown model padà. Gbogbo model
messages array A nílò rẹ̀. Ìjíròrò náà, ìfiránṣẹ́ àtijọ́ jùlọ ní iwájú. Wo Àwọn ìfiránṣẹ́ nísàlẹ̀. Gbogbo model
stream boolean false true ń fi èsì ránṣẹ́ gẹ́gẹ́ bí server-sent events bí a ṣe ń kọ ọ́. Gbogbo model
max_tokens integer 4096 Ààlà òkè èsì, ní token. Iye tó wà lóde 1 sí 65,536 ni a ń gbé wọnú ààlà yẹn. Òun náà ni iye tí a fi pamọ́ kúrò nínú balance rẹ nígbà tí ìbéèrè náà ń ṣiṣẹ́. Wo Gígùn output nísàlẹ̀. Àwọn model open-weight tí a gbàlejò, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1
max_completion_tokens integer Bákan náà pẹ̀lú max_tokens. Nígbà tí a bá fi méjèèjì ránṣẹ́, a ó lo max_tokens. Àwọn model open-weight tí a gbàlejò, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1
temperature number Sampling temperature. Lórí àwọn model open-weight tí a gbàlejò, iye àìyípadà jẹ́ 1, a sì ń mú àwọn iye wà láàrín 0 àti 2. Àwọn model open-weight tí a gbàlejò, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1
top_p number 0.95 Nucleus sampling. A ń mú àwọn iye wà láàrín 0 àti 1. Àwọn model open-weight tí a gbàlejò
seed integer Seed ti sampler, nọ́ńbà odidi èyíkéyìí. Láìsí i, a ń mú seed jáde láti inú model àti ìjíròrò, nítorí náà ìbéèrè kan náà tí a fi ránṣẹ́ lẹ́ẹ̀mejì ń lo seed kan náà. Àwọn model open-weight tí a gbàlejò
stop string | array String kan tàbí array ti àwọn string. A ń lo títí dé 4. Ìdáhùn parí ṣáájú èyí àkọ́kọ́ tó bá hàn; a kì í dá ọ̀rọ̀ stop fúnra rẹ̀ padà. Àwọn model open-weight tí a gbàlejò
reasoning_effort string high Bí model ṣe ń ronú tó kí ó tó dáhùn: off, low, medium tàbí high. none àti minimal túmọ̀ sí off, default túmọ̀ sí medium, max sì túmọ̀ sí high. Iye mìíràn yòówù yóò dá 400 padà. Àwọn model open-weight tí a gbàlejò
reasoning object Ètò kan náà ní ìrísí object: {"effort": "low"}. Nígbà tí a bá fi méjèèjì ránṣẹ́, a ó lo reasoning_effort. Àwọn model open-weight tí a gbàlejò
tools array Àwọn function tí model lè pè, ọ̀kọ̀ọ̀kan bí {"type": "function", "function": {"name", "description", "parameters"}}. Àwọn ìpè model padà wá nínú tool_calls; code rẹ ni ó ń ṣe wọ́n. Gbogbo model
tool_choice string | object auto "auto" jẹ́ kí model pinnu. "required" mú kí ó pe tool kan. {"type": "function", "function": {"name": "…"}} mú kí ó pe tool yẹn. Àwọn model open-weight tí a gbàlejò
response_format object {"type": "json_object"} fún ìdáhùn JSON, tàbí {"type": "json_schema", "json_schema": {…}} fún ìdáhùn tó tẹ̀lé schema rẹ. Gbogbo ìpele Shannon; àwọn model open-weight tí a gbàlejò gẹ́gẹ́ bí a ṣe kọ̀ wọ́n fún id kọ̀ọ̀kan
web_search boolean false true jẹ́ kí model wá nǹkan lórí wẹ́ẹ̀bù kí ó tó dáhùn. shannon-1.6-*, shannon-2-*, ìdílé Shannon 3

A gba àwọn field OpenAI mìíràn, bíi n, user, stream_options, parallel_tool_calls, presence_penalty, frequency_penalty, logit_bias, logprobs, metadata, store àti prompt_cache_key, kí code client tó wà tẹ́lẹ̀ lè ṣiṣẹ́ láìyípadà. Wọn kì í yí èsì padà: choice kan ni ó máa ń wà nígbà gbogbo, stream sì máa ń parí pẹ̀lú usage nígbà gbogbo.

Field tí irú JSON rẹ̀ kò tọ̀, fún àpẹẹrẹ "max_tokens": "100", yóò dá 422 padà. Ìbéèrè tí kò ní messages náà ń dá a padà.

Àwọn tool, structured output, ìrònú àti ìwá orí wẹ́ẹ̀bù ní ojú-ìwé tiwọn: Ipe iṣẹ, Awọn igbejade ti a ṣeto, Ipa ìrònú, Iwadi Wẹẹbu ti a ṣe sinu.

Ìbéèrè pẹ̀lú àwọn aṣayan

Ìbéèrè yìí ṣètò ìfiránṣẹ́ system, àwọn field sampling àti Ipa ìrònú. Ó lo model open-weight tí a gbàlejò, èyí tó ń lo gbogbo wọn.

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-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)

Èsì náà ní ìrísí kan náà bí òkè. usage rẹ̀ ń fi ẹ̀kúnrẹ́rẹ́ méjì kún lórí àwọn model open-weight tí a gbàlejò: àwọn token prompt tí a kà láti inú cache àti àwọn token tí a lò lórí ìrònú.

200 JSON
{
  "usage": {
    "prompt_tokens": 31,
    "completion_tokens": 62,
    "total_tokens": 93,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 21
    }
  }
}

Gígùn output

max_tokens ń ṣe nǹkan méjì. Àkọ́kọ́, ó jẹ́ iye token tí a fi pamọ́ láti inú balance rẹ nígbà tí ìbéèrè bẹ̀rẹ̀. Nígbà tí èsì bá parí, iye yẹn ni a ó fi àwọn token tí ìbéèrè náà lò rọ́pò. Tí max_tokens bá tóbi ju ohun tó kù nínú balance rẹ, ìbéèrè náà yóò dá 429 Quota exceeded padà bí èsì fúnra rẹ̀ bá tilẹ̀ wọ̀. Fi max_tokens tó kéré jù ránṣẹ́ láti fi pamọ́ díẹ̀.

A ń ka shannon-coder-1 lọ́nà míràn lórí endpoint yìí: ìbéèrè kọ̀ọ̀kan jẹ́ ọ̀kan nínú àwọn ìpè Shannon Coder ti plan rẹ, a kò sì fi token pamọ́ fún un. Àwọn ààlà àti balance

Èkejì, ó ń fi ààlà sí gígùn èsì lórí àwọn model wọ̀nyí:

Àwọn model Ohun tí max_tokens ń ṣe
shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 Èsì dúró nígbà tó bá dé ààlà. Stream náà yóò parí pẹ̀lú finish_reason length.
Àwọn model open-weight tí a gbàlejò Ọ̀rọ̀ ìdáhùn dúró ní max_tokens. A kò ka ìrònú sínú rẹ̀. Àwọn iye tó wà lábẹ́ 256 ń ṣiṣẹ́ bí 256.

Láìsí max_tokens tàbí max_completion_tokens, iye náà jẹ́ 4,096. Lórí shannon-coder-1 ó jẹ́ 65,536.

Àwọn ìfiránṣẹ́

Ìfiránṣẹ́ kọ̀ọ̀kan jẹ́ object pẹ̀lú role àti content. content jẹ́ string, tàbí array ti àwọn apá nígbà tí ìfiránṣẹ́ náà bá gbé ju ọ̀rọ̀ lọ.

Role Àpèjúwe Ó ń ṣiṣẹ́ lórí
system Àwọn ìtọ́ni fún model. Fi sí ipò àkọ́kọ́. Lórí àwọn ipele Shannon, ìfiránṣẹ́ system àkọ́kọ́ ni a ń lò. Àwọn model open-weight tí a gbàlejò, shannon-1.6-*, shannon-2-*, shannon-coder-1
developer A kà á bí system. Àwọn model open-weight tí a gbàlejò
user Ohun tí o béèrè. Lórí àwọn ipele Shannon, ìfiránṣẹ́ user tó gbẹ̀yìn ni prompt, àwọn ìfiránṣẹ́ tó wà ṣáájú rẹ̀ sì jẹ́ ìtàn. Gbogbo model
assistant Àwọn èsì model tẹ́lẹ̀. Pa tool_calls rẹ̀ mọ́ nígbà tí o bá fi abajade tool ránṣẹ́ lẹ́yìn rẹ̀. Gbogbo model
tool Abajade ìpè tool: tool_call_id gbé id ìpè náà mú, content sì gbé abajade náà bí string. Gbogbo model

Pẹ̀lú id ìdílé Shannon 3, fi àwọn ìtọ́ni tó gbọdọ̀ dúró sínú ìfiránṣẹ́ user.

Lórí àwọn ipele Shannon, ìbéèrè tí kò ní ọ̀rọ̀ user tàbí tools ń dá 400 No user message provided padà.

Àwọn apá àkóónú

Part Àpèjúwe Wà lórí
{"type": "text", "text": "…"} Ọ̀rọ̀ lásán. Gbogbo model
{"type": "image_url", "image_url": {"url": "…"}} Àwòrán kan, bí URL data: pẹ̀lú àkóónú base64 tàbí bí URL http(s). Ìdílé Shannon 3, shannon-1.6-lite, shannon-1.6-pro, àti àwọn model open-weight tí a gbàlejò tí wọ́n ń kọ image input sílẹ̀
{"type": "file", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} Ìwé kan (PDF, Word, PowerPoint tàbí Excel), bí base64 tàbí nípasẹ̀ URL. Ìdílé Shannon 3

Àwọn ìwọ̀n, ààlà àti àtòjọ kíkún ti àwọn ọ̀nà ní ojú-ìwé tiwọn. Àwọn àwòrán àti fáìlì

Object èsì

Field Irú Àpèjúwe
id string chatcmpl- tí àwọn ọ̀rọ̀ hexadecimal 32 tẹ̀lé.
object string Nígbà gbogbo chat.completion.
created integer Àkókò èsì, ní ìṣẹ́jú-àáyá Unix.
model string Id canonical ti model tó dáhùn. Ìkọ̀wé rẹ̀ lè yàtọ̀ sí id tí o fi ránṣẹ́.
choices array Nígbà gbogbo choice kan ṣoṣo, pẹ̀lú index 0.
choices[0].message.role string Nígbà gbogbo assistant.
choices[0].message.content string | null Ọ̀rọ̀ ìdáhùn. Pẹ̀lú tool_calls ó jẹ́ null lórí àwọn ipele Shannon; àwọn model open-weight tí a gbàlejò lè fi ọ̀rọ̀ ránṣẹ́ lẹ́gbẹ̀ẹ́ àwọn ìpè.
choices[0].message.reasoning_content string | null Ìrònú tí model kọ ṣáájú ìdáhùn, tàbí null nígbà tí kò sí.
choices[0].message.tool_calls array Ó wà nígbà tí model bá pe àwọn tool nìkan. Ìkọ̀sílẹ̀ kọ̀ọ̀kan ní id, type function, àti function pẹ̀lú name àti arguments bí string JSON.
choices[0].message.annotations array Lórí ìbéèrè tó ní web_search: true nìkan, tí ìwádìí rẹ̀ rí nǹkan. url_citation kan fún orísun kọ̀ọ̀kan tí àmì kan nínú content dárúkọ, pẹ̀lú url, title, start_index àti end_index (ipò àmì náà, tí a kà ní àwọn character, a kò ka òpin).
choices[0].finish_reason string Ìdí tí èsì fi parí. Wo Àwọn ìdí ìparí.
usage object Àwọn token ìbéèrè náà. Wo Ìlò.
sources array Lórí ìbéèrè tó ní web_search: true nìkan, tí ìwádìí rẹ̀ rí nǹkan: àwọn abajade tí a fún model, kọ̀ọ̀kan pẹ̀lú index, title àti url. [1] nínú ìdáhùn ni ẹnu-ọ̀nà tí index rẹ̀ jẹ́ 1.

Àwọn ìdí ìparí

finish_reason Àpèjúwe
stop Model parí ìdáhùn rẹ̀, tàbí string stop kan hàn.
tool_calls Model ń pe tool kan tàbí jù bẹ́ẹ̀ lọ. Ṣe wọ́n, kí o sì fi àwọn abajade ránṣẹ́ nínú àwọn ìfiránṣẹ́ tool.
length A gé èsì náà ní ààlà output. A ń ròyìn rẹ̀ nínú àwọn stream ti shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 àti ìdílé Shannon 3.

Èsì tí kì í ṣe streaming ń ròyìn stop tàbí tool_calls.

Ìlò

Field Irú Àpèjúwe Wà lórí
usage.prompt_tokens integer Àwọn token input. Gbogbo model
usage.completion_tokens integer Àwọn token output: ìrònú, ìdáhùn àti àwọn ìpè tool papọ̀. Gbogbo model
usage.total_tokens integer prompt_tokens àti completion_tokens papọ̀. Gbogbo model
usage.prompt_tokens_details.cached_tokens integer Apá prompt_tokens tí a kà láti inú prompt cache. Àwọn model open-weight tí a gbàlejò
usage.completion_tokens_details.reasoning_tokens integer Apá completion_tokens tí a lò lórí ìrònú. Àwọn model open-weight tí a gbàlejò

Lórí àwọn model open-weight tí a gbàlejò, prompt_tokens jẹ́ àwọn ìfiránṣẹ́ rẹ àti àwọn ìtumọ̀ tool tí a kà pẹ̀lú tokenizer ti model fúnra rẹ̀, pẹ̀lú àwọn token àwọn àwòrán èyíkéyìí. Àwọn endpoint ìkà token ń dá nọ́ńbà kan náà padà ṣáájú kí o tó fi ránṣẹ́. Kíka token

Lórí àwọn ipele Shannon, prompt_tokens ń ka gbogbo ohun tí model kà láti kọ èsì, nítorí náà ó tóbi ju ọ̀rọ̀ àwọn ìfiránṣẹ́ rẹ nìkan lọ.

Streaming

Pẹ̀lú stream tí a ṣètò sí true, èsì dé bí àwọn event chat.completion.chunk, ó sì parí pẹ̀lú data: [DONE]. Chunk tó gbẹ̀yìn ṣáájú rẹ̀ gbé finish_reason àti usage; a kò nílò stream_options. Ìrísí àwọn chunk, àwọn ìlà keep-alive àti àwọn àṣìṣe inú stream ní ojú-ìwé tiwọn. Sisanwọle

Àwọn àṣìṣe

Àṣìṣe jẹ́ JSON object tó ní member error. Àwọn àyẹ̀wò ń ṣiṣẹ́ ní ìtòlẹ́sẹẹsẹ yìí: API key, body ìbéèrè, id model, lẹ́yìn náà balance. Tábìlì náà ń kọ ohun tí endpoint yìí máa ń dá padà jùlọ. Àtòkọ kíkún, pẹ̀lú ohun tí a ó tún gbìyànjú, ní ojú-ìwé tirẹ̀. Mimu Aṣiṣe

400 JSON
{
  "error": {
    "type": "invalid_request_error",
    "message": "unknown model: no-such-model"
  }
}
Ipò Irú Ìfiránṣẹ́ Ìgbà
401 authentication_error Missing authentication
Invalid API key
A kò fi API key ránṣẹ́, tàbí key náà kò ṣe é mọ̀ tàbí a ti wọ́gi lé e.
400 invalid_request_error unknown model: <id> model kì í ṣe id tí a tẹ̀jáde.
400 invalid_request_error No user message provided Àwọn ìpele Shannon: ìbéèrè náà kò ní ọ̀rọ̀ user àti kò ní tools.
400 invalid_request_error <id> does not accept image input A fi part àwòrán ránṣẹ́ sí model open-weight tí a gbàlejò tí kò ní image input.
400 invalid_request_error <id> does not accept response_format A fi response_format ránṣẹ́ sí model open-weight tí a gbàlejò tí kò ní structured output.
400 invalid_request_error unknown reasoning effort '<value>'; expected off, low, medium or high reasoning_effort ní iye tó wà lóde àtòkọ náà.
422 invalid_request_error Failed to deserialize the JSON body into the target type: … messages kò sí, tàbí field kan ní irú JSON tí kò tọ́.
429 rate_limit_error Quota exceeded. Upgrade your plan at shannon-ai.com/plan max_tokens pọ̀ ju ohun tó kù nínú balance rẹ lọ.
429 rate_limit_error Too many requests. Retry in <n>s. Ààbò flood: ìbéèrè tó ju 120 lọ ní ìṣẹ́jú kan lórí account rẹ.
500 server_error The model backend failed to answer. Please retry. Model náà kò mú èsì jáde. Fi ìbéèrè náà ránṣẹ́ lẹ́ẹ̀kan sí i.
502 api_error The model backend failed to answer. Please retry. Bákan náà, lórí ìdílé Shannon 3 àti àwọn model open-weight tí a gbàlejò.