Responses API Responses API Endpoint ที่รองรับ OpenAI Responses API สำหรับการสนทนาหลายรอบแบบ stateless, tool calling และอินพุต multimodal เหมาะสำหรับ agent และเฟรมเวิร์กที่ใช้ OpenAI Python SDK ≥ 1.x กับ client.responses.create()
POST /v1/responses
Note
รับการยืนยันตัวตนและการกำหนดเส้นทางโมเดลเดียวกับ Chat Completions
เนื้อความคำขอ modelจำเป็น
string
ใช้ id หรือ alias ที่แสดงใน GET /v1/models เช่น "claude-sonnet-4.6" หรือ "anthropic/claude-sonnet-4.6"
inputจำเป็น
string | Item[]
อินพุตผู้ใช้ — สตริงธรรมดา (ข้อความเดียว) หรืออาร์เรย์ของรายการอินพุตสำหรับการสนทนาหลายรอบ/multimodal
instructions
string
คำสั่งระดับระบบ เทียบเท่ากับข้อความระบบ ต้องส่งใหม่ทุกคำขอ
stream
boolean
ถ้า true จะส่งคืน Responses API SSE stream events ประเภทเหตุการณ์: response.created, response.output_text.delta, response.completed
max_output_tokens
integer
จำนวนโทเค็นเอาต์พุตสูงสุดที่จะสร้าง (รวมโทเค็นการใช้เหตุผลสำหรับโมเดล o-series)
temperature
number
ส่งค่าการสุ่มตัวอย่างโดยไม่ตรวจสอบช่วง โมเดลอาจจำกัดหรือไม่สนใจค่าที่อยู่นอกช่วงรองรับ
top_p
number
มวลความน่าจะเป็นการสุ่มตัวอย่าง Nucleus ค่าเริ่มต้น: 1
tools
Tool[]
คำจำกัดความเครื่องมือ (ฟังก์ชัน) — รูปแบบ JSON Schema เดียวกับ Chat Completions (รับทั้งรูปแบบแบนของ Responses และรูปแบบซ้อน) เครื่องมือโฮสต์ในตัวของ OpenAI เอง (web_search_preview, file_search, computer_use_preview) ไม่รองรับ; การค้นหาเว็บใช้ได้ผ่าน plugins: [{id:"web"}] — รองรับเฉพาะบางเส้นทางโมเดล
tool_choice
string | object
ควบคุมการใช้เครื่องมือ: "auto", "none" หรือเครื่องมือเฉพาะ
parallel_tool_calls
boolean
เปิดใช้งานการเรียกฟังก์ชันแบบขนานเมื่อมีเครื่องมือ ค่าเริ่มต้น: true ใช้ได้เฉพาะโมเดลตระกูล OpenAI เท่านั้น — ดูหมายเหตุด้านล่าง
response_format
object
บังคับเอาต์พุต JSON ที่มีโครงสร้าง ดูส่วน Structured Output
previous_response_id
string
เอนด์พอยต์นี้ไม่มีสถานะ — การส่งค่าที่ไม่ใช่ null จะคืนค่า 400 (invalid_prompt) ทันที ไม่เคยถูกยอมรับแล้วละเว้น ให้ใช้โหมด stateless แทน: ส่งประวัติการสนทนาเต็มในอาร์เรย์ input
Request Schema (TypeScript) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
type ResponsesRequest = {
model : string ;
input : string | InputItem [];
instructions ?: string ;
stream ?: boolean ;
max_output_tokens ?: number ;
temperature ?: number ;
top_p ?: number ;
tools ?: Tool [];
tool_choice ?: "auto" | "none" | "required" | object ;
parallel_tool_calls ?: boolean ;
previous_response_id ?: string ;
};
type InputItem =
| { type ?: "message" ; role : "user" | "assistant" | "system" | "developer" ; content : string | ContentBlock [] }
| { type : "function_call_output" ; call_id : string ; output : string }
| { type : "function_call" ; call_id : string ; name : string ; arguments : string };
type ContentBlock =
| { type : "input_text" ; text : string }
| { type : "input_image" ; image_url : string ; detail ?: "auto" | "low" | "high" };
⌄ ดูทั้งหมด 24 บรรทัดตัวอย่างคำขอ cURL Python Multi-turn Streaming
curl https://api.bazaarlink.ai/v1/responses \
-H "Authorization: Bearer $BAZAARLINK_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.4-mini",
"instructions": "You are a helpful assistant.",
"input": "What is the capital of Taiwan?"
}'
⌄ ดูทั้งหมด 8 บรรทัดรูปแบบการตอบกลับ BazaarLink ส่งคืน response แบบมาตรฐานและลบฟิลด์เฉพาะของ upstream ออก request ID แบบ opaque ของ BazaarLink ใน response ตรงกับ x-request-id ใช้ร่วมกับ GET /v1/generation response แบบ non-streaming จะส่ง ID เดียวกันใน x-generation-id ด้วย usage.cost คือจำนวนเงิน USD ที่เรียกเก็บจากลูกค้า สถิติอาจพร้อมใช้งานหลังเสร็จสิ้นไม่กี่วินาที หากได้ 404 ให้ลองซ้ำช่วงสั้นๆ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
type ResponsesResponse = {
id : string ;
object : "response" ;
created_at : number ;
completed_at : number ;
status : "completed" | "failed" | "incomplete" ;
model : string ;
output : OutputItem [];
usage : {
input_tokens : number ;
output_tokens : number ;
total_tokens : number ;
cost ?: number ;
} | null ;
error : null | { code : string ; message : string };
};
type OutputItem =
| {
type : "message" ;
id : string ;
role : "assistant" ;
status : "completed" ;
content : Array <{ type : "output_text" ; text : string ; annotations : [] }>;
}
| { type : "function_call" ; id : string ; call_id : string ; name : string ; arguments : string ; status : "completed" };
⌄ ดูทั้งหมด 27 บรรทัดย้ายจาก Chat Completions แทนที่ messages ด้วย input (สตริงหรืออาร์เรย์) ใช้ instructions แทนข้อความบทบาทระบบ และอ่าน output[0].content[0].text แทน choices[0].message.content
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
response = client.chat.completions.create(
model="openai/gpt-5.4-mini" ,
messages=[
{"role" : "system" , "content" : "You are helpful." },
{"role" : "user" , "content" : "Hello" },
]
)
text = response.choices[0 ].message.content
response = client.responses.create(
model="openai/gpt-5.4-mini" ,
instructions="You are helpful." ,
input ="Hello"
)
text = response.output[0 ].content[0 ].text
⌄ ดูทั้งหมด 17 บรรทัดข้อจำกัด previous_response_id หรือ store: true จะถูกปฏิเสธด้วย 400 (รหัสข้อผิดพลาด invalid_prompt) — ไม่ใช่ถูกยอมรับแล้วละเว้น ให้ใช้โหมด stateless เสมอ: ส่งประวัติการสนทนาเต็มในอาร์เรย์ input เครื่องมือโฮสต์ในตัวของ OpenAI เอง (web_search_preview, file_search, computer_use_preview) ไม่รองรับ การค้นหาเว็บใช้ได้ผ่าน plugins: [{id:"web"}] — รองรับเฉพาะบางเส้นทางโมเดล background: true ได้รับการยอมรับแต่ถูกละเว้น — ทุกคำขอทำงานแบบซิงโครนัสจนเสร็จสมบูรณ์เสมอ