Hubris
API Reference

POST /v1/chat/completions

Создать chat completion. OpenAI-совместимый формат, поддержка стриминга, tool calling, structured outputs.

POST /v1/chat/completions

Главный эндпоинт Hubris — создаёт ответ языковой модели на цепочку сообщений. OpenAI-совместимый формат — без переписывания работают openai Python SDK, OpenAI TypeScript SDK, LangChain, Vercel AI SDK и любые другие клиенты под OpenAI Chat Completions API.

Параметры и ответ

POST/v1/chat/completions

Authorization

AuthorizationRequiredBearer <token>

API-ключ в формате sk-gw- + 32 hex. Создаётся в дашборде на /keys.

In: header

Request Body

application/jsonRequired
modelRequiredstring
Minimum length: 1
messagesRequiredarray<object | object | object | object>
toolsarray<object>
tool_choiceAny properties in string,object
parallel_tool_callsboolean
response_formatobject | object | object
temperaturenumber
Minimum: 0Maximum: 2
top_pnumber
Minimum: 0Maximum: 1
ninteger
Minimum: 1
stopAny properties in string,array<string>
max_tokensinteger
Minimum: 0
max_completion_tokensinteger
Minimum: 0
frequency_penaltynumber
Minimum: -2Maximum: 2
presence_penaltynumber
Minimum: -2Maximum: 2
logit_biasobject
seedinteger
logprobsboolean
top_logprobsinteger
Minimum: 0Maximum: 20
streamboolean
stream_optionsobject
userstring
reasoning_effortstring
Value in: "low" | "medium" | "high"
curl -X POST "https://api.hubris.pw/v1/chat/completions" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-haiku-4.5",
    "messages": [
      {
        "role": "system",
        "content": "string",
        "name": "string"
      }
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "string",
          "description": "string",
          "parameters": {
            "property1": null,
            "property2": null
          },
          "strict": true
        }
      }
    ],
    "tool_choice": "none",
    "parallel_tool_calls": true,
    "response_format": {
      "type": "text"
    },
    "temperature": 2,
    "top_p": 1,
    "n": 1,
    "stop": "string",
    "max_tokens": 0,
    "max_completion_tokens": 0,
    "frequency_penalty": -2,
    "presence_penalty": -2,
    "logit_bias": {
      "property1": 0,
      "property2": 0
    },
    "seed": 0,
    "logprobs": true,
    "top_logprobs": 20,
    "stream": true,
    "stream_options": {
      "include_usage": true
    },
    "user": "string",
    "reasoning_effort": "low"
  }'

Успешный ответ. При stream: falsechat.completion. При stream: truetext/event-stream с chunk-ами chat.completion.chunk.

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 0,
  "model": "string",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "string",
        "tool_calls": [
          {
            "id": "string",
            "type": "function",
            "function": {
              "name": "string",
              "arguments": "string"
            }
          }
        ],
        "name": "string",
        "refusal": "string"
      },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "completion_tokens_details": {
      "reasoning_tokens": 0
    },
    "prompt_tokens_details": {
      "cached_tokens": 0
    }
  },
  "system_fingerprint": "string"
}

Минимальный пример

curl -s https://api.hubris.pw/v1/chat/completions \
  -H "Authorization: Bearer sk-gw-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-haiku-4.5",
    "messages": [{"role": "user", "content": "Привет"}]
  }'

Стриминг

Передайте stream: true, чтобы получить ответ chunk-ами в формате Server-Sent Events. Подробности — на странице Streaming.

curl -N -s https://api.hubris.pw/v1/chat/completions \
  -H "Authorization: Bearer sk-gw-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-haiku-4.5",
    "messages": [{"role": "user", "content": "Расскажи короткую историю"}],
    "stream": true
  }'

Tool calling

Передайте определения функций в tools, модель сможет их вызывать. Полная схема — в OpenAPI-блоке выше.

curl -s https://api.hubris.pw/v1/chat/completions \
  -H "Authorization: Bearer sk-gw-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-haiku-4.5",
    "messages": [{"role": "user", "content": "Какая погода в Москве?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Получить текущую погоду по городу",
        "parameters": {
          "type": "object",
          "properties": {"city": {"type": "string"}},
          "required": ["city"]
        }
      }
    }]
  }'

В ответе модель вернёт tool_calls вместо обычного content — выполните функцию у себя и отправьте результат вторым запросом с role: "tool".

Structured outputs

Передайте response_format: { type: "json_schema", json_schema: { name, schema } }, чтобы модель ответила строгим JSON по вашей схеме:

curl -s https://api.hubris.pw/v1/chat/completions \
  -H "Authorization: Bearer sk-gw-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-haiku-4.5",
    "messages": [{"role": "user", "content": "Дай данные о Москве в JSON"}],
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "name": "city_info",
        "schema": {
          "type": "object",
          "properties": {
            "name": {"type": "string"},
            "country": {"type": "string"},
            "population": {"type": "number"}
          },
          "required": ["name", "country", "population"]
        }
      }
    }
  }'

Vision

Модели с "image" в modalities (см. GET /v1/models) принимают изображения через image_url-блок:

curl -s https://api.hubris.pw/v1/chat/completions \
  -H "Authorization: Bearer sk-gw-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-haiku-4.5",
    "messages": [{
      "role": "user",
      "content": [
        {"type": "text", "text": "Что на картинке?"},
        {"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
      ]
    }]
  }'

URL может быть https://... или data:image/<mime>;base64,... — обе формы работают.

Что дальше

  • Streaming — формат SSE.
  • Ошибки — что бывает при сбое.
  • Цены — как считается стоимость запроса.