---
title: "Создать сообщение (Anthropic Messages API)"
method: POST
path: "/v1/messages"
tags: ["Messages"]
---

# Создать сообщение (Anthropic Messages API)

`POST /v1/messages`

## Request

- Base URL: `https://api.hubris.pw`
- URL: `https://api.hubris.pw/v1/messages`
- Auth: one of:
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://api.hubris.pw/oauth/authorize`, token URL `https://api.hubris.pw/oauth/token`, scopes: `chat:write`)

Anthropic-совместимый endpoint. Принимает как Anthropic-имена моделей
(`claude-sonnet-4-5`, `claude-3-5-sonnet-20241022`, `claude-haiku-4-5-latest`),
так и каноничные (`anthropic/claude-sonnet-4.6`). Поддерживает Bearer и
x-api-key заголовки. Используется Claude Code и любыми Anthropic SDK
через `ANTHROPIC_BASE_URL=https://api.hubris.pw`.

При `stream: true` — Server-Sent Events в нативном Anthropic-формате
(`message_start` / `content_block_*` / `message_delta` / `message_stop`).

Privacy Mode на этом эндпоинте не поддерживается. Для маскирования PII
используйте `/v1/chat/completions`.

## Request body

- AnthropicMessagesRequest
  - `model` string, required: Имя модели. Принимаются и Anthropic-имена (`claude-sonnet-4-5`, `claude-3-5-sonnet-20241022`, `claude-haiku-4-5-latest`), и каноничные OR-имена (`anthropic/claude-sonnet-4.6`). См. /docs/integrations/claude-code.
  - `models` string[]: Список резервных моделей (расширение Hubris). Если `model` отвечает 429/5xx или не начинает ответ вовремя — запрос уходит к следующей по порядку. Модель, не принимающая содержимое запроса (картинки, документы), пропускается. Биллинг по фактически ответившей модели.
  - `max_tokens` integer, required: Максимальное число токенов в ответе. Обязательное поле.
  - `messages` AnthropicMessage[], required: Массив сообщений диалога. Чередование ролей user/assistant.
    - `role` 'user' | 'assistant' | 'system', required
    - `content` union, required
      - string
      - AnthropicContentBlock[]
        - union
          - AnthropicTextBlock
            - `type` 'text', required
            - `text` string, required
            - `cache_control` AnthropicCacheControl
              - …
            - `citations` object[]
              - …
          - AnthropicImageBlock
            - `type` 'image', required
            - `source` union, required
              - …
            - `cache_control` AnthropicCacheControl
              - …
          - AnthropicToolUseBlock
            - `type` 'tool_use', required
            - `id` string, required
            - `name` string, required
            - `input` unknown
            - `cache_control` AnthropicCacheControl
              - …
          - AnthropicToolResultBlock
            - `type` 'tool_result', required
            - `tool_use_id` string, required
            - `content` union
              - …
            - `is_error` boolean
            - `cache_control` AnthropicCacheControl
              - …
          - AnthropicDocumentBlock
            - `type` 'document', required
            - `source` object, required
            - `title` string
            - `context` string
            - `citations` object
            - `cache_control` AnthropicCacheControl
              - …
          - AnthropicThinkingBlock
            - `type` 'thinking', required
            - `thinking` string, required
            - `signature` string
          - AnthropicRedactedThinkingBlock
            - `type` 'redacted_thinking', required
            - `data` string, required
          - object
            - `type` string, required
  - `system` union: Системный промпт. Строка или массив text-блоков (для гибкого cache_control).
    - string
    - AnthropicTextBlock[]
      - `type` 'text', required
      - `text` string, required
      - `cache_control` AnthropicCacheControl
        - `type` 'ephemeral', required
        - `ttl` '5m' | '1h'
      - `citations` object[]
  - `metadata` object
    - `user_id` string
  - `stop_sequences` string[]
  - `stream` boolean
  - `temperature` number
  - `top_p` number
  - `top_k` integer
  - `tools` union[]
    - union
      - AnthropicServerTool
        - `type` string, required
        - `name` string, required
        - `max_uses` integer
        - `allowed_domains` string[]
        - `blocked_domains` string[]
        - `user_location` object
        - `cache_control` AnthropicCacheControl
          - `type` 'ephemeral', required
          - `ttl` '5m' | '1h'
      - AnthropicTool
        - `name` string, required
        - `description` string
        - `input_schema` object, required
        - `cache_control` AnthropicCacheControl
          - `type` 'ephemeral', required
          - `ttl` '5m' | '1h'
        - `type` string
  - `tool_choice` union
    - object
      - `type` 'auto', required
      - `disable_parallel_tool_use` boolean
    - object
      - `type` 'any', required
      - `disable_parallel_tool_use` boolean
    - object
      - `type` 'tool', required
      - `name` string, required
      - `disable_parallel_tool_use` boolean
    - object
      - `type` 'none', required
  - `thinking` object: Extended thinking (Claude 4+). enabled + budget_tokens — бюджет на размышления; adaptive — режим Claude 5.
    - `type` 'enabled' | 'disabled' | 'adaptive', required
    - `budget_tokens` integer
  - `service_tier` string

## Response `200`

Успешный ответ. При `stream: false` — JSON. При `stream: true` — `text/event-stream`.

- AnthropicMessagesResponse
  - `id` string, required
  - `type` 'message', required
  - `role` 'assistant', required
  - `content` AnthropicContentBlock[], required
    - union
      - AnthropicTextBlock
        - `type` 'text', required
        - `text` string, required
        - `cache_control` AnthropicCacheControl
          - `type` 'ephemeral', required
          - `ttl` '5m' | '1h'
        - `citations` object[]
      - AnthropicImageBlock
        - `type` 'image', required
        - `source` union, required
          - object
            - `type` 'base64', required
            - `media_type` 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp', required
            - `data` string, required
          - object
            - `type` 'url', required
            - `url` string, uri, required
        - `cache_control` AnthropicCacheControl
          - `type` 'ephemeral', required
          - `ttl` '5m' | '1h'
      - AnthropicToolUseBlock
        - `type` 'tool_use', required
        - `id` string, required
        - `name` string, required
        - `input` unknown
        - `cache_control` AnthropicCacheControl
          - `type` 'ephemeral', required
          - `ttl` '5m' | '1h'
      - AnthropicToolResultBlock
        - `type` 'tool_result', required
        - `tool_use_id` string, required
        - `content` union
          - string
          - union[]
            - union
              - …
        - `is_error` boolean
        - `cache_control` AnthropicCacheControl
          - `type` 'ephemeral', required
          - `ttl` '5m' | '1h'
      - AnthropicDocumentBlock
        - `type` 'document', required
        - `source` object, required
        - `title` string
        - `context` string
        - `citations` object
        - `cache_control` AnthropicCacheControl
          - `type` 'ephemeral', required
          - `ttl` '5m' | '1h'
      - AnthropicThinkingBlock
        - `type` 'thinking', required
        - `thinking` string, required
        - `signature` string
      - AnthropicRedactedThinkingBlock
        - `type` 'redacted_thinking', required
        - `data` string, required
      - object
        - `type` string, required
  - `model` string, required
  - `stop_reason` 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'pause_turn' | 'refusal', nullable, required
  - `stop_sequence` string, nullable, required
  - `usage` AnthropicResponseUsage, required
    - `input_tokens` integer, required
    - `output_tokens` integer, required
    - `cache_creation_input_tokens` integer, nullable
    - `cache_read_input_tokens` integer, nullable
    - `cache_creation` unknown
    - `service_tier` string, nullable
    - `server_tool_use` unknown
  - `container` unknown

## Other responses

- `400`: Невалидное тело
- `401`: Невалидный API-ключ
- `402`: Недостаточно средств
- `404`: Модель не найдена
- `429`: Превышен дневной лимит ключа
- `502`: Ошибка апстрима
- `503`: Курс ЦБ РФ недоступен
- `504`: Таймаут апстрима

---

[API](https://skmtc.dev/hubris/apis/hubris-api.md) · [All operations](https://skmtc.dev/hubris/apis/hubris-api/llms.txt) · [OpenAPI document](https://skmtc.dev/hubris/apis/hubris-api/revisions/79ea91ed8f10?raw)
