---
title: "Create a message"
method: POST
path: "/messages"
tags: ["Inference"]
---

# Create a message

`POST /messages`

Generates a response based on input messages. Streaming mode is supported. This endpoint follows the Anthropic Messages API specification and is compatible with Claude models.

## Request body

- CreateMessageDto — Request body for `POST /v1/messages`. Follows Anthropic Messages API specification.
  - `model` string, required — The unique identifier of the Claude model to use (e.g., claude-3-5-sonnet-20241022, claude-3-opus-20240229).
  - `max_tokens` integer — The maximum number of tokens to generate in the completion.
  - `messages` AnthropicMessage[], required — Array of messages that form the conversation.
    - `role` 'user' | 'assistant' | 'system', required — The role of the message sender.
    - `content` union, required — The content of the message.
      - string
      - ContentBlock[] — Array of content blocks (text, images, etc.).
        - `type` 'text' | 'image', required — The type of content block.
        - `text` string — Text content (for type 'text').
        - `source` object — Image source data (for type 'image').
          - `type` 'base64', required
          - `media_type` string, required — The media type of the image (e.g., 'image/jpeg').
          - `data` string, required — Base64-encoded image data.
    - `stop_reason` string — The reason the generation stopped (e.g., `stop`, `max_tokens`, `tool_use`).
    - `stop_sequence` string — The specific stop sequence that was encountered.
    - `usage` MessageUsage — Token usage statistics for the message.
      - `input_tokens` integer, required — Number of tokens in the input.
      - `output_tokens` integer, required — Number of tokens in the output.
    - `tool_use` ToolUse — Information about a tool use request from the model.
      - `id` string, required — A unique identifier for this tool use.
      - `name` string, required — The name of the tool being called.
      - `input` object, required — The arguments for the tool.
  - `system` string — Optional system instructions that guide the model's behavior.
  - `temperature` number — Adjusts randomness of the output (0.0 - 1.0).
  - `top_p` number — Nucleus sampling cutoff (0.0 - 1.0).
  - `top_k` integer — Restricts sampling to the K most probable tokens.
  - `stop_sequences` string[] — Stop sequences – generation stops before emitting any of these strings.
  - `stream` boolean — If true, the server streams tokens as they are generated.
  - `anthropic_version` string — The version of the Anthropic API to use.
  - `tools` Tool[] — List of tools the model may call.
    - `name` string, required — The name of the tool.
    - `description` string, required — A description of what the tool does.
    - `input_schema` object, required — JSON schema defining the tool's input parameters.
  - `tool_choice` object — Controls which tool is called.
    - `type` 'auto' | 'any' | 'tool' — How the model chooses which tool to call.
    - `name` string — The name of the tool to use.
  - `metadata` object — Optional metadata to include in the response.
    - `user_id` string — A unique identifier for the end-user.
    - `tags` string[] — Tags to apply to the message.

## Response `200`

Message creation result

- MessageResponseDto — Response from `POST /v1/messages` following Anthropic Messages API format.
  - `id` string, required — A unique identifier for the message.
  - `type` 'message', required — The type of the response.
  - `role` 'assistant', required — The role of the assistant.
  - `content` ContentBlock[], required — Array of content blocks in the response.
    - `type` 'text' | 'image', required — The type of content block.
    - `text` string — Text content (for type 'text').
    - `source` object — Image source data (for type 'image').
      - `type` 'base64', required
      - `media_type` string, required — The media type of the image (e.g., 'image/jpeg').
      - `data` string, required — Base64-encoded image data.
  - `stop_reason` string, required — The reason the generation stopped.
  - `stop_sequence` string — The specific stop sequence that was encountered.
  - `usage` MessageUsage, required — Token usage statistics for the message.
    - `input_tokens` integer, required — Number of tokens in the input.
    - `output_tokens` integer, required — Number of tokens in the output.
  - `model` string, required — The model used for generation.
  - `cache_control` object — Optional cache control information.
  - `billing` object — Optional billing information.

## Changes

- **2026-01-28** `a377f697eedf` — 1 info
  - endpoint added
- **2025-09-19** `97bc26aa608a` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/janhq/apis/jan-api-server-endpoints/changes/messages/post.md)

---

[API](https://skmtc.dev/janhq/apis/jan-api-server-endpoints.md) · [All operations](https://skmtc.dev/janhq/apis/jan-api-server-endpoints/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/janhq/jan-api-server-endpoints/revisions/8e64bd346c2f/schema)
