Chat Completions
Modellantworten für Konversationen generieren.
Endpunkt
POST
$ POST https://api.alltoken.ai/v1/chat/completionsAnfrage-Body
JSON
| 1 | { |
| 2 | "model": "deepseek-chat", |
| 3 | "messages": [ |
| 4 | { "role": "system", "content": "Sie sind ein hilfreicher Assistent." }, |
| 5 | { "role": "user", "content": "Hallo!" } |
| 6 | ], |
| 7 | "stream": false, |
| 8 | "temperature": 0.7, |
| 9 | "max_tokens": 1024 |
| 10 | } |
Parameter
model(erforderlich) — Modell-ID (z. B."deepseek-chat")messages(erforderlich) — Array von Nachrichtenobjekten mitroleundcontentstream—truefür SSE-Streaming,falsefür vollständige Antwort (Standard: false)temperature— Sampling-Temperatur, 0–2 (Standard: 1)top_p— Nucleus Sampling, 0–1 (Standard: 1)max_tokens— Maximale Anzahl generierter Tokensfrequency_penalty— Häufigkeitsstrafe, -2 bis 2 (Standard: 0)presence_penalty— Präsenzstrafe, -2 bis 2 (Standard: 0)tools— Array von Werkzeug-/Funktionsdefinitionenresponse_format—{"type": "json_object"}für garantierte JSON-Ausgabeweb_search—trueaktiviert Websuche (modellabhängig)
Nachrichtenrollen
system— Legt das Verhalten und den Kontext des Modells festuser— Nachrichten des Nutzersassistant— Frühere Modellantworten (für mehrstufige Gespräche)tool— Ergebnis eines Funktionsaufrufs (mittool_call_id)
Antwort
JSON
| 1 | { |
| 2 | "id": "chatcmpl-abc123", |
| 3 | "object": "chat.completion", |
| 4 | "created": 1700000000, |
| 5 | "model": "deepseek-chat", |
| 6 | "choices": [ |
| 7 | { |
| 8 | "index": 0, |
| 9 | "message": { |
| 10 | "role": "assistant", |
| 11 | "content": "Hallo! Wie kann ich Ihnen helfen?" |
| 12 | }, |
| 13 | "finish_reason": "stop" |
| 14 | } |
| 15 | ], |
| 16 | "usage": { |
| 17 | "prompt_tokens": 12, |
| 18 | "completion_tokens": 10, |
| 19 | "total_tokens": 22 |
| 20 | } |
| 21 | } |