Peke ki ngā ihirangi
Responses API

Responses API

Hou

Ka whakaae te POST /v1/responses ki ngā tohutohu me tētahi rārangi tūemi input, ā, ka whakahoki i tētahi ahanoa whakautu kua hangaia mai i ngā tūemi output, i te hōputu OpenAI Responses. Whakamahia me te API responses o te SDK OpenAI me ngā taputapu kua hangaia ki runga, pēnei i a Codex CLI. Kāore te endpoint e pupuri i te tūnga: tukuna te kōrero katoa i ia tono.

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

Ko te tono iti rawa he id model me tētahi kuputuhi. Kāore te whakautu e stream, mehemea kāore koe e tono.

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)

He ahanoa whakautu te whakautu. Kei tōna output te reasoning, ina whakaaro te model, me te karere:

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

Ngā āpure tono

Ko te model me te input ngā mea e hiahiatia ana e tētahi tono. Ka whakaingoa te tīwae Applied by i ngā model e huri ai tētahi āpure i te whakautu. Ko ngā model open-weight hosted ngā id tekau mā rua o te rārangi model; ko te whānau Shannon 3 ko shannon-3, shannon-3-pro, shannon-3.1 me shannon-3.1-pro. Ngā model me ngā utu

Āpure Momo Taunoa Whakaahuatanga Ka whakamahia e
model string E hiahiatia ana. He id mai i te rārangi model. Kāore te whakaritenga e aro ki te pū nui, pū iti rānei. Ka whakahoki tētahi id kua ngaro, kāore anō kia whakaputaina rānei i te 400 unknown model. Ngā model katoa
input string | array He aho, ka pānuitia hei karere kaiwhakamahi kotahi, he array rānei o ngā tūemi input. Tirohia Ngā tūemi input i raro iho. Ngā model katoa
instructions string Ngā tohutohu mā te model, te system prompt o tēnei hōputu. Ngā model open-weight hosted, shannon-1.6-*, shannon-2-*, shannon-coder-1
stream boolean false Ka tuku te true i te whakautu hei server-sent events. Tirohia Streaming i raro iho. Ngā model katoa
max_output_tokens integer 4096 Te tepe o runga o te whakautu, i ngā token. Ka nekehia tētahi uara i waho i te 1 ki te 65,536 ki roto i taua whānuitanga. Ko te nui hoki e wāhi atu ana i tō toenga i te wā e rere ana te tono. Tirohia Te tepe output i raro iho. Ngā model open-weight hosted, shannon-1.6-*, shannon-2-*, shannon-coder-1
temperature number Temperature sampling. I runga i ngā model open-weight hosted ka puritia ngā uara ki waenga i te 0 me te 2. Ngā model open-weight hosted; shannon-1.6-*, shannon-2-* me shannon-coder-1 i runga i ngā whakautu kāore e stream
top_p number Nucleus sampling. Ka puritia ngā uara ki waenga i te 0 me te 1. Ngā model open-weight hosted
tools array Ngā function ka taea e te model te karanga, i te āhua papatahi o tēnei hōputu: {"type": "function", "name", "description", "parameters"}. Tirohia Ngā tool i raro iho. Ngā model katoa
tool_choice string | object auto Ka tuku te "auto" i te model kia whakatau. Ka whakahau te "required" kia karanga ia i tētahi tool. Ka whakahau te {"type": "function", "name": "…"} kia karanga ia i taua tool. Ngā model open-weight hosted
reasoning object {"effort": "…"} me te off, low, medium high rānei. Ka whakahoki tētahi atu uara i te 400. Ngā model open-weight hosted
text object Ka tono te {"format": {…}} i tētahi whakautu JSON. Tirohia Output whakaritea i raro iho. Ngā taumata Shannon katoa; ngā model open-weight hosted pēnei i te rārangi mō ia id

E whakaaetia ana te previous_response_id, store, metadata, parallel_tool_calls, truncation, include, user me te prompt_cache_key kia rere tonu te waehere kiritaki o nāianei kāore i huri. Kāore rātou e huri i te whakautu. Nā te mea kāore he kōrero e tiakina ana, ka kawe te tono whai muri i ngā hurihanga o mua i te input.

Ngā tūemi input

He karere tētahi tūemi input, me tētahi role me tētahi content, he tūemi momo rānei e kawe ana i tētahi karanga tool, i tana hua rānei. He aho, he array wāhanga rānei te content.

Tūemi Whakaahuatanga Ka whakamahia e
{"role": "user", "content": …} Te mea ka pātaihia e koe. He aho te content, he wāhanga input_text me input_image rānei. Ngā model katoa
{"role": "assistant", "content": …} He whakautu o mua a te model. He aho te content, he wāhanga output_text rānei. Ngā model katoa
{"role": "system", "content": …}
{"role": "developer", "content": …}
Ngā tohutohu i roto i te kōrero. Ngā model open-weight hosted
{"type": "function_call", "call_id": "…", "name": "…", "arguments": "…"} He karanga tool i mahia e te model i tētahi whakautu o mua. He aho JSON te arguments. Ngā model katoa
{"type": "function_call_output", "call_id": "…", "output": "…"} Te hua o taua karanga. Ko te call_id te id o te karanga, ā, ko te output te hua hei aho. Ngā model katoa

Whakanōhia ngā tohutohu ki te āpure instructions. Ki tētahi id o te whānau Shannon 3, whakanōhia ngā tohutohu me puritia ki te karere user.

Ka taea te hoki o ngā tūemi o te output o tētahi whakautu ki te input pēnei i a rātou: ka pānuitia ngā tūemi message me function_call, ka whakarerea ngā tūemi reasoning.

Ngā wāhanga content

Wāhanga Whakaahuatanga E watea ana i runga i
{"type": "input_text", "text": "…"} Kuputuhi o tētahi karere kaiwhakamahi. Ngā model katoa
{"type": "output_text", "text": "…"} Kuputuhi o tētahi karere assistant. Ngā model katoa
{"type": "input_image", "image_url": "…"} He whakaahua, hei data URL data: me te content base64, hei URL http(s) rānei. Te whānau Shannon 3, shannon-1.6-lite, shannon-1.6-pro, me ngā model open-weight hosted e rārangi ana i te input whakaahua
{"type": "input_file", "file_data": "data:application/pdf;base64,…"} He tuhinga (PDF, Word, PowerPoint, Excel rānei): kei te file_data tētahi data URL data:, kei te file_url rānei tētahi URL http(s). Te whānau Shannon 3

I runga i ngā taumata Shannon ka pānuitia ngā whakaahua me ngā kōnae mai i te tūemi user whakamutunga o te input. Kei tōna ake whārangi ngā rahi me ngā tepe. Ngā whakaahua me ngā kōnae

He tono me ngā tohutohu me ngā kōwhiringa

Ka tuku tēnei tono i ngā tohutohu, i tētahi kōrero hei tūemi input, i tētahi tepe output, i tētahi temperature me tētahi reasoning effort. Ka whakamahi i tētahi model open-weight hosted, ka whakamahi i ēnei katoa.

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)

Kei te whakautu a tētahi model open-weight hosted te id, object, model, created_at, status, output me te usage. Ka tāpiri tōna usage i ngā token i pānuitia mai i te cache me ngā token i whakapaua ki te reasoning:

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

Te ahanoa whakautu

Kei ia whakautu te id, object, status, output me te usage. Hangaia tō waehere ki runga i ēnei.

Āpure Momo Whakaahuatanga Nā wai i tuku
id string resp_ ka whai ko ngā tohu hekihekimara e 32. Ngā model katoa
object string Ko response i ngā wā katoa. Ngā model katoa
status string completed. I roto i tētahi stream ko in_progress i te tuatahi, ā, ko failed i tētahi kaupapa response.failed. Ngā model katoa
output array Ngā tūemi output i te raupapa i whakaputaina e te model: reasoning, message, function_call. Ngā model katoa
usage object input_tokens, output_tokens me total_tokens. Ngā model katoa
usage.input_tokens_details object cached_tokens: ngā token input i pānuitia mai i te prompt cache. Ngā model open-weight hosted
usage.output_tokens_details object reasoning_tokens: ngā token output i whakapaua ki te reasoning. Ngā model open-weight hosted
model string Te id tūturu o te model i whakautu. Te whānau Shannon 3, ngā model open-weight hosted
created_at integer Te wā o te whakautu, i ngā hēkona Unix. Te whānau Shannon 3, ngā model open-weight hosted
instructions, tools, temperature, … Ka tuaruatia e te instructions, tools me te temperature te tono. Ko te error me te incomplete_details he null, ko te metadata he {}, ko te parallel_tool_calls he true, ko te tool_choice he auto, ā, ko te top_p he null. Te whānau Shannon 3

Ngā tūemi output

Tūemi Whakaahuatanga
{"id": "rs_…", "type": "reasoning", "summary": [{"type": "summary_text", "text": "…"}]} Te reasoning a te model hei wāhanga summary_text kotahi. Kei reira anake ina whakaaro te model.
{"id": "msg_…", "type": "message", "role": "assistant", "content": [{"type": "output_text", "text": "…"}]} Te whakautu: kotahi wāhanga output_text me te kuputuhi.
{"id": "fc_…", "type": "function_call", "call_id": "call_…", "name": "…", "arguments": "…"} He karanga tool. He aho JSON te arguments. Tukuna whakamuri te hua me te call_id ōrite.

Ka hono ngā SDK OpenAI i te kuputuhi o te karere mōu i te response.output_text.

Streaming

Tautuhia te stream ki te true mō ngā server-sent events. He rārangi event: tō ia frame me te ingoa o te kaupapa me tētahi rārangi data: me tētahi ahanoa JSON; ka tuaruatia e te ahanoa te ingoa i te type. Hono ngā delta ki tō rātou tūemi mā te output_index.

Ki te SDK OpenAI, pānuitia ngā kaupapa mā tō rātou 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")

Ka tae mai ngā kaupapa i tēnei raupapa. Ka puta ngā rōpū mō te reasoning, te karere me ngā karanga tool ina he ā rātou kei te whakautu anake.

Kaupapa Payload Āhea
response.created response Te mea tuatahi i ngā wā katoa. Ko te response.status he in_progress, ā, kau te response.output.
response.in_progress response Te tuarua i ngā wā katoa, me te ahanoa ōrite.
response.output_item.added output_index, item Ka tīmata te reasoning: he tūemi reasoning me te summary kau.
response.reasoning_summary_text.delta output_index, summary_index, delta He wāhanga o te reasoning.
response.reasoning_summary_text.done output_index, summary_index, text Kua oti te reasoning: tōna text katoa.
response.output_item.done output_index, item Te tūemi reasoning kua oti.
response.output_item.added output_index, item Ka tīmata te whakautu: he tūemi message me te tūnga in_progress me te kore content.
response.content_part.added output_index, content_index, part Ka huaki tētahi wāhanga output_text kau.
response.output_text.delta output_index, content_index, delta He wāhanga o te whakautu.
response.output_text.done output_index, content_index, text Kua oti te whakautu: tōna text katoa.
response.content_part.done output_index, content_index, part Te wāhanga output_text kua oti.
response.output_item.done output_index, item Te tūemi message kua oti, me te tūnga completed.
response.output_item.added output_index, item Ka tīmata tētahi karanga tool: he tūemi function_call me te call_id, name me te arguments kau.
response.function_call_arguments.delta output_index, delta Ngā argument o te karanga, kua oti katoa i te delta kotahi.
response.function_call_arguments.done output_index, arguments Ngā argument ōrite, hei arguments.
response.output_item.done output_index, item Te tūemi function_call kua oti.
response.completed response Te mea whakamutunga i ngā wā katoa ina angitu: te ahanoa whakautu katoa me te output me te 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}, …}}

He stream ka rahua

I runga i ngā taumata Shannon ka mutu tētahi whakautu rahua me te response.failed hei whakakapi mō te response.completed. Ko tōna response.status he failed, ā, kei te response.error tētahi code, rate_limit_exceeded server_error rānei, me tētahi message.

I runga i ngā model open-weight hosted he kaupapa error te rahua me te code api_error me tētahi message. Ka whai tonu te response.completed i a ia.

Whakaarohia he rahua tētahi stream ina he response.failed he kaupapa error rānei kei roto, ā, tukuna anō te tono.

Ngā tool

He function te tool ka whakahaerehia e tō waehere. Whakaahuatia i te tools; ina hiahia te model ki a ia, kei te whakautu tētahi tūemi function_call hei whakakapi, i te taha rānei o te karere.

He whakamārama tool i te tools:

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

Te output o tētahi whakautu e karanga ana i a ia:

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

Whakahaerehia te function, kātahi ka tuku anō i te tono me te karanga me tana hua kua tāpiritia ki te 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\"}"
  }
]

Ka pānuitia ngā tool o te momo function anake. I runga i te shannon-1.6-*, shannon-2-* me te shannon-coder-1 ka whakaitia te schema parameters ki ngā kupu matua JSON Schema noa: ka pānuitia te oneOf hei anyOf, ā, kāore ngā kupu matua pēnei i te $ref, additionalProperties, const, default me te title e tukuna ki te model.

Ka whakamahia ngā uara tool_choice required me tētahi function whakaingoa e ngā model open-weight hosted.

Kua whakaahuatia katoatia te tool loop i tōna ake whārangi. Karanga ā‑mahi

Output whakaritea

Ka tuhi tēnei hōputu i te output whakaritea hei text.format. Kei te format tonu te schema, i te taha o te name me te strict, kaua i raro i tētahi mema json_schema pēnei i Chat Completions.

  • Ka tono te {"type": "json_object"} i tētahi ahanoa JSON ahakoa tēhea.
  • Ka tono te {"type": "json_schema", "name", "schema", "strict"} i tētahi JSON e whai ana i tō schema. Ko te strict he true ina waiho e koe.
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"
        ]
      }
    }
  }
}

Ka tae mai te JSON hei kuputuhi i te wāhanga output_text o te karere; parauhia mōu ake. Ka whakahoki tētahi model open-weight hosted kāore he output whakaritea i te 400.

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

Kua rārangihia i tōna ake whārangi ko tēhea model e whakaae ana ki tēhea āhua. Putanga hanganga

Reasoning

Ka whakahoki tētahi model e whakaaro ana i tana reasoning hei tūemi output o te momo reasoning, i mua i te karere. I roto i tētahi stream ka tae mai hei kaupapa response.reasoning_summary_text.delta.

Ka whakamahi ngā model open-weight hosted i te reasoning.effort: off, low, medium high rānei, ko high ina kāore koe e tuku i tētahi. Kāore te off e whakahoki i tētahi tūemi reasoning. Tukuna hei ahanoa; kāore e pānuitia tētahi aho kau i runga i tēnei endpoint.

Kua whakaahuatia ngā effort i tō rātou ake whārangi. Reasoning effort

Te tepe output

Ko te max_output_tokens he 4,096 ina kāore koe e tuku. Ko te maha o ngā token e wāhi atu ana i tō toenga ina tīmata te tono; ina oti te whakautu, ka whakakapia taua nui e te mea i whakamahia e te tono. Ka whakahoki tētahi uara kāore e uru ki tō toenga e toe ana i te 429 Quota exceeded.

Ka whakawhāiti i te roa o te whakautu i runga i te shannon-1.6-*, shannon-2-* me te shannon-coder-1, me te roa o te kuputuhi whakautu i runga i ngā model open-weight hosted.

I runga i tēnei endpoint ka utua te shannon-coder-1 ki ngā token mai i tō toenga, pērā i ia model kē atu.

Ka taea te tae o tētahi tinana tono ki te 32 MiB. Ngā tepe me te toenga

Ngā hapa

Ka whakamahi ngā hapa i te tinana hapa OpenAI: he ahanoa error me te type me te message; ka kawe ētahi hoki i te code me te param me te uara null. Ka rārangi te ripanga i ngā mea e whakahokia pinepine ana e tēnei endpoint. Kei tōna ake whārangi te rārangi katoa, me te mea hei whakamātau anō. Whakahaere hapa

Tūnga Momo Karere Āhea
401 authentication_error Missing authentication
Invalid API key
Kāore he API key i tukuna, kāore rānei e mōhiotia te key, kua whakakorea rānei.
400 invalid_request_error unknown model: <id> Kei te ngaro te model, ehara rānei i tētahi id kua whakaputaina.
400 invalid_request_error No user message provided. Ngā taumata Shannon: kāore he kuputuhi kaiwhakamahi i te input.
400 invalid_request_error <id> does not accept image input I tukuna tētahi whakaahua ki tētahi model open-weight hosted kāore he input whakaahua.
400 invalid_request_error <id> does not accept response_format I tukuna te text.format ki tētahi model open-weight hosted kāore he output whakaritea.
400 invalid_request_error unknown reasoning effort '<value>'; expected off, low, medium or high Kei te reasoning.effort tētahi uara i waho i te rārangi.
422 invalid_request_error Failed to deserialize the JSON body into the target type: … He JSON tika te tinana engari he hē te momo o tētahi āpure.
429 rate_limit_error Quota exceeded. Upgrade your plan at shannon-ai.com/plan Nui ake te max_output_tokens i te mea e toe ana i tō toenga.
429 rate_limit_error Too many requests. Retry in <n>s. Flood protection: neke atu i te 120 tono i roto i te meneti kotahi i tō pūkete.
500 api_error The model backend failed to answer. Please retry. Kāore te model i whakaputa i tētahi whakautu. Tukuna anō te tono.
502 api_error The model backend failed to answer. Please retry. Te mea ōrite, i runga i ngā model open-weight hosted.
504 api_error upstream timed out I roa ake te wā o tētahi model open-weight hosted i te tepe wā o tētahi whakautu kāore e stream. Tukuna me te stream kua tautuhia ki te true.