استخدم OpenAI Chat Completions API للمحادثات. هذا هو تنسيق OpenAI chat API الكلاسيكي.
/api/ai/v1/chat/completionsBearer YOUR_API_KEY| المعلمة | النوع | مطلوب | الوصف |
|---|---|---|---|
model | string | مطلوب | اسم النموذج، مثل deepseek-v4.1-flash،qwen3.8-max |
messages | array | مطلوب | مصفوفة الرسائل بالتنسيق التالي |
max_tokens | integer | اختياري | الحد الأقصى لعدد التوكنز الناتجة |
temperature | float | اختياري | درجة الحرارة للعينة، تسيطر على العشوائية (0-2) |
stream | boolean | اختياري | مكن استجابة البث، اضبط على true لـ SSE |
| المعلمة | النوع | الوصف |
|---|---|---|
id | string | معرف الاستجابة الفريد |
model | string | النموذج المستخدم فعلياً |
choices | array | مصفوفة خيارات الاستجابة، عادةً خذ الخيار الأول |
usage | object | إحصائيات استخدام التوكنز |
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
}'