ใช้ OpenAI Responses API สำหรับการสนทนา Responses API เป็นรูปแบบ API ล่าสุดของ OpenAI ที่มีอินพุตยืดหยุ่นมากขึ้น
/api/ai/v1/responsesBearer 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 --location 'https://your-domain.com/api/ai/v1/responses' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"model": "deepseek-v4.1-flash",
"input": "Hello, who are you?",
"max_tokens": 1000,
"temperature": 0.7
}'import requests
response = requests.post(
"https://your-domain.com/api/ai/v1/responses",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
},
json={
"model": "deepseek-v4.1-flash",
"input": "Hello, who are you?",
"max_tokens": 1000,
"temperature": 0.7
}
)
print(response.json())curl --location 'https://your-domain.com/api/ai/v1/responses' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"model": "deepseek-v4.1-flash",
"input": "Hello",
"max_tokens": 1000,
"stream": true
}'