Chat (Text)
Konversations-Completions, mit oder ohne Streaming, mit oder ohne Tools.
Anfrage
POST /v1/chat/completions{
"messages": [
{ "role": "user", "content": "Explique le routage IA en une phrase." }
],
"model": null,
"routing_strategy": "auto",
"max_tokens": null,
"temperature": null,
"stream": false,
"tools": null,
"tool_choice": null
}Nur messages ist erforderlich. model und routing_strategy sind in Routing & Failover dokumentiert.
Antwort
{
"content": "Le routage IA choisit automatiquement le meilleur fournisseur disponible pour chaque appel.",
"finish_reason": "stop",
"model": "claude-opus-5",
"provider": "anthropic",
"input_tokens": 12,
"output_tokens": 18,
"tool_calls": null
}Streaming
Übergeben Sie "stream": true, um die Antwort im Format Server-Sent Events statt als einzelnen JSON-Block zu erhalten.
for await (const chunk of client.chat.completions.stream({
messages: [{ role: "user", content: "Compte jusqu'a 10." }],
})) {
process.stdout.write(chunk.delta);
}Tool-Aufrufe (Function Calling)
Stellen Sie tools bereit (Definitionen im Standard-JSON-Schema-Format), und das Modell kann mit tool_calls anstelle von (oder zusätzlich zu) Text antworten. Senden Sie das Ergebnis in einer Nachricht mit der Rolle "tool" und der entsprechenden tool_call_id zurück, um die Konversation fortzusetzen.
{
"messages": [
{ "role": "user", "content": "Quel temps fait-il a Paris ?" },
{
"role": "assistant",
"content": "",
"tool_calls": [
{ "id": "call_1", "name": "get_weather", "arguments": { "city": "Paris" } }
]
},
{ "role": "tool", "tool_call_id": "call_1", "content": "18C, nuageux" }
],
"tools": [
{
"name": "get_weather",
"description": "Meteo actuelle d'une ville.",
"parameters": {
"type": "object",
"properties": { "city": { "type": "string" } },
"required": ["city"]
}
}
]
}Kompatible Modelle
Anthropic (Claude), OpenAI (GPT), Google (Gemini), DeepSeek, xAI (Grok), Mistral, Moonshot, MiniMax, Meta — die genaue, aktuelle Liste ist über den Katalog verfügbar:
GET /v1/models?category=text