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

# Create a message

`POST /v1/messages`

Mirrors Anthropic's Messages API so Anthropic SDKs and agents run against Morph models by changing the base URL and API key only — request and response shapes are unchanged. Set `stream: true` to receive the message as a `text/event-stream` of Anthropic-style events; the 200 response below documents the non-streaming shape.

## Request body

- AnthropicMessageRequest — Anthropic-shaped Messages request served by a Morph model.
  - `model` string, required — ID of the Morph model to use
  - `max_tokens` integer, required — Maximum number of tokens to generate before stopping
  - `messages` object[], required — Conversation turns, alternating between user and assistant, oldest first
    - `role` 'user' | 'assistant', required — Which participant produced this Messages API turn
    - `content` string, required — The text content of the message
  - `system` string — System prompt applied ahead of the conversation
  - `stream` boolean — Enable streaming response. When true the response is a `text/event-stream` of Anthropic-style `message_start`, `content_block_delta`, and `message_stop` events.
  - `temperature` number — Sampling temperature for the Messages request (0.0 for deterministic output)

## Response `200`

Message response

- AnthropicMessageResponse — Anthropic-shaped Messages response produced by a Morph model.
  - `id` string, required — Unique identifier for the message
  - `type` 'message', required — Object type, always `message`
  - `role` 'assistant', required — The role of the message author, always `assistant` on a response
  - `content` object[], required — Content blocks generated by the model
    - `type` 'text', required — Content block type, always `text`
    - `text` string, required — The generated text
  - `model` string, required — ID of the model that produced the message
  - `stop_reason` 'end_turn' | 'max_tokens' | 'stop_sequence', required — Why the model stopped generating tokens
  - `usage` object, required — Token usage for the message
    - `input_tokens` integer, required — Number of input tokens counted for this message
    - `output_tokens` integer, required — Number of output tokens generated for this message

## Other responses

- `400` — Malformed request — missing or invalid fields.
- `401` — Missing or invalid API key.
- `429` — Rate limited — retry after the interval in the Retry-After header.
- `500` — Internal error — safe to retry with backoff.

---

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