Sử dụng OpenAI Chat Completions API cho hội thoại. Đây là định dạng API chat cổ điển của OpenAI.
/api/ai/v1/chat/completionsBearer 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 |
messages | array | Bắt buộc | Mảng tin nhắn có định dạng |
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 | Mô hình thực tế được sử dụng |
choices | array | Mảng các lựa chọn phản hồi, thường lấy cái đầu tiên |
usage | object | Thống kê sử dụng token |
curl --location 'https://your-domain.com/api/ai/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"model": "deepseek-v4.1-flash",
"messages": [
{"role": "user", "content": "Hello, who are you?"}
],
"max_tokens": 1000,
"temperature": 0.7
}'import requests
response = requests.post(
"https://your-domain.com/api/ai/v1/chat/completions",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
},
json={
"model": "deepseek-v4.1-flash",
"messages": [
{"role": "user", "content": "Hello, who are you?"}
],
"max_tokens": 1000,
"temperature": 0.7
}
)
print(response.json())curl --location 'https://your-domain.com/api/ai/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"model": "deepseek-v4.1-flash",
"messages": [{"role": "user", "content": "Hello"}],
"max_tokens": 1000,
"stream": true
}'