Simira kuzvirimo
Chat Completions

Chat Completions

POST /v1/chat/completions inotora hurukuro ndokudzosa message inotevera ye-model mu-OpenAI Chat Completions format. Shandisa kubva ku-OpenAI SDK ipi neipi kana kuburikidza ne-HTTP chaiyo; peji iyi ndiyo reference ye-field nefield.

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

Request diki kwazvo i-model id ne-user message imwe.

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)

Mhinduro i-JSON object imwe:

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

Headers

Request headers

Header Value Tsananguro
Authorization Bearer YOUR_API_KEY API key yako. x-api-key: YOUR_API_KEY inogamuchirwa panzvimbo payo pa-endpoint imwe neimwe.
Content-Type application/json Inodiwa. Chero value imwe inodzosa 415.
x-request-id Haidiwi. Id yako pachako ye-request. Inodzoka isina kuchinjwa mumhinduro.

Reply headers

Header Tsananguro
x-request-id Pamhinduro imwe neimwe, ma-error ne-streams zvakaverengwa: value yawakatumira, kana hexadecimal characters 12 kana usina kutumira. Itaure kana uchitaura nezve dambudziko.
content-type application/json, kana text/event-stream kana stream i-true.

Request fields

messages chete ndiyo inodiwa. Column ye-Applied by inotaura ma-model apo field inochinja mhinduro. Hosted open-weight models ndiwo ma-id gumi nemaviri e-model list; mhuri ye-Shannon 3 ndi-shannon-3, shannon-3-pro, shannon-3.1 ne-shannon-3.1-pro. Ma-model nemitengo

Field Mhando Default Tsananguro Inoshandiswa ne
model string shannon-1.6-lite Model inopindura: id kubva mu-model list. Itumire ne-request imwe neimwe. Kuenzanisa hakuteereri mavara makuru nemadiki. Id isiri published inodzosa 400 unknown model. Ma-model ese
messages array Inodiwa. Hurukuro, message yekare iri pamberi. Tarisa Messages pazasi. Ma-model ese
stream boolean false true inotumira mhinduro se-server-sent events ichiri kunyorwa. Ma-model ese
max_tokens integer 4096 Muganho wepamusoro wemhinduro, mu-tokens. Value iri kunze kwe-1 kusvika 65,536 inoendeswa mu-range iyoyo. Ndiyo zvakare huwandu hunochengetwa mu-balance yako request ichiri kushanda. Tarisa Output length pazasi. Hosted open-weight models, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1
max_completion_tokens integer Yakafanana ne-max_tokens. Kana dzese dzatumirwa, max_tokens ndiyo inoshandiswa. Hosted open-weight models, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1
temperature number Sampling temperature. Pa-hosted open-weight models default i-1 uye values dzinochengetwa pakati pe-0 ne-2. Hosted open-weight models, shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1
top_p number 0.95 Nucleus sampling. Values dzinochengetwa pakati pe-0 ne-1. Hosted open-weight models
seed integer Seed ye-sampler, integer ipi neipi. Pasina iyo, seed inotorwa kubva ku-model nehurukuro, saka request imwechete yakatumirwa kaviri inoshandisa seed imwechete. Hosted open-weight models
stop string | array String kana array ye-strings. Kusvika ku-4 dzinoshandiswa. Mhinduro inopera pamberi peyekutanga inoonekwa; stop text pachayo haidzoswi. Hosted open-weight models
reasoning_effort string high Kuti model inofunga zvakadii isati yapindura: off, low, medium kana high. none ne-minimal zvinoreva off, default inoreva medium, max inoreva high. Chero value imwe inodzosa 400. Hosted open-weight models
reasoning object Setting imwechete mu-object form: {"effort": "low"}. Kana dzese dzatumirwa, reasoning_effort ndiyo inoshandiswa. Hosted open-weight models
tools array Functions dzinogona kudanidzirwa ne-model, imwe neimwe se-{"type": "function", "function": {"name", "description", "parameters"}}. Calls dze-model dzinodzoka mu-tool_calls; code yako inodzimhanyisa. Ma-model ese
tool_choice string | object auto "auto" inosiya model ichisarudza. "required" inoiita kuti idanidzire tool. {"type": "function", "function": {"name": "…"}} inoiita kuti idanidzire tool iyoyo. Hosted open-weight models
response_format object {"type": "json_object"} kuti uwane mhinduro ye-JSON, kana {"type": "json_schema", "json_schema": {…}} kuti uwane mhinduro inotevera schema yako. Shannon tiers dzese; hosted open-weight models sezvakanyorwa pa-id imwe neimwe
web_search boolean false true inosiya model ichitsvaga pa-web isati yapindura. shannon-1.6-*, shannon-2-*, mhuri ye-Shannon 3

Mamwe OpenAI fields, sa-n, user, stream_options, parallel_tool_calls, presence_penalty, frequency_penalty, logit_bias, logprobs, metadata, store ne-prompt_cache_key, anogamuchirwa kuti client code iripo ishande isina kuchinjwa. Haachinji mhinduro: kunogara kuine choice imwe, uye stream inogara ichipera ine usage.

Field ine JSON type isiriyo, semuenzaniso "max_tokens": "100", inodzosa 422. Request isina messages inodaro zvakare.

Tools, structured output, reasoning ne-web search zvese zvine peji razvo: Kudanwa kwemabasa, Zvinobuda zvakarongeka, Reasoning effort, Kutsvaga pawebhu.

Request ine options

Request iyi inoisa system message, sampling fields ne-reasoning effort. Inoshandisa hosted open-weight model, inoshandisa zvese izvi.

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)

Mhinduro ine chimiro chimwechete sepamusoro. usage yayo inowedzera zvinhu zviviri pa-hosted open-weight models: prompt tokens dzakaverengwa kubva ku-cache ne-tokens dzakashandiswa pa-reasoning.

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

Kureba kwe-output

max_tokens inoita zvinhu zviviri. Chekutanga, ndicho huwandu hwe-tokens hunochengetwa mu-balance yako request payinotanga. Mhinduro kana yapera, huwandu uhwu hunotsiviwa ne-tokens dzakashandiswa ne-request. Kana max_tokens yakakura kupfuura zvasara mu-balance yako, request inodzosa 429 Quota exceeded kunyange mhinduro pachayo ingadai yakakwana. Tumira max_tokens diki kuti uchengetedze shoma.

shannon-coder-1 inoverengwa zvakasiyana pa-endpoint iyi: request imwe neimwe i-Shannon Coder call imwe ye-plan yako, uye hapana tokens dzinochengetwa. Limits ne-balance

Chechipiri, inogumira kureba kwemhinduro pa-ma-model aya:

Ma-model Zvinoitwa ne-max_tokens
shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 Mhinduro inomira kana yasvika pa-limit. Stream inobva yapera ne-finish_reason length.
Hosted open-weight models Text yemhinduro inomira pa-max_tokens. Reasoning haiverengwi pairi. Values dziri pazasi pe-256 dzinoshanda se-256.

Pasina max_tokens kana max_completion_tokens, value i-4,096. Pa-shannon-coder-1 i-65,536.

Messages

Message imwe neimwe i-object ine role ne-content. content i-string, kana array ye-parts kana message ichitakura zvimwe kunze kwe-text.

Role Tsananguro Inoshandiswa ne
system Mirayiro ye-model. Iise pakutanga. Pa-Shannon tiers system message yekutanga ndiyo inoshandiswa. Hosted open-weight models, shannon-1.6-*, shannon-2-*, shannon-coder-1
developer Inoverengwa se-system. Hosted open-weight models
user Zvaunobvunza. Pa-Shannon tiers user message yekupedzisira ndiyo prompt uye messages dzakaiva pamberi payo ndiyo history. Ma-model ese
assistant Mhinduro dzekare dze-model. Chengeta tool_calls dzayo kana uchitumira tool result mushure mayo. Ma-model ese
tool Mhedzisiro ye-tool call: tool_call_id ine id ye-call uye content ine mhedzisiro se-string. Ma-model ese

Ne-id yemhuri ye-Shannon 3, isa mirayiro inofanira kuchengetwa mu-user message.

Pa-Shannon tiers request isina user text uye isina tools inodzosa 400 No user message provided.

Content parts

Part Tsananguro Inowanikwa pa
{"type": "text", "text": "…"} Text chaiyo. Ma-model ese
{"type": "image_url", "image_url": {"url": "…"}} Mufananidzo, se-data: URL ine base64 content kana se-http(s) URL. Mhuri ye-Shannon 3, shannon-1.6-lite, shannon-1.6-pro, ne-hosted open-weight models dzinoratidza image input
{"type": "file", "source": {"type": "base64", "media_type": "application/pdf", "data": "…"}} Document (PDF, Word, PowerPoint kana Excel), se-base64 kana nge-URL. Mhuri ye-Shannon 3

Sizes, limits nerondedzero yakazara ye-forms zvine peji razvo. Mifananidzo ne-files

Reply object

Field Mhando Tsananguro
id string chatcmpl- inoteverwa ne-hexadecimal characters 32.
object string Inogara iri chat.completion.
created integer Nguva yemhinduro, mumasekonzi e-Unix.
model string Canonical id ye-model yakapindura. Inogona kusiyana manyorerwo ne-id yawakatumira.
choices array Inogara iri choice imwe chete, ine index 0.
choices[0].message.role string Inogara iri assistant.
choices[0].message.content string | null Text yemhinduro. Pamwe chete ne-tool_calls i-null pa-Shannon tiers; hosted open-weight models dzinogona kutumira text padivi pe-calls.
choices[0].message.reasoning_content string | null Reasoning yakanyorwa ne-model pamberi pemhinduro, kana null kana isipo.
choices[0].message.tool_calls array Iripo chete kana model ichidanidzira tools. Entry imwe neimwe ine id, type function, ne-function ine name ne-arguments se-JSON string.
choices[0].message.annotations array Chete pa-request ine web_search: true ine search yakawana chimwe chinhu. url_citation imwe pa-source imwe neimwe yatumidzwa ne-marker mu-content, ine url, title, start_index ne-end_index (iko pari marker, pakaverengwa mu-characters, kupera hakuverengwi).
choices[0].finish_reason string Chikonzero chekuti mhinduro yapera. Tarisa Finish reasons.
usage object Tokens dze-request. Tarisa Usage.
sources array Chete pa-request ine web_search: true ine search yakawana chimwe chinhu: mhedzisiro yakapiwa model, imwe neimwe ine index, title ne-url. [1] mumhinduro ndiyo entry ine index 1.

Finish reasons

finish_reason Tsananguro
stop Model yapedza mhinduro yayo, kana stop string yaonekwa.
tool_calls Model inodanidzira tool imwe kana dzakawanda. Dzimhanyise uye utumire mhedzisiro mu-tool messages.
length Mhinduro yadimburwa pa-output limit. Inoratidzwa mu-streams dze-shannon-1.6-lite, shannon-1.6-pro, shannon-coder-1 nemhuri ye-Shannon 3.

Mhinduro isiri streamed inoratidza stop kana tool_calls.

Usage

Field Mhando Tsananguro Inowanikwa pa
usage.prompt_tokens integer Input tokens. Ma-model ese
usage.completion_tokens integer Output tokens: reasoning, mhinduro ne-tool calls pamwe chete. Ma-model ese
usage.total_tokens integer prompt_tokens pamwe ne-completion_tokens. Ma-model ese
usage.prompt_tokens_details.cached_tokens integer Chikamu che-prompt_tokens chakaverengwa kubva ku-prompt cache. Hosted open-weight models
usage.completion_tokens_details.reasoning_tokens integer Chikamu che-completion_tokens chakashandiswa pa-reasoning. Hosted open-weight models

Pa-hosted open-weight models, prompt_tokens ndi-messages dzako ne-tool definitions dzakaverengwa ne-tokenizer ye-model pachayo, pamwe ne-tokens dzemifananidzo chero ipi. Token counting endpoints dzinodzosa nhamba imwechete usati watumira. Kuverenga tokens

Pa-Shannon tiers, prompt_tokens inoverenga zvese zvakaverengwa ne-model kunyora mhinduro, saka yakakura kupfuura text ye-messages dzako bedzi.

Streaming

Kana stream yaiswa ku-true mhinduro inouya se-chat.completion.chunk events uye inopera ne-data: [DONE]. Chunk yekupedzisira pamberi payo inotakura finish_reason ne-usage; hapana stream_options dzinodiwa. Zvimiro ze-chunk, keep-alive lines ne-errors mukati me-stream zvine peji razvo. Kuyerera

Errors

Error i-JSON object ine error member. Ma-check anomhanya nenzira iyi: API key, request body, model id, wozoita balance. Tafura inoratidza zvinodzoserwa nguva dzakawanda ne-endpoint iyi. Rondedzero yakazara, ine zvekuedza zvakare, ine peji rayo. Zvikanganiso

400 JSON
{
  "error": {
    "type": "invalid_request_error",
    "message": "unknown model: no-such-model"
  }
}
Status Mhando Message Rinhi
401 authentication_error Missing authentication
Invalid API key
API key haina kutumirwa, kana key haizivikanwi kana kuti yabviswa.
400 invalid_request_error unknown model: <id> model haisi published id.
400 invalid_request_error No user message provided Shannon tiers: request haina user text uye haina tools.
400 invalid_request_error <id> does not accept image input Image part yatumirwa kune hosted open-weight model isina image input.
400 invalid_request_error <id> does not accept response_format response_format yatumirwa kune hosted open-weight model isina structured output.
400 invalid_request_error unknown reasoning effort '<value>'; expected off, low, medium or high reasoning_effort ine value iri kunze kwe-list.
422 invalid_request_error Failed to deserialize the JSON body into the target type: … messages haisipo, kana field ine JSON type isiriyo.
429 rate_limit_error Quota exceeded. Upgrade your plan at shannon-ai.com/plan max_tokens yakakura kupfuura zvasara mu-balance yako.
429 rate_limit_error Too many requests. Retry in <n>s. Flood protection: ma-request anopfuura 120 paminiti imwe pa-account yako.
500 server_error The model backend failed to answer. Please retry. Model haina kugadzira mhinduro. Tumira request zvakare.
502 api_error The model backend failed to answer. Please retry. Zvakafanana, pa-mhuri ye-Shannon 3 ne-hosted open-weight models.