ใช้ OpenAI Responses API สำหรับการสนทนา Responses API เป็นรูปแบบ API ล่าสุดของ OpenAI ที่มีอินพุตยืดหยุ่นมากขึ้น
Bearer YOUR_API_KEY| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
| model | string | จำเป็น | ชื่อโมเดล เช่น deepseek-v4.1-flash, qwen3.8-max |
| input | string | จำเป็น | ข้อความอินพุตหรือเนื้อหาการสนทนา |
| max_tokens | integer | ไม่บังคับ | จำนวนโทเค็นเอาต์พุตสูงสุด |
| temperature | float | ไม่บังคับ | อุณหภูมิการสุ่ม ควบคุมความสุ่ม (0-2) |
| stream | boolean | ไม่บังคับ | เปิดการตอบสนองแบบสตรีม ตั้งค่าเป็น true สำหรับ SSE |
| พารามิเตอร์ | ประเภท | คำอธิบาย |
|---|---|---|
| id | string | ตัวระบุการตอบสนองที่ไม่ซ้ำกัน |
| model | string | โมเดลที่ใช้จริง |
| output | string | เอาต์พุตข้อความที่สร้าง |
| usage | object | สถิติการใช้โทเค็น รวมถึง prompt_tokens, completion_tokens, total_tokens |
curl https://your-domain.com/api/ai/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "deepseek-v4.1-flash",
"input": "Hello, who are you?",
"max_tokens": 1000
}'