Mandrosoa any amin'ny votoaty
Responses API

Responses API

Vaovao

Ny POST /v1/responses dia mandray instructions sy lisitry ny input item ary mamerina response object misy output item, amin'ny endrika OpenAI Responses. Ampiasao miaraka amin'ny responses API an'ny SDK OpenAI sy ny tool mifototra aminy, toy ny Codex CLI. Ny endpoint dia tsy mitahiry state: alefaso ny resaka manontolo isaky ny fangatahana.

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

Ny fangatahana kely indrindra dia id model sy soratra. Ny valiny dia tsy streamed raha tsy angatahinao.

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)

Ny valiny dia response object. Ny output-ny dia misy ny reasoning, raha nanao reasoning ny model, sy ny hafatra:

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

Saha fangatahana

Ny model sy input no ilain'ny fangatahana. Ny tsanganana Applied by dia manonona ny model izay anovan'ny saha ny valiny. Ny model open-weight hosted dia ny id roa ambin'ny folo ao amin'ny lisitry ny model; ny fianakavian'i Shannon 3 dia shannon-3, shannon-3-pro, shannon-3.1 ary shannon-3.1-pro. Model & vidiny

Saha Karazana Default Famaritana Ampiharin'ny
model string Ilaina. Id avy ao amin'ny lisitry ny model. Tsy mijery ny litera lehibe/kely ny fampitahana. Ny id tsy misy na tsy navoaka dia mamerina 400 unknown model. Model rehetra
input string | array String, vakiana ho hafatry ny mpampiasa iray, na array misy input item. Jereo ny Input item etsy ambany. Model rehetra
instructions string Toromarika ho an'ny model, ny system prompt amin'ity endrika ity. Model open-weight hosted, shannon-1.6-*, shannon-2-*, shannon-coder-1
stream boolean false Ny true dia mandefa ny valiny ho server-sent events. Jereo ny Streaming etsy ambany. Model rehetra
max_output_tokens integer 4096 Fetra ambony ho an'ny valiny, amin'ny token. Ny sanda ivelan'ny 1 hatramin'ny 65,536 dia ampifandraisina amin'io faribolana io. Io koa no habetsaka voatahiry avy amin'ny balance-nao raha mbola mandeha ny fangatahana. Jereo ny Output limit etsy ambany. Model open-weight hosted, shannon-1.6-*, shannon-2-*, shannon-coder-1
temperature number Sampling temperature. Amin'ny model open-weight hosted dia tazonina eo anelanelan'ny 0 sy 2 ny sanda. Model open-weight hosted; shannon-1.6-*, shannon-2-* ary shannon-coder-1 amin'ny valiny tsy streamed
top_p number Nucleus sampling. Tazonina eo anelanelan'ny 0 sy 1 ny sanda. Model open-weight hosted
tools array Ny function azon'ny model antsoina, amin'ny endrika fisaka an'ity format ity: {"type": "function", "name", "description", "parameters"}. Jereo ny Tools etsy ambany. Model rehetra
tool_choice string | object auto Ny "auto" dia avela hanapa-kevitra ny model. Ny "required" dia manery azy hiantso tool. Ny {"type": "function", "name": "…"} dia manery azy hiantso io tool io. Model open-weight hosted
reasoning object {"effort": "…"} miaraka amin'ny off, low, medium na high. Ny sanda hafa rehetra dia mamerina 400. Model open-weight hosted
text object Ny {"format": {…}} dia mangataka valiny JSON. Jereo ny Structured output etsy ambany. Tier Shannon rehetra; model open-weight hosted araka ny voatanisa isaky ny id

Raisina ny previous_response_id, store, metadata, parallel_tool_calls, truncation, include, user ary prompt_cache_key mba hahafahan'ny kaody client efa misy mandeha tsy miova. Tsy manova ny valiny izy ireo. Satria tsy misy resaka voatahiry, ny fangatahana manaraka dia mitondra ny fihodinana teo aloha ao amin'ny input.

Input item

Ny input item dia na hafatra, misy role sy content, na item misy karazana mitondra tool call na ny valiny. Ny content dia string na array misy ampahany.

Item Famaritana Ampiharin'ny
{"role": "user", "content": …} Izay angatahinao. Ny content dia string, na ampahany input_text sy input_image. Model rehetra
{"role": "assistant", "content": …} Valin'ny model teo aloha. Ny content dia string, na ampahany output_text. Model rehetra
{"role": "system", "content": …}
{"role": "developer", "content": …}
Toromarika ao anaty resaka. Model open-weight hosted
{"type": "function_call", "call_id": "…", "name": "…", "arguments": "…"} Tool call nataon'ny model tamin'ny valiny teo aloha. Ny arguments dia string JSON. Model rehetra
{"type": "function_call_output", "call_id": "…", "output": "…"} Ny valin'io antso io. Ny call_id dia ny id an'ny antso ary ny output ny valiny ho string. Model rehetra

Apetraho ao amin'ny saha instructions ny toromarika. Amin'ny id ao amin'ny fianakavian'i Shannon 3, apetraho ao amin'ny hafatra user ny toromarika tsy maintsy tanteraka.

Ny item ao amin'ny output an'ny valiny dia azo averina ao amin'ny input araka izy: ny item message sy function_call dia vakiana, ny item reasoning dia lavina.

Content part

Ampahany Famaritana Azo ampiasaina amin'ny
{"type": "input_text", "text": "…"} Soratry ny hafatry ny mpampiasa. Model rehetra
{"type": "output_text", "text": "…"} Soratry ny hafatra assistant. Model rehetra
{"type": "input_image", "image_url": "…"} Sary, ho URL data: misy base64 na ho URL http(s). Fianakavian'i Shannon 3, shannon-1.6-lite, shannon-1.6-pro, ary ny model open-weight hosted izay mitanisa input sary
{"type": "input_file", "file_data": "data:application/pdf;base64,…"} Document (PDF, Word, PowerPoint na Excel): ny file_data dia mitazona URL data:, na ny file_url URL http(s). Fianakavian'i Shannon 3

Amin'ny tier Shannon, ny sary sy rakitra dia vakiana avy amin'ny item user farany ao amin'ny input. Ny habe sy fetra dia manana pejy manokana. Sary sy rakitra

Fangatahana misy instructions sy options

Ity fangatahana ity dia mandefa instructions, resaka ho input item, output limit, temperature ary reasoning effort. Mampiasa model open-weight hosted izy, izay mampihatra ireo rehetra.

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)

Ny valin'ny model open-weight hosted dia manana id, object, model, created_at, status, output ary usage. Ny usage-ny dia manampy ny token novakina avy amin'ny cache sy ny token lany tamin'ny 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
  }
}

Ny response object

Ny id, object, status, output ary usage dia misy amin'ny valiny rehetra. Iorina amin'ireo ny kaody-nao.

Saha Karazana Famaritana Alefan'ny
id string resp_ arahin'ny tarehintsoratra hexadecimal 32. Model rehetra
object string Foana response. Model rehetra
status string completed. Ao anaty stream dia in_progress aloha izy, ary failed ao amin'ny event response.failed. Model rehetra
output array Ny output item araka ny filaharana namokatrany ny model: reasoning, message, function_call. Model rehetra
usage object input_tokens, output_tokens ary total_tokens. Model rehetra
usage.input_tokens_details object cached_tokens: ny input token novakina avy amin'ny prompt cache. Model open-weight hosted
usage.output_tokens_details object reasoning_tokens: ny output token lany tamin'ny reasoning. Model open-weight hosted
model string Ny id kanônika an'ny model namaly. Fianakavian'i Shannon 3, model open-weight hosted
created_at integer Ny fotoanan'ny valiny, amin'ny segondra Unix. Fianakavian'i Shannon 3, model open-weight hosted
instructions, tools, temperature, … Ny instructions, tools ary temperature dia mamerina ny fangatahana. Ny error sy incomplete_details dia null, ny metadata dia {}, ny parallel_tool_calls dia true, ny tool_choice dia auto ary ny top_p dia null. Fianakavian'i Shannon 3

Output item

Item Famaritana
{"id": "rs_…", "type": "reasoning", "summary": [{"type": "summary_text", "text": "…"}]} Ny reasoning an'ny model ho ampahany summary_text iray. Misy rehefa nanao reasoning ny model ihany.
{"id": "msg_…", "type": "message", "role": "assistant", "content": [{"type": "output_text", "text": "…"}]} Ny valiny: ampahany output_text iray misy ny soratra.
{"id": "fc_…", "type": "function_call", "call_id": "call_…", "name": "…", "arguments": "…"} Tool call. Ny arguments dia string JSON. Alefaso miverina ny valiny miaraka amin'ny call_id mitovy.

Ny SDK OpenAI dia manambatra ho anao ny soratry ny hafatra ao amin'ny response.output_text.

Streaming

Apetraho ho true ny stream ho server-sent events. Ny frame tsirairay dia manana andalana event: misy ny anaran'ny event ary andalana data: misy object JSON; ny object dia mamerina ny anarana ao amin'ny type. Ampifanaraho amin'ny item-ny amin'ny output_index ny delta.

Miaraka amin'ny SDK OpenAI, vakio araka ny type-ny ny event:

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")

Tonga araka ity filaharana ity ny event. Ny vondrona ho an'ny reasoning, ny hafatra ary ny tool call dia miseho rehefa manana azy ny valiny ihany.

Event Payload Rahoviana
response.created response Foana voalohany. Ny response.status dia in_progress ary foana ny response.output.
response.in_progress response Foana faharoa, miaraka amin'ny object mitovy.
response.output_item.added output_index, item Manomboka ny reasoning: item reasoning misy summary foana.
response.reasoning_summary_text.delta output_index, summary_index, delta Sombin'ny reasoning.
response.reasoning_summary_text.done output_index, summary_index, text Vita ny reasoning: ny text-ny manontolo.
response.output_item.done output_index, item Ny item reasoning vita.
response.output_item.added output_index, item Manomboka ny valiny: item message misy status in_progress ary tsy misy content.
response.content_part.added output_index, content_index, part Misokatra ampahany output_text foana.
response.output_text.delta output_index, content_index, delta Sombin'ny valiny.
response.output_text.done output_index, content_index, text Vita ny valiny: ny text-ny manontolo.
response.content_part.done output_index, content_index, part Ny ampahany output_text vita.
response.output_item.done output_index, item Ny item message vita, misy status completed.
response.output_item.added output_index, item Miandoha ny tool call: item function_call miaraka amin'ny call_id, name ary arguments foana.
response.function_call_arguments.delta output_index, delta Ny arguments an'ny antso, feno ao anaty delta iray.
response.function_call_arguments.done output_index, arguments Ny arguments mitovy, ho arguments.
response.output_item.done output_index, item Ny item function_call vita.
response.completed response Foana farany rehefa nahomby: ny response object manontolo miaraka amin'ny output sy 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 tsy mahomby

Amin'ny tier Shannon, ny valiny tsy nahomby dia mifarana amin'ny response.failed fa tsy response.completed. Ny response.status-ny dia failed ary ny response.error dia mitazona code, rate_limit_exceeded na server_error, ary message.

Amin'ny model open-weight hosted, ny tsy fahombiazana dia event error miaraka amin'ny code api_error sy message. Mbola manaraka azy ny response.completed.

Heverina ho tsy nahomby ny stream rehefa misy event response.failed na error, ary alefaso indray ny fangatahana.

Tools

Ny tool dia function ampandehanin'ny kaody-nao. Faritano ao amin'ny tools; rehefa mila azy ny model, ny valiny dia misy item function_call solon'ny hafatra, na eo anilany.

Famaritana tool ao amin'ny tools:

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

Ny output an'ny valiny miantso azy:

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

Ampandehano ny function, avy eo alefaso indray ny fangatahana miaraka amin'ny antso sy ny valiny nampidirina ao amin'ny 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\"}"
  }
]

Ny tool karazana function ihany no vakiana. Amin'ny shannon-1.6-*, shannon-2-* ary shannon-coder-1 ny schema parameters dia ahena ho keyword JSON Schema iraisana: ny oneOf dia vakiana ho anyOf, ary ny keyword toy ny $ref, additionalProperties, const, default ary title dia tsy atolotra ny model.

Ny sanda tool_choice required sy function voatondro dia ampiharin'ny model open-weight hosted.

Ny tool loop dia voasoratra tanteraka ao amin'ny pejiny manokana. Antso fiasa

Structured output

Ity endrika ity dia manoratra ny structured output ho text.format. Ny schema dia mipetraka mivantana ao amin'ny format, eo anilan'ny name sy strict, fa tsy ao ambanin'ny mpikambana json_schema toy ny amin'ny Chat Completions.

  • Ny {"type": "json_object"} dia mangataka object JSON na inona na inona.
  • Ny {"type": "json_schema", "name", "schema", "strict"} dia mangataka JSON araka ny schema-nao. Ny strict dia true raha tsy asianao.
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"
        ]
      }
    }
  }
}

Ny JSON dia tonga ho soratra ao amin'ny ampahany output_text an'ny hafatra; parse-o ianao. Ny model open-weight hosted tsy manana structured output dia mamerina 400.

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

Izay model mandray izay endrika dia voatanisa ao amin'ny pejiny manokana. Vokatra voarafitra

Reasoning

Ny model manao reasoning dia mamerina ny reasoning-ny ho output item karazana reasoning, alohan'ny hafatra. Ao anaty stream dia tonga ho event response.reasoning_summary_text.delta.

Ny model open-weight hosted dia mampihatra ny reasoning.effort: off, low, medium na high, miaraka amin'ny high raha tsy mandefa na inona na inona ianao. Ny off dia tsy mamerina item reasoning. Alefaso ho object; ny string tsotra dia tsy vakiana amin'ity endpoint ity.

Voasoratra ao amin'ny pejiny manokana ny effort. Reasoning effort

Output limit

4,096 ny max_output_tokens raha tsy alefanao. Io no isan'ny token voatahiry avy amin'ny balance-nao rehefa manomboka ny fangatahana; rehefa vita ny valiny, io habetsaka io dia soloina izay nampiasain'ny fangatahana. Ny sanda tsy mifanaraka amin'ny balance sisa dia mamerina 429 Quota exceeded.

Mametra ny halavan'ny valiny izy amin'ny shannon-1.6-*, shannon-2-* ary shannon-coder-1, ary ny halavan'ny soratry ny valiny amin'ny model open-weight hosted.

Amin'ity endpoint ity, ny shannon-coder-1 dia vidiana amin'ny token avy amin'ny balance-nao, tahaka ny model hafa rehetra.

Ny body ny fangatahana dia hatramin'ny 32 MiB. Fetra sy balance

Hadisoana

Ny hadisoana dia mampiasa ny body hadisoana OpenAI: object error misy type sy message; ny sasany dia mitondra code sy param koa miaraka amin'ny sanda null. Ny tabilao dia mitanisa izay averin'ity endpoint ity matetika indrindra. Ny lisitra feno, miaraka amin'izay hatao retry, dia manana pejy manokana. Fitantanana hadisoana

Status Type Hafatra Rahoviana
401 authentication_error Missing authentication
Invalid API key
Tsy nandefa API key, na tsy fantatra na nofoanana ny key.
400 invalid_request_error unknown model: <id> Tsy misy ny model na tsy id navoaka izy.
400 invalid_request_error No user message provided. Tier Shannon: tsy misy soratra avy amin'ny mpampiasa ny input.
400 invalid_request_error <id> does not accept image input Nalefa sary tamin'ny model open-weight hosted tsy mandray sary.
400 invalid_request_error <id> does not accept response_format Nalefa tamin'ny model open-weight hosted tsy manana structured output ny text.format.
400 invalid_request_error unknown reasoning effort '<value>'; expected off, low, medium or high Ny reasoning.effort dia mitazona sanda ivelan'ny lisitra.
422 invalid_request_error Failed to deserialize the JSON body into the target type: … JSON mety ny body nefa diso ny karazana saha iray.
429 rate_limit_error Quota exceeded. Upgrade your plan at shannon-ai.com/plan Lehibe noho ny sisa amin'ny balance-nao ny max_output_tokens.
429 rate_limit_error Too many requests. Retry in <n>s. Flood protection: mihoatra ny fangatahana 120 ao anatin'ny minitra iray amin'ny kaontinao.
500 api_error The model backend failed to answer. Please retry. Tsy namoaka valiny ny model. Alefaso indray ny fangatahana.
502 api_error The model backend failed to answer. Please retry. Mitovy, amin'ny model open-weight hosted.
504 api_error upstream timed out Naharitra lavitra noho ny fetra fotoana ny model open-weight hosted amin'ny valiny tsy streamed. Alefaso miaraka amin'ny stream voapetraka ho true.