Leum gun t-susbaint
Responses API

Responses API

Ùr

Gabhaidh POST /v1/responses stiùireadh agus liosta de nithean cuir-a-steach agus tillidh e nì freagairt air a dhèanamh de nithean cuir-a-mach, ann an cruth OpenAI Responses. Cleachd e leis an responses API aig OpenAI SDK agus le innealan a tha air an togail air, leithid Codex CLI. Chan eil an endpoint a’ cumail staid: cuir an còmhradh gu lèir leis gach iarrtas.

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

Is e id modail agus teacsa an t-iarrtas as lugha. Chan eil am freagairt air a shruthadh mura h-iarr thu e.

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)

Is e nì freagairt a th’ anns an fhreagairt. Tha an reasoning ann an output, nuair a rinn am modail reasoning, agus an teachdaireachd:

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

Raointean iarrtais

Is e model agus input na tha a dhìth air iarrtas. Tha an colbh Applied by ag ainmeachadh nam modailean air a bheil raon ag atharrachadh an fhreagairt. Is e na modailean open-weight hosted an dusan id air liosta nam modailean; is e teaghlach Shannon 3 shannon-3, shannon-3-pro, shannon-3.1 agus shannon-3.1-pro. Modailean & prìsean

Raon Seòrsa Bun-roghainn Tuairisgeul Air a chur an gnìomh le
model string Riatanach. Id o liosta nam modailean. Chan eil aire air litrichean mòra no beaga. Tillidh id a tha a dhìth no neo-fhoillsichte 400 unknown model. A h-uile modail
input string | array Sreang, a thèid a leughadh mar aon teachdaireachd neach-cleachdaidh, no raon de nithean cuir-a-steach. Faic Input items gu h-ìosal. A h-uile modail
instructions string Stiùireadh dhan mhodail, system prompt a’ chruth seo. Modailean open-weight hosted, shannon-1.6-*, shannon-2-*, shannon-coder-1
stream boolean false Cuiridh true am freagairt mar server-sent events. Faic Streaming gu h-ìosal. A h-uile modail
max_output_tokens integer 4096 Crìoch àrd air an fhreagairt, ann an tokens. Thèid luach taobh a-muigh 1 gu 65,536 a ghluasad dhan rainse sin. Is e cuideachd an t-suim a thèid a chuir an dàrna taobh bho do balance fhad ’s a tha an t-iarrtas a’ ruith. Faic Output limit gu h-ìosal. Modailean open-weight hosted, shannon-1.6-*, shannon-2-*, shannon-coder-1
temperature number Temperature sampling. Air na modailean open-weight hosted thèid luachan a chumail eadar 0 agus 2. Modailean open-weight hosted; shannon-1.6-*, shannon-2-* agus shannon-coder-1 air freagairtean gun streaming
top_p number Nucleus sampling. Thèid luachan a chumail eadar 0 agus 1. Modailean open-weight hosted
tools array Na gnìomhan as urrainn dhan mhodail a ghairm, ann an cruth còmhnard a’ chruth seo: {"type": "function", "name", "description", "parameters"}. Faic Tools gu h-ìosal. A h-uile modail
tool_choice string | object auto Leigidh "auto" leis a’ mhodail co-dhùnadh. Toirt "required" air inneal a ghairm. Toirt {"type": "function", "name": "…"} air an inneal sin a ghairm. Modailean open-weight hosted
reasoning object {"effort": "…"} le off, low, medium no high. Tillidh luach sam bith eile 400. Modailean open-weight hosted
text object Iarraidh {"format": {…}} freagairt JSON. Faic Structured output gu h-ìosal. A h-uile ìre Shannon; modailean open-weight hosted mar a tha air an liostadh gach id

Thèid previous_response_id, store, metadata, parallel_tool_calls, truncation, include, user agus prompt_cache_key a ghabhail gus am bi còd client a th’ ann a’ ruith gun atharrachadh. Chan atharraich iad am freagairt. Leis nach eil còmhradh air a stòradh, bidh na turns na bu tràithe ann an input ann an iarrtas leantainneach.

Nithean cuir-a-steach

Is e teachdaireachd, le role agus content, no nì le seòrsa a tha a’ giùlan gairm inneal no a thoradh a th’ ann an nì cuir-a-steach. Is e sreang no raon de phàirtean a th’ ann an content.

Nì Tuairisgeul Air a chur an gnìomh le
{"role": "user", "content": …} Na dh’fhaighnich thu. Is e sreang a th’ ann an content, no pàirtean input_text agus input_image. A h-uile modail
{"role": "assistant", "content": …} Freagairt na bu tràithe dhen mhodail. Is e sreang a th’ ann an content, no pàirtean output_text. A h-uile modail
{"role": "system", "content": …}
{"role": "developer", "content": …}
Stiùireadh am broinn a’ chòmhraidh. Modailean open-weight hosted
{"type": "function_call", "call_id": "…", "name": "…", "arguments": "…"} Gairm inneal a rinn am modail ann am freagairt na bu tràithe. Is e sreang JSON a th’ ann an arguments. A h-uile modail
{"type": "function_call_output", "call_id": "…", "output": "…"} Toradh na gairm sin. Is e call_id id na gairm agus output an toradh mar sreang. A h-uile modail

Cuir stiùireadh san raon instructions. Le id de theaghlach Shannon 3, cuir stiùireadh a dh’fheumas a bhith ann san teachdaireachd user.

Faodaidh nithean output freagairt a dhol air ais dhan input mar a tha iad: thèid nithean message agus function_call a leughadh, thèid nithean reasoning a leum thairis.

Pàirtean susbaint

Pàirt Tuairisgeul Ri fhaighinn air
{"type": "input_text", "text": "…"} Teacsa teachdaireachd neach-cleachdaidh. A h-uile modail
{"type": "output_text", "text": "…"} Teacsa teachdaireachd neach-cuideachaidh. A h-uile modail
{"type": "input_image", "image_url": "…"} Dealbh, mar URL data: le susbaint base64 no mar URL http(s). Teaghlach Shannon 3, shannon-1.6-lite, shannon-1.6-pro, agus na modailean open-weight hosted a tha a’ liostadh cuir-a-steach dhealbhan
{"type": "input_file", "file_data": "data:application/pdf;base64,…"} Sgrìobhainn (PDF, Word, PowerPoint no Excel): tha URL data: ann an file_data, no URL http(s) ann an file_url. Teaghlach Shannon 3

Air ìrean Shannon thèid dealbhan agus faidhlichean a leughadh bhon nì user mu dheireadh ann an input. Tha duilleag fhèin aig meudan is crìochan. Dealbhan agus faidhlichean

Iarrtas le stiùireadh agus roghainnean

Cuiridh an t-iarrtas seo stiùireadh, còmhradh mar nithean cuir-a-steach, crìoch cuir-a-mach, temperature agus oidhirp reasoning. Cleachdaidh e modail open-weight hosted, a chuireas uile an gnìomh.

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)

Tha id, object, model, created_at, status, output agus usage ann am freagairt modail open-weight hosted. Cuiridh usage aige ris na tokens a chaidh a leughadh bho cache agus na tokens a chaidh air 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
  }
}

An nì freagairt

Tha id, object, status, output agus usage air gach freagairt. Tog do chòd orra sin.

Raon Seòrsa Tuairisgeul Air a chur le
id string resp_ agus an uair sin 32 caractar hexadecimal. A h-uile modail
object string An-còmhnaidh response. A h-uile modail
status string completed. Ann an stream tha e in_progress an toiseach, agus failed ann an tachartas response.failed. A h-uile modail
output array Na nithean cuir-a-mach san òrdugh anns an tug am modail a-mach iad: reasoning, message, function_call. A h-uile modail
usage object input_tokens, output_tokens agus total_tokens. A h-uile modail
usage.input_tokens_details object cached_tokens: na tokens cuir-a-steach a chaidh a leughadh bho cache a’ prompt. Modailean open-weight hosted
usage.output_tokens_details object reasoning_tokens: na tokens cuir-a-mach a chaidh air reasoning. Modailean open-weight hosted
model string Id canonach a’ mhodail a fhreagair. Teaghlach Shannon 3, modailean open-weight hosted
created_at integer Àm an fhreagairt, ann an diogan Unix. Teaghlach Shannon 3, modailean open-weight hosted
instructions, tools, temperature, … Bidh instructions, tools agus temperature ag ath-aithris an iarrtais. Tha error agus incomplete_details null, tha metadata {}, tha parallel_tool_calls true, tha tool_choice auto agus tha top_p null. Teaghlach Shannon 3

Nithean cuir-a-mach

Nì Tuairisgeul
{"id": "rs_…", "type": "reasoning", "summary": [{"type": "summary_text", "text": "…"}]} Reasoning a’ mhodail mar aon phàirt summary_text. Ann dìreach nuair a rinn am modail reasoning.
{"id": "msg_…", "type": "message", "role": "assistant", "content": [{"type": "output_text", "text": "…"}]} Am freagairt: aon phàirt output_text leis an teacsa.
{"id": "fc_…", "type": "function_call", "call_id": "call_…", "name": "…", "arguments": "…"} Gairm inneal. Is e sreang JSON a th’ ann an arguments. Cuir an toradh air ais leis an aon call_id.

Cuiridh na OpenAI SDKan teacsa na teachdaireachd còmhla dhut ann an response.output_text.

Streaming

Suidhich stream gu true airson server-sent events. Tha loidhne event: aig gach frèam le ainm an tachartais agus loidhne data: le nì JSON; bidh an nì ag ath-aithris an ainm ann an type. Maidsich deltas ris an nì aca le output_index.

Leis an OpenAI SDK, leugh na tachartasan a-rèir an 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")

Bidh na tachartasan a’ ruighinn san òrdugh seo. Chan eil buidhnean reasoning, na teachdaireachd is gairmean inneal ann ach nuair a tha iad san fhreagairt.

Tachartas Payload Cuin
response.created response An-còmhnaidh an toiseach. Tha response.status in_progress agus tha response.output falamh.
response.in_progress response An-còmhnaidh san dàrna àite, leis an aon nì.
response.output_item.added output_index, item Tòisichidh an reasoning: nì reasoning le summary falamh.
response.reasoning_summary_text.delta output_index, summary_index, delta Pios dhen reasoning.
response.reasoning_summary_text.done output_index, summary_index, text Tha an reasoning coileanta: an text gu lèir aige.
response.output_item.done output_index, item An nì reasoning crìochnaichte.
response.output_item.added output_index, item Tòisichidh am freagairt: nì message le staid in_progress agus gun susbaint.
response.content_part.added output_index, content_index, part Fosglaidh pàirt output_text falamh.
response.output_text.delta output_index, content_index, delta Pios dhen fhreagairt.
response.output_text.done output_index, content_index, text Tha am freagairt coileanta: an text gu lèir aige.
response.content_part.done output_index, content_index, part A’ phàirt output_text chrìochnaichte.
response.output_item.done output_index, item An nì message crìochnaichte, le staid completed.
response.output_item.added output_index, item Tòisichidh gairm inneal: nì function_call le call_id, name agus arguments falamh.
response.function_call_arguments.delta output_index, delta Argamaidean na gairm, coileanta ann an aon delta.
response.function_call_arguments.done output_index, arguments Na h-aon argamaidean, mar arguments.
response.output_item.done output_index, item An nì function_call crìochnaichte.
response.completed response An-còmhnaidh mu dheireadh nuair a shoirbhicheas e: an nì freagairt gu lèir le output agus 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}, …}}

Stream a dh’fhàilligeas

Air ìrean Shannon crìochnaichidh freagairt a dh’fhàillig le response.failed an àite response.completed. Is e failed an response.status aige agus tha code (rate_limit_exceeded no server_error) agus message ann an response.error.

Air na modailean open-weight hosted is e tachartas error le code api_error agus message a th’ ann am fàillinn. Thig response.completed às a dhèidh fhathast.

Gabh ri stream mar fhàillinn nuair a tha tachartas response.failed no error ann, agus cuir an t-iarrtas a-rithist.

Innealan

Is e inneal gnìomh a ruitheas do chòd. Mìnich e ann an tools; nuair a tha am modail ga iarraidh, tha nì function_call san fhreagairt an àite na teachdaireachd, no ri a taobh.

Mìneachadh inneil ann an tools:

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

An output aig freagairt a ghairmeas e:

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

Ruith an gnìomh, an uair sin cuir an t-iarrtas a-rithist leis a’ ghairm agus an toradh aice air an cur ri 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\"}"
  }
]

Thèid dìreach innealan de sheòrsa function a leughadh. Air shannon-1.6-*, shannon-2-* agus shannon-coder-1 thèid an sgeama parameters a lùghdachadh gu na h-iuchraichean cumanta JSON Schema: thèid oneOf a leughadh mar anyOf, agus chan eilear a’ cur iuchraichean leithid $ref, additionalProperties, const, default agus title chun a’ mhodail.

Cuiridh na modailean open-weight hosted luachan tool_choice required agus gnìomh air ainm an gnìomh.

Tha lùb nan innealan air a mhìneachadh gu h-iomlan air duilleag fhèin. Call gnìomh

Toradh structaraichte

Tha an cruth seo a’ sgrìobhadh toradh structaraichte mar text.format. Tha an sgeama dìreach ann an format, ri taobh name agus strict, chan ann fo bhall json_schema mar air Chat Completions.

  • Iarraidh {"type": "json_object"} nì JSON sam bith.
  • Iarraidh {"type": "json_schema", "name", "schema", "strict"} JSON a leanas an sgeama agad. Tha strict true nuair a dh’fhàgas tu às e.
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"
        ]
      }
    }
  }
}

Thig an JSON mar theacsa ann am pàirt output_text na teachdaireachd; parsaich thu fhèin e. Tillidh modail open-weight hosted gun toradh structaraichte 400.

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

Tha an cruth a ghabhas gach modail air a liostadh air duilleag fhèin. Toraidhean structarail

Reasoning

Tillidh modail a nì reasoning a reasoning mar nì cuir-a-mach de sheòrsa reasoning, ron teachdaireachd. Ann an stream thig e mar thachartasan response.reasoning_summary_text.delta.

Cuiridh na modailean open-weight hosted reasoning.effort an gnìomh: off, low, medium no high, le high nuair nach cuir thu dad. Chan eil off a’ tilleadh nì reasoning. Cuir e mar nì; chan eilear a’ leughadh sreang lom air an endpoint seo.

Tha na h-oidhirpean air am mìneachadh air duilleag fhèin. Oidhirp reusanachaidh

Crìoch cuir-a-mach

Tha max_output_tokens 4,096 nuair nach cuir thu e. Is e an àireamh de tokens a thèid a chuir an dàrna taobh bho do balance nuair a thòisicheas an t-iarrtas; nuair a tha am freagairt coileanta, thèid an t-suim sin a chur an àite na chleachd an t-iarrtas. Tillidh luach nach freagair ris a’ balance a tha air fhàgail agad 429 Quota exceeded.

Cuingichidh e fad an fhreagairt air shannon-1.6-*, shannon-2-* agus shannon-coder-1, agus fad teacsa an fhreagairt air na modailean open-weight hosted.

Air an endpoint seo thèid shannon-coder-1 a chosgadh ann an tokens bho do balance, mar gach modail eile.

Faodaidh bodhaig iarrtais a bhith suas gu 32 MiB. Crìochan agus balance

Mearachdan

Bidh mearachdan a’ cleachdadh bodhaig mearachd OpenAI: nì error le type agus message; tha code agus param le luach null aig cuid cuideachd. Tha an clàr a’ liostadh na tha an endpoint seo a’ tilleadh as trice. Tha duilleag fhèin aig an liosta iomlan, le dè a dh’fheumar ath-fheuchainn. Làimhseachadh mearachd

Staid Seòrsa Teachdaireachd Cuin
401 authentication_error Missing authentication
Invalid API key
Cha deach iuchair API a chur, no chan eil an iuchair aithnichte no tha i air a cur à bith.
400 invalid_request_error unknown model: <id> Tha model a dhìth no chan e id foillsichte a th’ ann.
400 invalid_request_error No user message provided. Ìrean Shannon: chan eil teacsa neach-cleachdaidh ann an input.
400 invalid_request_error <id> does not accept image input Chaidh dealbh a chur gu modail open-weight hosted gun chuir-a-steach dhealbhan.
400 invalid_request_error <id> does not accept response_format Chaidh text.format a chur gu modail open-weight hosted gun toradh structaraichte.
400 invalid_request_error unknown reasoning effort '<value>'; expected off, low, medium or high Tha luach taobh a-muigh na liosta ann an reasoning.effort.
422 invalid_request_error Failed to deserialize the JSON body into the target type: … Tha am bodhaig na JSON dligheach ach tha seòrsa ceàrr air raon.
429 rate_limit_error Quota exceeded. Upgrade your plan at shannon-ai.com/plan Tha max_output_tokens nas motha na tha air fhàgail dhe do balance.
429 rate_limit_error Too many requests. Retry in <n>s. Flood protection: còrr air 120 iarrtas ann an aon mhionaid air a’ chunntas agad.
500 api_error The model backend failed to answer. Please retry. Cha tug am modail a-mach freagairt. Cuir an t-iarrtas a-rithist.
502 api_error The model backend failed to answer. Please retry. An aon rud, air na modailean open-weight hosted.
504 api_error upstream timed out Thug modail open-weight hosted nas fhaide na crìoch ama freagairt gun streaming. Cuir e le stream suidhichte gu true.