Eqa uye okuqukethwe
I-Responses API

I-Responses API

OKUSHA

I-POST /v1/responses yamukela iziqondiso nohlu lwezinto zokufakwayo bese ibuyisa i-response object eyakhiwe ngezinto zokuphumayo, ngesimo se-OpenAI Responses. Yisebenzise nge-responses API ye-SDK ye-OpenAI nangamathuluzi akhelwe kuyo, njenge-Codex CLI. I-endpoint ayigcini isimo: thumela yonke ingxoxo nesicelo ngasinye.

POST https://api.shannon-ai.com/v1/responses

Isicelo esincane kunazo zonke siyi-id ye-model nombhalo. Impendulo ayiyi-stream ngaphandle kokuba uyicele.

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.shannon-ai.com/v1",
)

response = client.responses.create(
    model="shannon-3",
    input="Say hello in one sentence.",
)

print(response.output_text)

Impendulo iyi-response object. I-output yayo iphethe ukucabanga, uma i-model icabangile, nomlayezo:

200 JSON
{
  "id": "resp_5f0c1e7a9b3d4c62a8e1f07d2b46c9a3",
  "object": "response",
  "created_at": 1791625200,
  "model": "shannon-3",
  "status": "completed",
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "metadata": {},
  "parallel_tool_calls": true,
  "temperature": null,
  "tool_choice": "auto",
  "tools": [],
  "top_p": null,
  "output": [
    {
      "id": "rs_8a2e6c1f4b7d4e03b9c5a1d70f3e2b64",
      "type": "reasoning",
      "summary": [
        {
          "type": "summary_text",
          "text": "The user wants a greeting in one sentence. Keep it short and friendly."
        }
      ]
    },
    {
      "id": "msg_1c7b9e3a5d2f4a86b0e4c8d19a6f7e25",
      "type": "message",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "Hello, it is good to meet you.",
          "annotations": []
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 1184,
    "output_tokens": 46,
    "total_tokens": 1230
  }
}

Ama-field esicelo

I-model ne-input yilokho isicelo esikudingayo. Ikholomu ethi Applied by ibhala ama-model lapho i-field ishintsha khona impendulo. Ama-model e-open-weight ahlinzekiwe ayishumi nambili, wonke ama-id aphelele ohlwini lwama-model; umndeni we-Shannon 3 yi-shannon-3, shannon-3-pro, shannon-3.1 ne-shannon-3.1-pro. Ama-model namanani

I-field Uhlobo Okuzenzakalelayo Incazelo Isetshenziswa yi-
model string Iyadingeka. I-id evela ohlwini lwama-model. Ukufanisa akunandaba nonkulu noma amancane. I-id engekho noma engashicilelwe ibuyisa 400 unknown model. Wonke ama-model
input string | array I-string, efundwa njengomlayezo owodwa womsebenzisi, noma i-array yezinto zokufakwayo. Bheka Input items ngezansi. Wonke ama-model
instructions string Iziqondiso ze-model, i-system prompt yalesi simo. Ama-model e-open-weight ahlinzekiwe, shannon-1.6-*, shannon-2-*, shannon-coder-1
stream boolean false I-true ithumela impendulo njenge-server-sent events. Bheka Streaming ngezansi. Wonke ama-model
max_output_tokens integer 4096 Umkhawulo ophezulu wempendulo, ngama-token. Inani eliphandle kuka-1 kuya ku-65,536 lisondezwa kuleso hla. Futhi yinani elibekwa eceleni ku-balance yakho ngenkathi isicelo siqhubeka. Bheka Output limit ngezansi. Ama-model e-open-weight ahlinzekiwe, shannon-1.6-*, shannon-2-*, shannon-coder-1
temperature number I-temperature ye-sampling. Kuma-model e-open-weight ahlinzekiwe amanani agcinwa phakathi kuka-0 no-2. Ama-model e-open-weight ahlinzekiwe; shannon-1.6-*, shannon-2-* ne-shannon-coder-1 ezimpendulweni ezingeyona i-stream
top_p number I-nucleus sampling. Amanani agcinwa phakathi kuka-0 no-1. Ama-model e-open-weight ahlinzekiwe
tools array Imisebenzi i-model engayibiza, ngesimo esiyisicaba salesi simo: {"type": "function", "name", "description", "parameters"}. Bheka Tools ngezansi. Wonke ama-model
tool_choice string | object auto "auto" ivumela i-model inqume. "required" iyiphoqa ukuthi ibize ithuluzi. {"type": "function", "name": "…"} iyiphoqa ukuthi ibize lelo thuluzi. Ama-model e-open-weight ahlinzekiwe
reasoning object {"effort": "…"} ene-off, low, medium noma high. Noma yiliphi elinye inani libuyisa 400. Ama-model e-open-weight ahlinzekiwe
text object {"format": {…}} icela impendulo ye-JSON. Bheka Structured output ngezansi. Zonke izigaba ze-Shannon; ama-model e-open-weight ahlinzekiwe njengoba kubhalwe nge-id ngayinye

I-previous_response_id, store, metadata, parallel_tool_calls, truncation, include, user ne-prompt_cache_key ziyamukelwa ukuze ikhodi ye-client ekhona isebenze ngaphandle kokushintshwa. Azishintshi impendulo. Ngoba ayikho ingxoxo egciniwe, isicelo esilandelayo siphatha izikhathi zangaphambilini ku-input.

Izinto zokufakwayo

Into yokufakwayo ngumlayezo, ene-role ne-content, noma into ehlobile ephethe isicelo sethuluzi noma umphumela waso. I-content iyi-string noma i-array yezingxenye.

Into Incazelo Isetshenziswa yi-
{"role": "user", "content": …} Lokho obuzayo. I-content iyi-string, noma izingxenye ze-input_text ne-input_image. Wonke ama-model
{"role": "assistant", "content": …} Impendulo yangaphambilini ye-model. I-content iyi-string, noma izingxenye ze-output_text. Wonke ama-model
{"role": "system", "content": …}
{"role": "developer", "content": …}
Iziqondiso ngaphakathi engxoxweni. Ama-model e-open-weight ahlinzekiwe
{"type": "function_call", "call_id": "…", "name": "…", "arguments": "…"} Isicelo sethuluzi i-model esenze empendulweni yangaphambilini. I-arguments iyi-string ye-JSON. Wonke ama-model
{"type": "function_call_output", "call_id": "…", "output": "…"} Umphumela walokho kubiza. I-call_id yi-id yocingo kanti i-output ngumphumela njenge-string. Wonke ama-model

Faka iziqondiso ku-field ye-instructions. Nge-id yomndeni we-Shannon 3, faka iziqondiso okufanele ziphumelele emlayezweni we-user.

Izinto ze-output yempendulo zingabuyela ku-input njengoba zinjalo: izinto ze-message ne-function_call ziyafundwa, izinto ze-reasoning ziyeqiwa.

Izingxenye zokuqukethwe

Ingxenye Incazelo Itholakala ku-
{"type": "input_text", "text": "…"} Umbhalo womlayezo womsebenzisi. Wonke ama-model
{"type": "output_text", "text": "…"} Umbhalo womlayezo we-assistant. Wonke ama-model
{"type": "input_image", "image_url": "…"} Isithombe, njenge-data: URL enokuqukethwe kwe-base64 noma njenge-URL ye-http(s). Umndeni we-Shannon 3, shannon-1.6-lite, shannon-1.6-pro, nama-model e-open-weight ahlinzekiwe abhala okufakwayo kwesithombe
{"type": "input_file", "file_data": "data:application/pdf;base64,…"} Idokhumenti (PDF, Word, PowerPoint noma Excel): i-file_data iphethe i-data: URL, noma i-file_url iphethe i-URL ye-http(s). Umndeni we-Shannon 3

Ezigabeni ze-Shannon izithombe namafayela afundwa ento yokugcina ye-user ye-input. Osayizi nemikhawulo kunekhasi lazo. Izithombe namafayela

Isicelo esineziqondiso nezinketho

Lesi sicelo sithumela iziqondiso, ingxoxo njengezinto zokufakwayo, umkhawulo wokuphumayo, i-temperature ne-effort yokucabanga. Sisebenzisa i-model e-open-weight ehlinzekiwe, ezisebenzisa zonke.

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.shannon-ai.com/v1",
)

response = client.responses.create(
    model="DeepSeek-V4-Flash-0731-W4A16-AUTOROUND-REAP",
    instructions="You are a physics teacher. Answer in two sentences.",
    input=[
        {"role": "user", "content": "Why is the sky blue?"},
        {"role": "assistant", "content": "Air scatters blue light more than red light."},
        {"role": "user", "content": "And why are sunsets red?"},
    ],
    max_output_tokens=512,
    temperature=0.3,
    reasoning={"effort": "low"},
)

for item in response.output:
    if item.type == "reasoning":
        print("reasoning:", item.summary[0].text)
    elif item.type == "message":
        print("answer:", item.content[0].text)
print(response.usage)

Impendulo ye-model e-open-weight ehlinzekiwe inayo i-id, object, model, created_at, status, output ne-usage. I-usage yayo yengeza ama-token afundwe ku-cache nama-token asetshenziselwe ukucabanga:

200 JSON
{
  "usage": {
    "input_tokens": 58,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 67,
    "output_tokens_details": {
      "reasoning_tokens": 19
    },
    "total_tokens": 125
  }
}

I-response object

I-id, object, status, output ne-usage ikho kuyo yonke impendulo. Yakha ikhodi yakho kulokho.

I-field Uhlobo Incazelo Ithunyelwa yi-
id string resp_ elandelwa yizinhlamvu ze-hexadecimal ezingu-32. Wonke ama-model
object string Njalo response. Wonke ama-model
status string completed. Ku-stream kuqala kube yi-in_progress, bese kuba yi-failed emcimbini we-response.failed. Wonke ama-model
output array Izinto zokuphumayo ngokulandelana i-model ezikhiqize ngakho: reasoning, message, function_call. Wonke ama-model
usage object I-input_tokens, output_tokens ne-total_tokens. Wonke ama-model
usage.input_tokens_details object I-cached_tokens: ama-token okufakwayo afundwe ku-prompt cache. Ama-model e-open-weight ahlinzekiwe
usage.output_tokens_details object I-reasoning_tokens: ama-token okuphumayo asetshenziselwe ukucabanga. Ama-model e-open-weight ahlinzekiwe
model string I-id esemthethweni ye-model ephendulile. Umndeni we-Shannon 3, ama-model e-open-weight ahlinzekiwe
created_at integer Isikhathi sempendulo, ngamasekhondi e-Unix. Umndeni we-Shannon 3, ama-model e-open-weight ahlinzekiwe
instructions, tools, temperature, … I-instructions, tools ne-temperature kuphindaphinda isicelo. I-error ne-incomplete_details ziyi-null, i-metadata iyi-{}, i-parallel_tool_calls iyi-true, i-tool_choice iyi-auto futhi i-top_p iyi-null. Umndeni we-Shannon 3

Izinto zokuphumayo

Into Incazelo
{"id": "rs_…", "type": "reasoning", "summary": [{"type": "summary_text", "text": "…"}]} Ukucabanga kwe-model njengengxenye eyodwa ye-summary_text. Ikhona kuphela uma i-model icabangile.
{"id": "msg_…", "type": "message", "role": "assistant", "content": [{"type": "output_text", "text": "…"}]} Impendulo: ingxenye eyodwa ye-output_text enombhalo.
{"id": "fc_…", "type": "function_call", "call_id": "call_…", "name": "…", "arguments": "…"} Isicelo sethuluzi. I-arguments iyi-string ye-JSON. Buyisa umphumela nge-call_id efanayo.

Ama-SDK e-OpenAI akuhlanganisela umbhalo womlayezo ku-response.output_text.

I-streaming

Setha i-stream ibe true ukuthola i-server-sent events. I-frame ngayinye inomugqa we-event: onegama lomcimbi nomugqa we-data: one-JSON object; i-object iphindaphinda igama ku-type. Fanisa ama-delta nento yawo nge-output_index.

Nge-SDK ye-OpenAI, funda imicimbi ngohlobo lwayo (type):

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.shannon-ai.com/v1",
)

stream = client.responses.create(
    model="shannon-3",
    input="Explain server-sent events in three sentences.",
    stream=True,
)

for event in stream:
    kind = getattr(event, "type", "error")     # an event without a type is an error event
    if kind == "response.reasoning_summary_text.delta":
        pass                                   # a piece of reasoning: event.delta
    elif kind == "response.output_text.delta":
        print(event.delta, end="", flush=True)
    elif kind == "response.output_item.done" and event.item.type == "function_call":
        print("\ntool call:", event.item.name, event.item.arguments)
    elif kind == "response.completed":
        print("\n", event.response.usage)
    elif kind in ("response.failed", "error"):
        raise RuntimeError("the stream failed, send the request again")

Imicimbi ifika ngalokhu kulandelana. Amaqembu okucabanga, umlayezo nezicelo zamathuluzi avela kuphela uma impendulo inawo.

Umcimbi I-payload Nini
response.created response Njalo yokuqala. I-response.status iyi-in_progress futhi i-response.output ayinalutho.
response.in_progress response Njalo yesibili, ne-object efanayo.
response.output_item.added output_index, item Ukucabanga kuyaqala: into ye-reasoning ene-summary engenalutho.
response.reasoning_summary_text.delta output_index, summary_index, delta Ucezu lokucabanga.
response.reasoning_summary_text.done output_index, summary_index, text Ukucabanga kuphelele: yonke i-text yako.
response.output_item.done output_index, item Into ye-reasoning eqediwe.
response.output_item.added output_index, item Impendulo iyaqala: into ye-message enesimo in_progress futhi ngaphandle kokuqukethwe.
response.content_part.added output_index, content_index, part Ingxenye engenalutho ye-output_text iyavuleka.
response.output_text.delta output_index, content_index, delta Ucezu lwempendulo.
response.output_text.done output_index, content_index, text Impendulo iphelele: yonke i-text yayo.
response.content_part.done output_index, content_index, part Ingxenye ye-output_text eqediwe.
response.output_item.done output_index, item Into ye-message eqediwe, enesimo completed.
response.output_item.added output_index, item Isicelo sethuluzi siyaqala: into ye-function_call ene-call_id, name ne-arguments engenalutho.
response.function_call_arguments.delta output_index, delta Ama-argument esicelo sethuluzi, aphelele ku-delta eyodwa.
response.function_call_arguments.done output_index, arguments Ama-argument afanayo, njenge-arguments.
response.output_item.done output_index, item Into ye-function_call eqediwe.
response.completed response Njalo yokugcina lapho kuphumelele: yonke i-response object ene-output ne-usage.
200 text/event-stream
event: response.created
data: {"type":"response.created","response":{"id":"resp_5f0c…","object":"response","status":"in_progress","output":[], …}}

event: response.in_progress
data: {"type":"response.in_progress","response":{"id":"resp_5f0c…","object":"response","status":"in_progress","output":[], …}}

event: response.output_item.added
data: {"type":"response.output_item.added","output_index":0,"item":{"id":"msg_1c7b…","type":"message","role":"assistant","status":"in_progress","content":[]}}

event: response.content_part.added
data: {"type":"response.content_part.added","output_index":0,"content_index":0,"part":{"type":"output_text","text":""}}

event: response.output_text.delta
data: {"type":"response.output_text.delta","output_index":0,"content_index":0,"delta":"Server-sent"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","output_index":0,"content_index":0,"delta":" events let a server push text over one HTTP reply."}

event: response.output_text.done
data: {"type":"response.output_text.done","output_index":0,"content_index":0,"text":"Server-sent events let a server push text over one HTTP reply."}

event: response.content_part.done
data: {"type":"response.content_part.done","output_index":0,"content_index":0,"part":{"type":"output_text","text":"Server-sent events let a server push text over one HTTP reply."}}

event: response.output_item.done
data: {"type":"response.output_item.done","output_index":0,"item":{"id":"msg_1c7b…","type":"message","role":"assistant","status":"completed","content":[{"type":"output_text","text":"Server-sent events let a server push text over one HTTP reply.","annotations":[]}]}}

event: response.completed
data: {"type":"response.completed","response":{"id":"resp_5f0c…","object":"response","status":"completed","output":[…],"usage":{"input_tokens":1190,"output_tokens":18,"total_tokens":1208}, …}}

I-stream ehlulekayo

Ezigabeni ze-Shannon impendulo ehlulekile iphela nge-response.failed esikhundleni se-response.completed. I-response.status yayo iyi-failed futhi i-response.error iphethe i-code, rate_limit_exceeded noma server_error, ne-message.

Kuma-model e-open-weight ahlinzekiwe ukwehluleka kuwumcimbi we-error ene-code api_error ne-message. I-response.completed isalandela.

Thatha i-stream njengehlulekile uma iphethe umcimbi we-response.failed noma we-error, bese uphinda uthumele isicelo.

Amathuluzi

Ithuluzi ngumsebenzi oqhutshwa yikhodi yakho. Yichaze ku-tools; lapho i-model iyifuna, impendulo iphatha into ye-function_call esikhundleni somlayezo, noma eceleni kwawo.

Incazelo yethuluzi ku-tools:

tools
[
  {
    "type": "function",
    "name": "get_weather",
    "description": "Current weather for a city.",
    "parameters": {
      "type": "object",
      "properties": {
        "city": {
          "type": "string"
        }
      },
      "required": [
        "city"
      ]
    }
  }
]

I-output yempendulo ebiza lowo msebenzi:

200 output
[
  {
    "id": "call_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
    "type": "function_call",
    "name": "get_weather",
    "call_id": "call_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
    "arguments": "{\"city\":\"Paris\"}"
  }
]

Qhuba umsebenzi, bese uphinda uthumele isicelo ngokungeza ukubiza nomphumela wako ku-input:

input
[
  {
    "role": "user",
    "content": "What is the weather in Paris?"
  },
  {
    "type": "function_call",
    "call_id": "call_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
    "name": "get_weather",
    "arguments": "{\"city\":\"Paris\"}"
  },
  {
    "type": "function_call_output",
    "call_id": "call_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
    "output": "{\"temperature_c\": 18, \"sky\": \"cloudy\"}"
  }
]

Amathuluzi ohlobo function kuphela afundwa. Ku-shannon-1.6-*, shannon-2-* ne-shannon-coder-1 i-schema ye-parameters inciphiswa ibe amagama abalulekile e-JSON Schema avamile: i-oneOf ifundwa njenge-anyOf, futhi amagama anjenge-$ref, additionalProperties, const, default ne-title awadluliselwa ku-model.

Amanani e-tool_choice ethi required nomsebenzi onegama asetshenziswa ama-model e-open-weight ahlinzekiwe.

Umjikelezo wamathuluzi uchazwe ngokugcwele ekhasini lawo. Ukubiza umsebenzi

Okuphumayo okuhlelekile

Lesi simo sibhala okuphumayo okuhlelekile njenge-text.format. I-schema ihlala ngqo ku-format, eduze kwe-name ne-strict, hhayi ngaphansi kwelungu le-json_schema njengase-Chat Completions.

  • {"type": "json_object"} icela noma iyiphi i-JSON object.
  • {"type": "json_schema", "name", "schema", "strict"} icela i-JSON elandela i-schema yakho. I-strict iyi-true uma uyishiya ngaphandle.
POST /v1/responses
{
  "model": "shannon-1.6-lite",
  "input": "Extract the city and the date: 'The conference opens in Lisbon on 12 May 2027.'",
  "text": {
    "format": {
      "type": "json_schema",
      "name": "event",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "city": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "description": "ISO 8601 date"
          }
        },
        "required": [
          "city",
          "date"
        ]
      }
    }
  }
}

I-JSON ifika njengombhalo engxenyeni ye-output_text yomlayezo; yihlaziye wena. I-model e-open-weight ehlinzekiwe engenakho ukuphumayo okuhlelekile ibuyisa 400.

output_text
{"city": "Lisbon", "date": "2027-05-12"}

Ukuthi iyiphi i-model yamukela yiphi indlela kubhalwe ekhasini layo. Imiphumela ehlanganisiwe

Ukucabanga

I-model ecabangayo ibuyisa ukucabanga kwayo njengento yokuphumayo yohlobo reasoning, ngaphambi komlayezo. Ku-stream kufika njengemicimbi ye-response.reasoning_summary_text.delta.

Ama-model e-open-weight ahlinzekiwe asebenzisa i-reasoning.effort: off, low, medium noma high, kube high uma ungathumeli lutho. I-off ayibuyisi into yokucabanga. Yithumele njenge-object; i-string yodwa ayifundwa kule-endpoint.

Ama-effort achazwe ekhasini lawo. Umzamo wokucabanga

Umkhawulo wokuphumayo

I-max_output_tokens ingu-4,096 uma ungayithumeli. Yinani lama-token abekwa eceleni ku-balance yakho lapho isicelo siqala; lapho impendulo iphelele, leli nani lishintshwa yilokho isicelo esikusebenzisile. Inani elingafaneleki ku-balance yakho esele libuyisa 429 Quota exceeded.

Inqamula ubude bempendulo ku-shannon-1.6-*, shannon-2-* ne-shannon-coder-1, nobude bombhalo wempendulo kuma-model e-open-weight ahlinzekiwe.

Kule-endpoint i-shannon-coder-1 ikhokhiswa ngama-token e-balance yakho, njengawo wonke amanye ama-model.

Umzimba wesicelo ungafika ku-32 MiB. Imikhawulo ne-balance

Amaphutha

Amaphutha asebenzisa umzimba wephutha we-OpenAI: into ye-error ene-type ne-message; amanye aphinde aphathe i-code ne-param enani elithi null. Ithebula libhala lokho le-endpoint eyibuyisa kakhulu. Uhlu olugcwele, nokuthi yini okufanele iphindwe, lunekhasi lalo. Ukuphathwa kwamaphutha

Isimo Uhlobo Umlayezo Nini
401 authentication_error Missing authentication
Invalid API key
Akukho API key ethunyelwe, noma i-key ayaziwa noma ihoxisiwe.
400 invalid_request_error unknown model: <id> I-model ayikho noma akuyona i-id eshicilelwe.
400 invalid_request_error No user message provided. Izigaba ze-Shannon: i-input ayiphethe mbhalo womsebenzisi.
400 invalid_request_error <id> does not accept image input Isithombe sithunyelwe ku-model e-open-weight ehlinzekiwe engenakho ukufakwayo kwesithombe.
400 invalid_request_error <id> does not accept response_format I-text.format ithunyelwe ku-model e-open-weight ehlinzekiwe engenakho ukuphumayo okuhlelekile.
400 invalid_request_error unknown reasoning effort '<value>'; expected off, low, medium or high I-reasoning.effort iphethe inani eliphandle kohlu.
422 invalid_request_error Failed to deserialize the JSON body into the target type: … Umzimba uyi-JSON esebenzayo kodwa i-field inohlobo olungalungile.
429 rate_limit_error Quota exceeded. Upgrade your plan at shannon-ai.com/plan I-max_output_tokens inkulu kunokusele ku-balance yakho.
429 rate_limit_error Too many requests. Retry in <n>s. I-flood protection: izicelo ezingaphezu kwezingu-120 ngomzuzu owodwa ku-akhawunti yakho.
500 api_error The model backend failed to answer. Please retry. I-model ayikhiqizanga mpendulo. Phinda uthumele isicelo.
502 api_error The model backend failed to answer. Please retry. Okufanayo, kuma-model e-open-weight ahlinzekiwe.
504 api_error upstream timed out I-model e-open-weight ehlinzekiwe ithathe isikhathi eside kunomkhawulo wesikhathi wempendulo engeyona i-stream. Yithumele ne-stream isethwe ibe true.