Чат (текст)

Завершения диалога, со стримингом или без, с инструментами или без них.

Запрос

http
POST /v1/chat/completions
json
{
  "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
}

Обязательным является только messages. model и routing_strategy описаны в разделе Маршрутизация и отказоустойчивость.

Ответ

json
{
  "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
}

Стриминг

Передайте "stream": true, чтобы получать ответ в формате Server-Sent Events вместо единого JSON-блока.

typescript
for await (const chunk of client.chat.completions.stream({
  messages: [{ role: "user", content: "Compte jusqu'a 10." }],
})) {
  process.stdout.write(chunk.delta);
}

Вызов инструментов (function calling)

Передайте tools (описания в стандартном формате JSON Schema), и модель сможет ответить с помощью tool_calls вместо текста (или вместе с ним). Верните результат в сообщении с ролью "tool" и соответствующим tool_call_id, чтобы продолжить диалог.

json
{
  "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"]
      }
    }
  ]
}
Для автоматизированной многошаговой оркестрации (сервер повторно вызывает модель после каждого результата инструмента, сохраняет долговременную память) см. руководство ИИ-агенты, вместо того чтобы управлять этим циклом самостоятельно.

Совместимые модели

Anthropic (Claude), OpenAI (GPT), Google (Gemini), DeepSeek, xAI (Grok), Mistral, Moonshot, MiniMax, Meta — точный и актуальный список доступен через каталог:

bash
GET /v1/models?category=text