Sử dụng OpenAI Responses API cho hội thoại. Responses API là định dạng API OpenAI mới nhất với đầu vào linh hoạt hơn.
/api/ai/v1/responsesBearer YOUR_API_KEY| Tham số | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
model | string | Bắt buộc | Tên model, ví dụ deepseek-v4.1-flash, qwen3.8-max |
input | string | Bắt buộc | Văn bản đầu vào hoặc nội dung hội thoại |
max_tokens | integer | Tùy chọn | Số token đầu ra tối đa |
temperature | float | Tùy chọn | Nhiệt độ sampling, kiểm soát độ ngẫu nhiên (0-2) |
stream | boolean | Tùy chọn | Bật phản hồi streaming, đặt true cho SSE |
| Tham số | Kiểu | Mô tả |
|---|---|---|
id | string | Định danh phản hồi duy nhất |
model | string | Model thực tế được sử dụng |
output | string | Văn bản đầu ra được tạo |
usage | object | Thống kê sử dụng token, bao gồm 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
}'