Responses API
नवीनPOST /v1/responses सूचना आणि इनपुट आयटम्सची यादी घेते आणि OpenAI Responses फॉरमॅटमध्ये आउटपुट आयटम्सचा बनलेला रिस्पॉन्स ऑब्जेक्ट परत करते. OpenAI SDK च्या responses API सोबत आणि त्यावर बांधलेल्या Codex CLI सारख्या टूल्ससोबत वापरा. एंडपॉइंट कोणतीही स्थिती ठेवत नाही: प्रत्येक रिक्वेस्टसोबत संपूर्ण संभाषण पाठवा.
POST https://api.shannon-ai.com/v1/responses
सर्वात लहान रिक्वेस्ट म्हणजे मॉडेल id आणि एक मजकूर. तुम्ही मागितल्याशिवाय उत्तर स्ट्रीम होत नाही.
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) import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com/v1",
});
const response = await client.responses.create({
model: "shannon-3",
input: "Say hello in one sentence.",
});
console.log(response.output_text); curl https://api.shannon-ai.com/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "shannon-3",
"input": "Say hello in one sentence."
}' उत्तर म्हणजे रिस्पॉन्स ऑब्जेक्ट. त्याच्या output मध्ये मॉडेलने रीझनिंग केले असल्यास ते आणि संदेश असतो:
{
"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
}
} रिक्वेस्ट फील्ड्स
रिक्वेस्टला model आणि input लागतात. कोण लागू करते स्तंभ ज्या मॉडेल्सवर फील्ड उत्तर बदलते ती नावे देतो. होस्ट केलेली open-weight मॉडेल्स म्हणजे मॉडेल यादीतील बारा id; Shannon 3 कुटुंब म्हणजे shannon-3, shannon-3-pro, shannon-3.1 आणि shannon-3.1-pro. मॉडेल्स आणि किंमत
| फील्ड | प्रकार | डिफॉल्ट | वर्णन | कोण लागू करते |
|---|---|---|---|---|
model | string | आवश्यक. मॉडेल यादीतील id. जुळवताना मोठ्या-लहान अक्षरांचा फरक पडत नाही. नसलेला किंवा प्रकाशित नसलेला id 400 unknown model परत करतो. | सर्व मॉडेल्स | |
input | string | array | स्ट्रिंग, जी एक युजर संदेश म्हणून वाचली जाते, किंवा इनपुट आयटम्सचा ॲरे. खाली Input items पाहा. | सर्व मॉडेल्स | |
instructions | string | मॉडेलसाठी सूचना, या फॉरमॅटचा सिस्टम प्रॉम्प्ट. | होस्ट केलेली open-weight मॉडेल्स, shannon-1.6-*, shannon-2-*, shannon-coder-1 | |
stream | boolean | false | true उत्तर server-sent events म्हणून पाठवते. खाली Streaming पाहा. | सर्व मॉडेल्स |
max_output_tokens | integer | 4096 | उत्तराची कमाल मर्यादा, टोकन्समध्ये. 1 ते 65,536 बाहेरचे मूल्य त्या श्रेणीत आणले जाते. रिक्वेस्ट चालू असताना तुमच्या बॅलन्समधून राखून ठेवलेली रक्कमही हीच असते. खाली Output limit पाहा. | होस्ट केलेली open-weight मॉडेल्स, shannon-1.6-*, shannon-2-*, shannon-coder-1 |
temperature | number | सॅम्पलिंग टेंपरेचर. होस्ट केलेल्या open-weight मॉडेल्सवर मूल्ये 0 आणि 2 दरम्यान ठेवली जातात. | होस्ट केलेली open-weight मॉडेल्स; स्ट्रीम नसलेल्या उत्तरांवर shannon-1.6-*, shannon-2-* आणि shannon-coder-1 | |
top_p | number | न्यूक्लियस सॅम्पलिंग. मूल्ये 0 आणि 1 दरम्यान ठेवली जातात. | होस्ट केलेली open-weight मॉडेल्स | |
tools | array | मॉडेल कॉल करू शकणारी फंक्शन्स, या फॉरमॅटच्या सपाट स्वरूपात: {"type": "function", "name", "description", "parameters"}. खाली Tools पाहा. | सर्व मॉडेल्स | |
tool_choice | string | object | auto | "auto" मॉडेलला ठरवू देते. "required" त्याला टूल कॉल करायला लावते. {"type": "function", "name": "…"} त्याला तेच टूल कॉल करायला लावते. | होस्ट केलेली open-weight मॉडेल्स |
reasoning | object | off, low, medium किंवा high सह {"effort": "…"}. इतर कोणतेही मूल्य 400 परत करते. | होस्ट केलेली open-weight मॉडेल्स | |
text | object | {"format": {…}} JSON उत्तर मागते. खाली Structured output पाहा. | सर्व Shannon टियर्स; होस्ट केलेली open-weight मॉडेल्स प्रत्येक id नुसार नमूद केल्याप्रमाणे |
previous_response_id, store, metadata, parallel_tool_calls, truncation, include, user आणि prompt_cache_key स्वीकारली जातात, म्हणजे विद्यमान क्लायंट कोड बदल न करता चालतो. ती उत्तर बदलत नाहीत. संभाषण साठवले जात नसल्यामुळे पुढची रिक्वेस्ट आधीचे टर्न्स input मध्ये घेऊन जाते.
इनपुट आयटम्स
इनपुट आयटम म्हणजे role आणि content असलेला संदेश, किंवा टूल कॉल अथवा त्याचा निकाल असलेला टाइप केलेला आयटम. content स्ट्रिंग किंवा भागांचा ॲरे असतो.
| आयटम | वर्णन | कोण लागू करते |
|---|---|---|
{"role": "user", "content": …} | तुम्ही जे विचारता. content स्ट्रिंग, किंवा input_text आणि input_image भाग असतो. | सर्व मॉडेल्स |
{"role": "assistant", "content": …} | मॉडेलचे आधीचे उत्तर. content स्ट्रिंग किंवा output_text भाग असतो. | सर्व मॉडेल्स |
{"role": "system", "content": …}{"role": "developer", "content": …} | संभाषणातील सूचना. | होस्ट केलेली open-weight मॉडेल्स |
{"type": "function_call", "call_id": "…", "name": "…", "arguments": "…"} | मॉडेलने आधीच्या उत्तरात केलेला टूल कॉल. arguments JSON स्ट्रिंग असते. | सर्व मॉडेल्स |
{"type": "function_call_output", "call_id": "…", "output": "…"} | त्या कॉलचा निकाल. call_id कॉलचा id आणि output निकाल स्ट्रिंग म्हणून. | सर्व मॉडेल्स |
सूचना instructions फील्डमध्ये ठेवा. Shannon 3 कुटुंबाच्या id सह, जी सूचना पाळली गेलीच पाहिजे ती user संदेशात ठेवा.
उत्तराच्या output मधील आयटम्स जसेच्या तसे input मध्ये परत जाऊ शकतात: message आणि function_call आयटम्स वाचले जातात, reasoning आयटम्स वगळले जातात.
कंटेंट भाग
| भाग | वर्णन | कुठे उपलब्ध |
|---|---|---|
{"type": "input_text", "text": "…"} | युजर संदेशाचा मजकूर. | सर्व मॉडेल्स |
{"type": "output_text", "text": "…"} | असिस्टंट संदेशाचा मजकूर. | सर्व मॉडेल्स |
{"type": "input_image", "image_url": "…"} | इमेज, base64 मजकूर असलेला data: URL म्हणून किंवा http(s) URL म्हणून. | Shannon 3 कुटुंब, shannon-1.6-lite, shannon-1.6-pro, आणि इमेज इनपुट असल्याचे नमूद करणारी होस्ट केलेली open-weight मॉडेल्स |
{"type": "input_file", "file_data": "data:application/pdf;base64,…"} | दस्तऐवज (PDF, Word, PowerPoint किंवा Excel): file_data मध्ये data: URL, किंवा file_url मध्ये http(s) URL असतो. | Shannon 3 कुटुंब |
Shannon टियर्सवर इमेज आणि फाइल्स input च्या शेवटच्या user आयटममधून वाचल्या जातात. आकार आणि मर्यादांसाठी स्वतंत्र पान आहे. इमेज आणि फाइल्स
सूचना आणि पर्यायांसह रिक्वेस्ट
ही रिक्वेस्ट सूचना, इनपुट आयटम्सच्या रूपात संभाषण, आउटपुट मर्यादा, टेंपरेचर आणि रीझनिंग effort पाठवते. ती होस्ट केलेले open-weight मॉडेल वापरते, जे या सर्व लागू करते.
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) import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com/v1",
});
const response = await 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 (const item of response.output) {
if (item.type === "reasoning") console.log("reasoning:", item.summary[0].text);
if (item.type === "message") console.log("answer:", item.content[0].text);
}
console.log(response.usage); curl https://api.shannon-ai.com/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"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"}
}' होस्ट केलेल्या open-weight मॉडेलच्या उत्तरात id, object, model, created_at, status, output आणि usage असतात. त्याचे usage कॅशमधून वाचलेली टोकन्स आणि रीझनिंगवर खर्च झालेली टोकन्स जोडते:
{
"usage": {
"input_tokens": 58,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 67,
"output_tokens_details": {
"reasoning_tokens": 19
},
"total_tokens": 125
}
} रिस्पॉन्स ऑब्जेक्ट
id, object, status, output आणि usage प्रत्येक उत्तरात असतात. तुमचा कोड त्यांवर बांधा.
| फील्ड | प्रकार | वर्णन | कोण पाठवते |
|---|---|---|---|
id | string | resp_ नंतर 32 हेक्साडेसिमल अक्षरे. | सर्व मॉडेल्स |
object | string | नेहमी response. | सर्व मॉडेल्स |
status | string | completed. स्ट्रीममध्ये आधी in_progress असते, आणि response.failed इव्हेंटमध्ये failed. | सर्व मॉडेल्स |
output | array | मॉडेलने तयार केलेल्या क्रमाने आउटपुट आयटम्स: reasoning, message, function_call. | सर्व मॉडेल्स |
usage | object | input_tokens, output_tokens आणि total_tokens. | सर्व मॉडेल्स |
usage.input_tokens_details | object | cached_tokens: प्रॉम्प्ट कॅशमधून वाचलेली इनपुट टोकन्स. | होस्ट केलेली open-weight मॉडेल्स |
usage.output_tokens_details | object | reasoning_tokens: रीझनिंगवर खर्च झालेली आउटपुट टोकन्स. | होस्ट केलेली open-weight मॉडेल्स |
model | string | उत्तर देणाऱ्या मॉडेलचा कॅनॉनिकल id. | Shannon 3 कुटुंब, होस्ट केलेली open-weight मॉडेल्स |
created_at | integer | उत्तराची वेळ, Unix सेकंदांत. | Shannon 3 कुटुंब, होस्ट केलेली open-weight मॉडेल्स |
instructions, tools, temperature, … | instructions, tools आणि temperature रिक्वेस्ट पुन्हा सांगतात. error आणि incomplete_details null आहेत, metadata {} आहे, parallel_tool_calls true आहे, tool_choice auto आहे आणि top_p null आहे. | Shannon 3 कुटुंब |
आउटपुट आयटम्स
| आयटम | वर्णन |
|---|---|
{"id": "rs_…", "type": "reasoning", "summary": [{"type": "summary_text", "text": "…"}]} | मॉडेलचे रीझनिंग एक summary_text भाग म्हणून. मॉडेलने रीझनिंग केले असेल तेव्हाच असतो. |
{"id": "msg_…", "type": "message", "role": "assistant", "content": [{"type": "output_text", "text": "…"}]} | उत्तर: मजकूर असलेला एक output_text भाग. |
{"id": "fc_…", "type": "function_call", "call_id": "call_…", "name": "…", "arguments": "…"} | टूल कॉल. arguments JSON स्ट्रिंग असते. निकाल त्याच call_id सह परत पाठवा. |
OpenAI SDK संदेशाचा मजकूर तुमच्यासाठी response.output_text मध्ये जोडतात.
स्ट्रीमिंग
server-sent events साठी stream true सेट करा. प्रत्येक फ्रेममध्ये इव्हेंटचे नाव असलेली event: ओळ आणि JSON ऑब्जेक्ट असलेली data: ओळ असते; ऑब्जेक्ट type मध्ये नाव पुन्हा सांगतो. डेल्टा त्यांच्या आयटमशी output_index ने जुळवा.
OpenAI SDK सह इव्हेंट्स त्यांच्या 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") import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.shannon-ai.com/v1",
});
const stream = await client.responses.create({
model: "shannon-3",
input: "Explain server-sent events in three sentences.",
stream: true,
});
for await (const event of stream) {
if (event.type === "response.reasoning_summary_text.delta") {
// a piece of reasoning: event.delta
} else if (event.type === "response.output_text.delta") {
process.stdout.write(event.delta);
} else if (event.type === "response.output_item.done" && event.item.type === "function_call") {
console.log("\ntool call:", event.item.name, event.item.arguments);
} else if (event.type === "response.completed") {
console.log("\n", event.response.usage);
} else if (event.type === "response.failed" || event.type === "error") {
throw new Error("the stream failed, send the request again");
}
} curl -N https://api.shannon-ai.com/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "shannon-3",
"input": "Explain server-sent events in three sentences.",
"stream": true
}' इव्हेंट्स या क्रमाने येतात. रीझनिंग, संदेश आणि टूल कॉल्सचे गट उत्तरात ते असतील तेव्हाच दिसतात.
| इव्हेंट | पेलोड | केव्हा |
|---|---|---|
response.created | response | नेहमी पहिला. response.status in_progress आहे आणि response.output रिकामे आहे. |
response.in_progress | response | नेहमी दुसरा, त्याच ऑब्जेक्टसह. |
response.output_item.added | output_index, item | रीझनिंग सुरू होते: रिकामे summary असलेला reasoning आयटम. |
response.reasoning_summary_text.delta | output_index, summary_index, delta | रीझनिंगचा एक तुकडा. |
response.reasoning_summary_text.done | output_index, summary_index, text | रीझनिंग पूर्ण झाले: त्याचा संपूर्ण text. |
response.output_item.done | output_index, item | पूर्ण झालेला reasoning आयटम. |
response.output_item.added | output_index, item | उत्तर सुरू होते: स्टेटस in_progress आणि मजकूर नसलेला message आयटम. |
response.content_part.added | output_index, content_index, part | रिकामा output_text भाग उघडतो. |
response.output_text.delta | output_index, content_index, delta | उत्तराचा एक तुकडा. |
response.output_text.done | output_index, content_index, text | उत्तर पूर्ण झाले: त्याचा संपूर्ण text. |
response.content_part.done | output_index, content_index, part | पूर्ण झालेला output_text भाग. |
response.output_item.done | output_index, item | पूर्ण झालेला message आयटम, स्टेटस completed सह. |
response.output_item.added | output_index, item | टूल कॉल सुरू होतो: call_id, name आणि रिकामे arguments असलेला function_call आयटम. |
response.function_call_arguments.delta | output_index, delta | कॉलची आर्ग्युमेंट्स, एकाच डेल्टामध्ये पूर्ण. |
response.function_call_arguments.done | output_index, arguments | तीच आर्ग्युमेंट्स, arguments म्हणून. |
response.output_item.done | output_index, item | पूर्ण झालेला function_call आयटम. |
response.completed | response | यशस्वी झाल्यास नेहमी शेवटी: output आणि usage सह संपूर्ण रिस्पॉन्स ऑब्जेक्ट. |
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}, …}} अयशस्वी होणारा स्ट्रीम
Shannon टियर्सवर अयशस्वी उत्तर response.completed ऐवजी response.failed ने संपते. त्याचे response.status failed असते आणि response.error मध्ये code, rate_limit_exceeded किंवा server_error, आणि message असते.
होस्ट केलेल्या open-weight मॉडेल्सवर अपयश म्हणजे code api_error आणि message असलेला error इव्हेंट. त्यानंतरही response.completed येतो.
स्ट्रीममध्ये response.failed किंवा error इव्हेंट असल्यास तो अयशस्वी समजा आणि रिक्वेस्ट पुन्हा पाठवा.
टूल्स
टूल म्हणजे तुमचा कोड चालवणारे फंक्शन. ते tools मध्ये वर्णन करा; मॉडेलला ते हवे असेल तेव्हा उत्तरात संदेशाच्या जागी किंवा त्याच्या शेजारी function_call आयटम असतो.
tools मधील टूल व्याख्या:
[
{
"type": "function",
"name": "get_weather",
"description": "Current weather for a city.",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": [
"city"
]
}
}
] तो कॉल करणाऱ्या उत्तराचा output:
[
{
"id": "call_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
"type": "function_call",
"name": "get_weather",
"call_id": "call_3d9a7c1e5b2f4a60c8e1d7f09b24a6c5",
"arguments": "{\"city\":\"Paris\"}"
}
] फंक्शन चालवा, मग कॉल आणि त्याचा निकाल 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\"}"
}
] फक्त function प्रकारची टूल्स वाचली जातात. shannon-1.6-*, shannon-2-* आणि shannon-coder-1 वर parameters स्कीमा सामान्य JSON Schema कीवर्ड्सपर्यंत कमी केला जातो: oneOf हे anyOf म्हणून वाचले जाते, आणि $ref, additionalProperties, const, default व title सारखे कीवर्ड्स मॉडेलला दिले जात नाहीत.
tool_choice ची required आणि नाव दिलेले फंक्शन ही मूल्ये होस्ट केलेली open-weight मॉडेल्स लागू करतात.
टूल लूपचे संपूर्ण वर्णन स्वतःच्या पानावर आहे. फंक्शन कॉलिंग
स्ट्रक्चर्ड आउटपुट
हा फॉरमॅट स्ट्रक्चर्ड आउटपुट text.format म्हणून लिहितो. स्कीमा थेट format मध्ये, name आणि strict शेजारी असतो; Chat Completions प्रमाणे json_schema सदस्याखाली नाही.
{"type": "json_object"}कोणताही JSON ऑब्जेक्ट मागते.{"type": "json_schema", "name", "schema", "strict"}तुमच्या स्कीमाचे पालन करणारा JSON मागते. तुम्ही वगळल्यासstricttrueअसते.
{
"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"
]
}
}
}
} JSON संदेशाच्या output_text भागात मजकूर म्हणून येतो; तो स्वतः पार्स करा. स्ट्रक्चर्ड आउटपुट नसलेले होस्ट केलेले open-weight मॉडेल 400 परत करते.
{"city": "Lisbon", "date": "2027-05-12"} कोणते मॉडेल कोणता प्रकार घेते ते स्वतःच्या पानावर दिले आहे. संरचित आउटपुट्स
रीझनिंग
रीझनिंग करणारे मॉडेल आपले रीझनिंग संदेशाच्या आधी reasoning प्रकारचा आउटपुट आयटम म्हणून परत देते. स्ट्रीममध्ये ते response.reasoning_summary_text.delta इव्हेंट्स म्हणून येते.
होस्ट केलेली open-weight मॉडेल्स reasoning.effort लागू करतात: off, low, medium किंवा high, तुम्ही काही न पाठवल्यास high. off रीझनिंग आयटम देत नाही. ते ऑब्जेक्ट म्हणून पाठवा; या एंडपॉइंटवर साधी स्ट्रिंग वाचली जात नाही.
Effort चे स्तर स्वतःच्या पानावर वर्णन केले आहेत. रीझनिंग effort
आउटपुट मर्यादा
तुम्ही न पाठवल्यास max_output_tokens 4,096 असते. रिक्वेस्ट सुरू होताना तुमच्या बॅलन्समधून राखून ठेवलेली ही टोकन्सची संख्या आहे; उत्तर पूर्ण झाल्यावर ती रक्कम रिक्वेस्टने वापरलेल्या रकमेने बदलली जाते. तुमच्या उरलेल्या बॅलन्समध्ये न बसणारे मूल्य 429 Quota exceeded परत करते.
ते shannon-1.6-*, shannon-2-* आणि shannon-coder-1 वर उत्तराची लांबी मर्यादित करते, आणि होस्ट केलेल्या open-weight मॉडेल्सवर उत्तराच्या मजकुराची लांबी.
या एंडपॉइंटवर shannon-coder-1 चे शुल्क इतर मॉडेल्सप्रमाणे तुमच्या बॅलन्समधून टोकन्समध्ये लागते.
रिक्वेस्ट बॉडी 32 MiB पर्यंत असू शकते. मर्यादा आणि बॅलन्स
त्रुटी
त्रुटी OpenAI एरर बॉडी वापरतात: type आणि message असलेला error ऑब्जेक्ट; काहींमध्ये null मूल्यासह code आणि param देखील असतात. तक्ता हा एंडपॉइंट सर्वाधिक वेळा काय परत करतो ते दाखवतो. काय पुन्हा करायचे यासह संपूर्ण यादीसाठी स्वतंत्र पान आहे. त्रुटी हाताळणी
| स्टेटस | प्रकार | संदेश | केव्हा |
|---|---|---|---|
401 | authentication_error | Missing authenticationInvalid API key | API की पाठवली नाही, किंवा की अज्ञात आहे किंवा रद्द केली आहे. |
400 | invalid_request_error | unknown model: <id> | model नाही किंवा प्रकाशित id नाही. |
400 | invalid_request_error | No user message provided. | Shannon टियर्स: input मध्ये वापरकर्त्याचा मजकूर नाही. |
400 | invalid_request_error | <id> does not accept image input | इमेज इनपुट नसलेल्या होस्ट केलेल्या open-weight मॉडेलला इमेज पाठवली. |
400 | invalid_request_error | <id> does not accept response_format | स्ट्रक्चर्ड आउटपुट नसलेल्या होस्ट केलेल्या open-weight मॉडेलला text.format पाठवले. |
400 | invalid_request_error | unknown reasoning effort '<value>'; expected off, low, medium or high | reasoning.effort मध्ये यादीबाहेरचे मूल्य आहे. |
422 | invalid_request_error | Failed to deserialize the JSON body into the target type: … | बॉडी वैध JSON आहे पण एखाद्या फील्डचा प्रकार चुकीचा आहे. |
429 | rate_limit_error | Quota exceeded. Upgrade your plan at shannon-ai.com/plan | max_output_tokens तुमच्या उरलेल्या बॅलन्सपेक्षा मोठे आहे. |
429 | rate_limit_error | Too many requests. Retry in <n>s. | फ्लड प्रोटेक्शन: तुमच्या अकाउंटवर एका मिनिटात 120 पेक्षा जास्त रिक्वेस्ट्स. |
500 | api_error | The model backend failed to answer. Please retry. | मॉडेलने उत्तर तयार केले नाही. रिक्वेस्ट पुन्हा पाठवा. |
502 | api_error | The model backend failed to answer. Please retry. | तेच, होस्ट केलेल्या open-weight मॉडेल्सवर. |
504 | api_error | upstream timed out | होस्ट केलेल्या open-weight मॉडेलला स्ट्रीम नसलेल्या उत्तराच्या वेळ मर्यादेपेक्षा जास्त वेळ लागला. stream true सेट करून पाठवा. |