Använd OpenAI Chat Completions API för konversationer. Detta är det klassiska OpenAI-chatt-API-formatet.
/api/ai/v1/chat/completionsBearer YOUR_API_KEY| Parameter | Typ | Obligatorisk | Beskrivning |
|---|---|---|---|
model | string | Obligatoriskt | Modellnamn, t.ex. deepseek-v4.1-flash, qwen3.8-max |
messages | array | Obligatoriskt | Meddelandearray i formatet |
max_tokens | integer | Valfritt | Maximalt antal utdata-tokens |
temperature | float | Valfritt | Samplingtemperatur, styr slumpmässighet (0-2) |
stream | boolean | Valfritt | Aktivera strömmande svar, sätt till true för SSE |
| Parameter | Typ | Beskrivning |
|---|---|---|
id | string | Unikt svars-ID |
model | string | Faktisk modell som använts |
choices | array | Array med svarsalternativ, ta vanligtvis det första |
usage | object | Statistik över tokenanvändning |
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
}'