Usa OpenAI Chat Completions API per le conversazioni. Questo è il formato classico dell'API chat OpenAI.
/api/ai/v1/chat/completionsBearer YOUR_API_KEY| Parametro | Tipo | Obbligatorio | Descrizione |
|---|---|---|---|
model | string | Obbligatorio | Nome del modello, ad es. deepseek-v4.1-flash, qwen3.8-max |
messages | array | Obbligatorio | Array di messaggi nel formato seguente |
max_tokens | integer | Opzionale | Numero massimo di token di output |
temperature | float | Opzionale | Temperatura di campionamento, controlla la casualità (0-2) |
stream | boolean | Opzionale | Abilita la risposta in streaming, imposta su true per SSE |
| Parametro | Tipo | Descrizione |
|---|---|---|
id | string | Identificatore univoco della risposta |
model | string | Modello effettivamente utilizzato |
choices | array | Array di scelte di risposta, di solito prendi la prima |
usage | object | Statistiche sull'utilizzo dei 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
}'