---
title: "Create message"
method: POST
path: "/v1/messages"
---

# Create message

`POST /v1/messages`

Send a message to an Anthropic-compatible model and receive a response

## Headers

- `x-api-key` string, required
- `anthropic-version` string

## Request body

- MessageRequest
  - `model` string, required — The model to use for the completion
  - `max_tokens` integer, required — The maximum number of tokens to generate before stopping
  - `messages` AnthropicMessage[], required — Input messages
    - `role` 'user' | 'assistant', required — The role of the messages author
    - `content` union, required — The contents of the message
      - string
      - AnthropicContentBlock[]
        - union
          - AnthropicTextBlock
            - `type` 'text', required
            - `text` string, required
          - AnthropicImageBlock
            - `type` 'image', required
            - `source` AnthropicImageSource, required
              - …
          - AnthropicToolUseBlock
            - `type` 'tool_use', required
            - `id` string, required
            - `name` string, required
            - `input` object, required
          - AnthropicToolResultBlock
            - `type` 'tool_result', required
            - `tool_use_id` string, required
            - `content` union
              - …
            - `is_error` boolean
  - `system` string — System prompt to be used for the completion
  - `temperature` number — Amount of randomness injected into the response
  - `top_p` number — Use nucleus sampling
  - `top_k` integer — Only sample from the top K options for each subsequent token
  - `stream` boolean — Whether to incrementally stream the response using server-sent events
  - `stop_sequences` string[] — Custom text sequences that will cause the model to stop generating
  - `tools` AnthropicTool[] — Definitions of tools that the model may use
    - `type` 'custom' | 'web_search_20250305', required — The type of tool. Use `custom` (default, may be omitted) for user-defined tools with `name`, `description`, and `input_schema`. Use `web_search_20250305` to enable native Anthropic web search.
    - `name` string — The tool name. Required for `custom` tools. For `web_search_20250305`, set to `web_search`.
    - `description` string — For `custom` tools: describes when the model should use this tool.
    - `input_schema` object — For `custom` tools: JSON schema for the tool input.
    - `max_uses` integer — For `web_search_20250305`: maximum number of web searches the model may perform.
  - `tool_choice` union — How the model should use the provided tools
    - 'auto' | 'any'
    - AnthropicToolChoice
      - `type` 'tool', required
      - `name` string, required

## Response `200`

Message response

- MessageResponse
  - `id` string, required — Unique object identifier
  - `type` 'message', required — Object type
  - `role` 'assistant', required — Conversational role of the generated message
  - `content` AnthropicContentBlock[], required — Content generated by the model
    - union
      - AnthropicTextBlock
        - `type` 'text', required
        - `text` string, required
      - AnthropicImageBlock
        - `type` 'image', required
        - `source` AnthropicImageSource, required
          - `type` 'base64', required
          - `media_type` 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp', required
          - `data` string, required — Base64 encoded image data
      - AnthropicToolUseBlock
        - `type` 'tool_use', required
        - `id` string, required
        - `name` string, required
        - `input` object, required
      - AnthropicToolResultBlock
        - `type` 'tool_result', required
        - `tool_use_id` string, required
        - `content` union
          - string
          - AnthropicContentBlock[]
        - `is_error` boolean
  - `model` string, required — The model that handled the request
  - `stop_reason` 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use', required — The reason that we stopped
  - `stop_sequence` string — Which custom stop sequence was generated
  - `usage` AnthropicUsage, required
    - `input_tokens` integer, required — The number of input tokens which were used
    - `output_tokens` integer, required — The number of output tokens which were used

## Other responses

- `400` — Bad request - malformed payload or invalid parameters.
- `401` — Unauthorized - missing or empty Authorization header.
- `402` — Payment required - organization balance exhausted.
- `403` — Forbidden - invalid token or model not in access list.
- `404` — Not found - provider/model not supported.
- `429` — Rate limit exceeded. Retry after the Retry-After header value.
- `500` — Internal server error.
- `502` — Bad gateway - upstream provider returned an invalid response.

---

[API](https://skmtc.dev/requesty/apis/requesty-api.md) · [All operations](https://skmtc.dev/requesty/apis/requesty-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/requesty/requesty-api/revisions/63bc7d99ccde/schema)
