Léim go dtí an t-ábhar
Responses API

Responses API

Nua

Glacann POST /v1/responses le treoracha agus liosta míreanna ionchuir agus filleann sé réad freagra a dhéantar de mhíreanna aschuir, i bhformáid OpenAI Responses. Úsáid é leis an responses API de SDK OpenAI agus le huirlisí atá tógtha air, mar Codex CLI. Ní choinníonn an críochphointe aon staid: seol an comhrá iomlán le gach iarratas.

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

Is é an t-iarratas is lú id múnla agus téacs. Ní shruthaítear an freagra mura n-iarrann tú é.

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 réad freagra é an freagra. Coinníonn a output an réasúnaíocht, nuair a rinne an múnla réasúnaíocht, agus an teachtaireacht:

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

Réimsí iarratais

Is iad model agus input an méid a theastaíonn ó iarratas. Ainmníonn an colún Curtha i bhfeidhm ag na múnlaí a n-athraíonn réimse an freagra orthu. Is iad na múnlaí open-weight óstáilte an dá id dhéag sa liosta múnlaí; is iad teaghlach Shannon 3 shannon-3, shannon-3-pro, shannon-3.1 agus shannon-3.1-pro. Múnlaí agus praghsáil

Réimse Cineál Réamhshocrú Tuairisc Curtha i bhfeidhm ag
model string Riachtanach. Id ón liosta múnlaí. Ní thugtar aird ar chás na litreacha sa mheaitseáil. Filleann id atá ar iarraidh nó neamhfhoilsithe 400 unknown model. Gach múnla
input string | array Sreang, a léitear mar theachtaireacht úsáideora amháin, nó eagar de mhíreanna ionchuir. Féach Míreanna ionchuir thíos. Gach múnla
instructions string Treoracha don mhúnla, prompt córais na formáide seo. Múnlaí open-weight óstáilte, shannon-1.6-*, shannon-2-*, shannon-coder-1
stream boolean false Seolann true an freagra mar imeachtaí a sheolann an freastalaí (server-sent events). Féach Sruthú thíos. Gach múnla
max_output_tokens integer 4096 Uasteorainn an fhreagra, i dtokens. Aistrítear luach lasmuigh de 1 go 65,536 isteach sa raon sin. Is é freisin an méid a chuirtear i leataobh as d'iarmhéid fad a ritheann an t-iarratas. Féach Teorainn aschuir thíos. Múnlaí open-weight óstáilte, shannon-1.6-*, shannon-2-*, shannon-coder-1
temperature number Teocht shamplála. Ar na múnlaí open-weight óstáilte coinnítear na luachanna idir 0 agus 2. Múnlaí open-weight óstáilte; shannon-1.6-*, shannon-2-* agus shannon-coder-1 ar fhreagraí gan sruthú
top_p number Samplú núicléis. Coinnítear na luachanna idir 0 agus 1. Múnlaí open-weight óstáilte
tools array Na feidhmeanna a fhéadfaidh an múnla a ghlaoch, i bhfoirm chothrom na formáide seo: {"type": "function", "name", "description", "parameters"}. Féach Uirlisí thíos. Gach múnla
tool_choice string | object auto Lig "auto" don mhúnla cinneadh. Cuireann "required" iachall air uirlis a ghlaoch. Cuireann {"type": "function", "name": "…"} iachall air an uirlis sin a ghlaoch. Múnlaí open-weight óstáilte
reasoning object {"effort": "…"} le off, low, medium nó high. Filleann aon luach eile 400. Múnlaí open-weight óstáilte
text object Iarrann {"format": {…}} freagra JSON. Féach Aschur struchtúrtha thíos. Gach leibhéal Shannon; múnlaí open-weight óstáilte mar atá liostaithe do gach id

Glactar le previous_response_id, store, metadata, parallel_tool_calls, truncation, include, user agus prompt_cache_key ionas go n-oibríonn cód cliaint atá ann cheana gan athrú. Ní athraíonn siad an freagra. Toisc nach stóráiltear aon chomhrá, iompraíonn iarratas leantach na casadh roimhe seo in input.

Míreanna ionchuir

Is teachtaireacht, le role agus content, nó mír chlóscríofa a iompraíonn glao uirlise nó a thoradh, é mír ionchuir. Is sreang nó eagar codanna content.

Mír Tuairisc Curtha i bhfeidhm ag
{"role": "user", "content": …} An rud a iarrann tú. Is sreang content, nó codanna input_text agus input_image. Gach múnla
{"role": "assistant", "content": …} Freagra níos luaithe ón múnla. Is sreang content, nó codanna output_text. Gach múnla
{"role": "system", "content": …}
{"role": "developer", "content": …}
Treoracha laistigh den chomhrá. Múnlaí open-weight óstáilte
{"type": "function_call", "call_id": "…", "name": "…", "arguments": "…"} Glao uirlise a rinne an múnla i bhfreagra níos luaithe. Is sreang JSON arguments. Gach múnla
{"type": "function_call_output", "call_id": "…", "output": "…"} Toradh an ghlao sin. Is é call_id id an ghlao agus output an toradh mar shreang. Gach múnla

Cuir treoracha sa réimse instructions. Le id de theaghlach Shannon 3, cuir treoracha atá le comhlíonadh sa teachtaireacht user.

Is féidir míreanna output freagra a chur ar ais in input mar atá: léitear míreanna message agus function_call, scipeáiltear míreanna reasoning.

Codanna ábhair

Cuid Tuairisc Ar fáil ar
{"type": "input_text", "text": "…"} Téacs teachtaireachta úsáideora. Gach múnla
{"type": "output_text", "text": "…"} Téacs teachtaireachta cúntóra. Gach múnla
{"type": "input_image", "image_url": "…"} Íomhá, mar URL data: le hábhar base64 nó mar URL http(s). Teaghlach Shannon 3, shannon-1.6-lite, shannon-1.6-pro, agus na múnlaí open-weight óstáilte a liostaíonn ionchur íomhá
{"type": "input_file", "file_data": "data:application/pdf;base64,…"} Doiciméad (PDF, Word, PowerPoint nó Excel): coinníonn file_data URL data:, nó file_url URL http(s). Teaghlach Shannon 3

Ar leibhéil Shannon léitear íomhánna agus comhaid ón mír user dheireanach de input. Tá leathanach dá gcuid féin ag méideanna agus teorainneacha. Íomhánna agus comhaid

Iarratas le treoracha agus roghanna

Seolann an t-iarratas seo treoracha, comhrá mar mhíreanna ionchuir, teorainn aschuir, teocht agus iarracht réasúnaíochta. Úsáideann sé múnla open-weight óstáilte, a chuireann iad uile i bhfeidhm.

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)

Tá id, object, model, created_at, status, output agus usage i bhfreagra múnla open-weight óstáilte. Cuireann a usage leis na tokens a léadh ón taisce agus na tokens a caitheadh ar réasúnaíocht:

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 réad freagra

Tá id, object, status, output agus usage ar gach freagra. Tóg do chód orthu sin.

Réimse Cineál Tuairisc Seolta ag
id string resp_ agus ina dhiaidh 32 carachtar heicsidheachúlach. Gach múnla
object string response i gcónaí. Gach múnla
status string completed. I sruth is in_progress é ar dtús, agus failed in imeacht response.failed. Gach múnla
output array Na míreanna aschuir san ord inar tháirg an múnla iad: reasoning, message, function_call. Gach múnla
usage object input_tokens, output_tokens agus total_tokens. Gach múnla
usage.input_tokens_details object cached_tokens: na tokens ionchuir a léadh ón taisce prompt. Múnlaí open-weight óstáilte
usage.output_tokens_details object reasoning_tokens: na tokens aschuir a caitheadh ar réasúnaíocht. Múnlaí open-weight óstáilte
model string Id canónach an mhúnla a d'fhreagair. Teaghlach Shannon 3, múnlaí open-weight óstáilte
created_at integer Am an fhreagra, i soicindí Unix. Teaghlach Shannon 3, múnlaí open-weight óstáilte
instructions, tools, temperature, … Athdhéanann instructions, tools agus temperature an t-iarratas. Is null iad error agus incomplete_details, is {} é metadata, is true é parallel_tool_calls, is auto é tool_choice agus is null é top_p. Teaghlach Shannon 3

Míreanna aschuir

Mír Tuairisc
{"id": "rs_…", "type": "reasoning", "summary": [{"type": "summary_text", "text": "…"}]} Réasúnaíocht an mhúnla mar chuid summary_text amháin. Ann amháin nuair a rinne an múnla réasúnaíocht.
{"id": "msg_…", "type": "message", "role": "assistant", "content": [{"type": "output_text", "text": "…"}]} An freagra: cuid output_text amháin leis an téacs.
{"id": "fc_…", "type": "function_call", "call_id": "call_…", "name": "…", "arguments": "…"} Glao uirlise. Is sreang JSON arguments. Seol an toradh ar ais leis an call_id céanna.

Ceanglaíonn SDKanna OpenAI téacs na teachtaireachta duit in response.output_text.

Sruthú

Socraigh stream ar true le haghaidh server-sent events. Tá líne event: le hainm an imeachta agus líne data: le réad JSON i ngach fráma; athdhéanann an réad an t-ainm in type. Cuir deilteanna le chéile lena mír de réir output_index.

Le SDK OpenAI, léigh na himeachtaí de réir a 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")

Tagann na himeachtaí san ord seo. Ní bhíonn na grúpaí don réasúnaíocht, don teachtaireacht agus do ghlaonna uirlisí ann ach amháin nuair a bhíonn siad sa fhreagra.

Imeacht Pálasta Cathain
response.created response Ar dtús i gcónaí. Is in_progress é response.status agus tá response.output folamh.
response.in_progress response Sa dara háit i gcónaí, leis an réad céanna.
response.output_item.added output_index, item Tosaíonn an réasúnaíocht: mír reasoning le summary folamh.
response.reasoning_summary_text.delta output_index, summary_index, delta Píosa den réasúnaíocht.
response.reasoning_summary_text.done output_index, summary_index, text Tá an réasúnaíocht críochnaithe: a text iomlán.
response.output_item.done output_index, item An mhír reasoning chríochnaithe.
response.output_item.added output_index, item Tosaíonn an freagra: mír message le stádas in_progress agus gan ábhar.
response.content_part.added output_index, content_index, part Osclaítear cuid output_text folamh.
response.output_text.delta output_index, content_index, delta Píosa den fhreagra.
response.output_text.done output_index, content_index, text Tá an freagra críochnaithe: a text iomlán.
response.content_part.done output_index, content_index, part An chuid output_text chríochnaithe.
response.output_item.done output_index, item An mhír message chríochnaithe, le stádas completed.
response.output_item.added output_index, item Tosaíonn glao uirlise: mír function_call le call_id, name agus arguments folamh.
response.function_call_arguments.delta output_index, delta Argóintí an ghlao, iomlán in aon delta amháin.
response.function_call_arguments.done output_index, arguments Na hargóintí céanna, mar arguments.
response.output_item.done output_index, item An mhír function_call chríochnaithe.
response.completed response Go deireanach i gcónaí nuair a éiríonn leis: an réad freagra iomlán 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}, …}}

Sruth a theipeann

Ar leibhéil Shannon críochnaíonn freagra a theip le response.failed in ionad response.completed. Is failed é a response.status agus coinníonn response.error code, rate_limit_exceeded nó server_error, agus message.

Ar na múnlaí open-weight óstáilte is imeacht error é teip le code api_error agus message. Leanann response.completed é fós.

Déileáil le sruth mar theip nuair a bhíonn imeacht response.failed nó error ann, agus seol an t-iarratas arís.

Uirlisí

Is feidhm é uirlis a ritheann do chód. Déan cur síos uirthi in tools; nuair a theastaíonn sí ón múnla, coinníonn an freagra mír function_call in ionad na teachtaireachta, nó in aice léi.

Sainmhíniú uirlise in tools:

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

output freagra a ghlaonn í:

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

Rith an fheidhm, ansin seol an t-iarratas arís agus an glao agus a thoradh curtha le 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\"}"
  }
]

Ní léitear ach uirlisí den chineál function. Ar shannon-1.6-*, shannon-2-* agus shannon-coder-1 laghdaítear an scéim parameters go dtí na heochairfhocail choitianta JSON Schema: léitear oneOf mar anyOf, agus ní chuirtear eochairfhocail mar $ref, additionalProperties, const, default agus title ar aghaidh chuig an múnla.

Cuireann na múnlaí open-weight óstáilte luachanna tool_choice required agus feidhm ainmnithe i bhfeidhm.

Déantar cur síos iomlán ar lúb na n-uirlisí ar leathanach dá cuid féin. Glaonna Feidhme

Aschur struchtúrtha

Scríobhann an fhormáid seo aschur struchtúrtha mar text.format. Suíonn an scéim go díreach i format, in aice le name agus strict, ní faoi bhall json_schema mar a bhíonn ar Chat Completions.

  • Iarrann {"type": "json_object"} aon réad JSON.
  • Iarrann {"type": "json_schema", "name", "schema", "strict"} JSON a leanann do scéim. Is true é strict nuair a fhágann tú ar lár é.
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"
        ]
      }
    }
  }
}

Tagann an JSON mar théacs sa chuid output_text den teachtaireacht; parsáil féin é. Filleann múnla open-weight óstáilte gan aschur struchtúrtha 400.

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

Liostaítear cén múnla a ghlacann le cén fhoirm ar leathanach dá chuid féin. Aschuir Struchtúrtha

Réasúnaíocht

Filleann múnla a dhéanann réasúnaíocht a réasúnaíocht mar mhír aschuir den chineál reasoning, roimh an teachtaireacht. I sruth tagann sí mar imeachtaí response.reasoning_summary_text.delta.

Cuireann na múnlaí open-weight óstáilte reasoning.effort i bhfeidhm: off, low, medium nó high, agus high nuair nach seolann tú faic. Ní fhilleann off aon mhír réasúnaíochta. Seol é mar réad; ní léitear sreang lom ar an gcríochphointe seo.

Déantar cur síos ar na hiarrachtaí ar leathanach dá gcuid féin. Iarracht réasúnaíochta

Teorainn aschuir

Is é 4,096 max_output_tokens mura seolann tú é. Is é líon na dtokens a chuirtear i leataobh as d'iarmhéid nuair a thosaíonn an t-iarratas; nuair a bhíonn an freagra críochnaithe, cuirtear an méid a d'úsáid an t-iarratas ina áit. Filleann luach nach n-oireann do d'iarmhéid fágtha 429 Quota exceeded.

Cuireann sé teorainn le fad an fhreagra ar shannon-1.6-*, shannon-2-* agus shannon-coder-1, agus le fad théacs an fhreagra ar na múnlaí open-weight óstáilte.

Ar an gcríochphointe seo muirearaítear shannon-coder-1 i dtokens ó d'iarmhéid, cosúil le gach múnla eile.

Féadfaidh corp iarratais a bheith suas le 32 MiB. Teorainneacha agus iarmhéid

Earráidí

Úsáideann earráidí corp earráide OpenAI: réad error le type agus message; iompraíonn cuid acu code agus param freisin leis an luach null. Liostaíonn an tábla an méid a fhilleann an críochphointe seo is minice. Tá leathanach dá chuid féin ag an liosta iomlán, lena n-áirítear cad atá le hathiarraidh. Láimhseáil Earráide

Stádas Cineál Teachtaireacht Cathain
401 authentication_error Missing authentication
Invalid API key
Níor seoladh aon eochair API, nó níl aithne ar an eochair nó cúlghairadh í.
400 invalid_request_error unknown model: <id> Tá model ar iarraidh nó ní id foilsithe é.
400 invalid_request_error No user message provided. Leibhéil Shannon: níl aon téacs úsáideora i input.
400 invalid_request_error <id> does not accept image input Seoladh íomhá chuig múnla open-weight óstáilte gan ionchur íomhá.
400 invalid_request_error <id> does not accept response_format Seoladh text.format chuig múnla open-weight óstáilte gan aschur struchtúrtha.
400 invalid_request_error unknown reasoning effort '<value>'; expected off, low, medium or high Tá luach lasmuigh den liosta i reasoning.effort.
422 invalid_request_error Failed to deserialize the JSON body into the target type: … Is JSON bailí é an corp ach tá cineál mícheart ar réimse.
429 rate_limit_error Quota exceeded. Upgrade your plan at shannon-ai.com/plan Tá max_output_tokens níos mó ná an méid atá fágtha de d'iarmhéid.
429 rate_limit_error Too many requests. Retry in <n>s. Cosaint tuilte: níos mó ná 120 iarratas in aon nóiméad amháin ar do chuntas.
500 api_error The model backend failed to answer. Please retry. Níor tháirg an múnla freagra. Seol an t-iarratas arís.
502 api_error The model backend failed to answer. Please retry. An rud céanna, ar na múnlaí open-weight óstáilte.
504 api_error upstream timed out Thóg múnla open-weight óstáilte níos faide ná teorainn ama freagra gan sruthú. Seol é le stream socraithe ar true.