API Reference

Chat Completions

OpenAI-style request/response shape для документированных полей. Это не обещание полной parity со всем OpenAI API.

POST/vllm/v1/chat/completions

Создаёт ответ единственной публичной модели по истории messages.

Полный URL: https://api.42gpu.ru/vllm/v1/chat/completions

Обычный запрос

Все параметры →
Terminal
curl -sS https://api.42gpu.ru/vllm/v1/chat/completions \
  -H "Authorization: Bearer $GPU42_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Qwen/Qwen3.5-397B-A17B-FP8",
    "messages": [{"role": "user", "content": "Напиши короткое хокку о коде"}],
    "chat_template_kwargs": {"enable_thinking": false},
    "max_tokens": 256
  }'
Response200
{
  "id": "chatcmpl-…",
  "object": "chat.completion",
  "created": 1783900000,
  "model": "Qwen/Qwen3.5-397B-A17B-FP8",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Строки оживают…"
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 28,
    "completion_tokens": 15,
    "total_tokens": 43
  }
}

Ответ с reasoning

При включённом thinking черновое рассуждение приходит отдельно в reasoning_content. Оно входит в completion tokens и общий max_tokens.

Response200
{
  "id": "chatcmpl-…",
  "model": "Qwen/Qwen3.5-397B-A17B-FP8",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "reasoning_content": "Нужно вычислить произведение…",
      "content": "17 × 24 = 408."
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 96,
    "total_tokens": 114
  }
}

Если finish_reason=length, reasoning заполнен, а финальный content пуст, 42gpu добавляет diagnostic thinking_token_budget_exhausted и сохраняет reasoning.

Streaming (SSE)

Используйте stream: true. Обрабатывайте как delta.reasoning_content, так и delta.content; последний marker — data: [DONE].

Terminal
curl -N https://api.42gpu.ru/vllm/v1/chat/completions \
  -H "Authorization: Bearer $GPU42_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Qwen/Qwen3.5-397B-A17B-FP8",
    "messages": [{"role": "user", "content": "Почему небо синее?"}],
    "stream": true,
    "stream_options": {"include_usage": true},
    "max_tokens": 512
  }'
SSE (values abbreviated)
data: {"id":"chatcmpl-…","object":"chat.completion.chunk","model":"Qwen/Qwen3.5-397B-A17B-FP8","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"id":"chatcmpl-…","object":"chat.completion.chunk","model":"Qwen/Qwen3.5-397B-A17B-FP8","choices":[{"index":0,"delta":{"reasoning_content":"Сначала…"},"finish_reason":null}]}

data: {"id":"chatcmpl-…","object":"chat.completion.chunk","model":"Qwen/Qwen3.5-397B-A17B-FP8","choices":[{"index":0,"delta":{"content":"Синий цвет…"},"finish_reason":null}]}

data: {"id":"chatcmpl-…","object":"chat.completion.chunk","model":"Qwen/Qwen3.5-397B-A17B-FP8","choices":[],"usage":{"prompt_tokens":20,"completion_tokens":80,"total_tokens":100}}

data: [DONE]

Tool calling

Передайте function schema в tools. Выполняйте функцию только после собственной проверки name и JSON arguments, затем добавьте результат как message с ролью tool.

Request body
{
  "model": "Qwen/Qwen3.5-397B-A17B-FP8",
  "messages": [{"role": "user", "content": "Какая погода в Казани?"}],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Текущая погода в городе",
      "parameters": {
        "type": "object",
        "properties": {"city": {"type": "string"}},
        "required": ["city"]
      }
    }
  }],
  "tool_choice": "auto",
  "max_tokens": 512
}
Response200
{
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": null,
      "tool_calls": [{
        "id": "call_…",
        "type": "function",
        "function": {
          "name": "get_weather",
          "arguments": "{"city":"Казань"}"
        }
      }]
    },
    "finish_reason": "tool_calls"
  }]
}

Изображения и видео

Текущий multimodal deployment принимает image_url и video_url blocks. URL должен быть доступен upstream; размер, формат и количество медиа могут быть отклонены upstream.

Request body
{
  "model": "Qwen/Qwen3.5-397B-A17B-FP8",
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "Опиши медиа"},
      {"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}},
      {"type": "video_url", "video_url": {"url": "https://example.com/video.mp4"}}
    ]
  }],
  "max_tokens": 512
}

usage и идентификаторы

  • prompt_tokens — вход, completion_tokens — весь выход, включая reasoning, total_tokens — сумма.
  • Для streaming запросите stream_options.include_usage, если нужен финальный usage chunk.
  • Сохраняйте response headers X-Request-ID и X-42GPU-Request-ID для диагностики.