---
title: "Create a Message"
method: POST
path: "/v1/messages"
---

# Create a Message

`POST /v1/messages`

Send a structured list of input messages with text and/or image content, and Claude Sonnet 5 will generate the next message in the conversation.

## Request body

- object
  - `model` 'claude-sonnet-5', required — Model ID.
  - `messages` object[], required — Input messages. Each message has a role and content.
    - `role` 'user' | 'assistant', required — The role of the message author.
    - `content` union, required — The content of the message. Either a string or an array of content blocks.
      - string
      - object[]
        - `type` 'text' | 'image'
        - `text` string
        - `source` object
          - `type` string
          - `media_type` string
          - `data` string
  - `max_tokens` integer, required — The maximum number of tokens to generate before stopping. Claude Sonnet 5 supports up to 128K output tokens.
  - `system` union — System prompt. Provides context and instructions to Claude.
    - string
    - object[]
      - `type` string
      - `text` string
  - `metadata` object — An object describing metadata about the request.
    - `user_id` string — An external identifier for the user who is associated with the request.
  - `stop_sequences` string[] — Custom text sequences that will cause the model to stop generating.
  - `temperature` number — Amount of randomness injected into the response. On Claude Sonnet 5, non-default values return a 400 error.
  - `top_p` number — Use nucleus sampling. On Claude Sonnet 5, non-default values return a 400 error.
  - `top_k` integer — Only sample from the top K options for each subsequent token. On Claude Sonnet 5, non-default values return a 400 error.
  - `stream` boolean — Whether to incrementally stream the response using server-sent events.
  - `tools` object[] — Definitions of tools that the model may use.
    - `name` string, required — Name of the tool.
    - `description` string — Description of what the tool does.
    - `input_schema` object, required — JSON Schema for the tool input.
  - `tool_choice` object — How the model should use the provided tools.
    - `type` 'auto' | 'any' | 'tool' — How the model should use the provided tools.
    - `name` string — The name of the tool to use (when type is "tool").
  - `output_config` object — Output controls for models that support adaptive thinking effort.
    - `effort` 'low' | 'medium' | 'high' | 'xhigh' | 'max' — Controls adaptive thinking depth and token usage. Claude Sonnet 5 defaults to high.
  - `thinking` object — Adaptive thinking configuration. Claude Sonnet 5 uses adaptive thinking by default; use output_config.effort to control depth. Manual extended thinking is not supported.
    - `type` 'adaptive' | 'disabled' — Whether to explicitly use adaptive thinking or disable thinking.

## Response `200`

Message created successfully

- Message
  - `id` string, required
  - `type` string, required
  - `role` string, required
  - `content` object[], required
    - `type` 'text' | 'thinking' | 'tool_use'
    - `text` string
    - `thinking` string
    - `id` string
    - `name` string
    - `input` object
  - `model` string, required
  - `stop_reason` string, required — Includes `refusal` for requests that the model declines.
  - `stop_sequence` string, nullable
  - `usage` object, required
    - `input_tokens` integer
    - `output_tokens` integer
    - `cache_creation_input_tokens` integer
    - `cache_read_input_tokens` integer

## Other responses

- `400` — Invalid request
- `401` — Unauthorized
- `429` — Rate limit exceeded

---

[API](https://skmtc.net/anyfast/apis/anthropic-claude-compatible-endpoint.md) · [All operations](https://skmtc.net/anyfast/apis/anthropic-claude-compatible-endpoint/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/anyfast/anthropic-claude-compatible-endpoint/revisions/edfc53e182a1/schema)
