Skip to main content
POST
Create a message

Overview

POST /v1/messages mirrors Anthropic’s Messages API. Clients built on an Anthropic SDK switch to Morph by changing the base URL and API key — no request or response rewriting.
Model ids, prices, and context windows are served live at morphllm.com/api/models/json — fetch that rather than hardcoding. For OpenAI-style clients, use POST /v1/chat/completions instead; both routes serve the same models.

Authorizations

Authorization
string
header
required

Morph API key, passed as Authorization: Bearer sk-.... Create keys at https://www.morphllm.com/dashboard/api-keys.

Body

application/json

Anthropic-compatible message request

Anthropic-shaped Messages request served by a Morph model.

model
string
required

ID of the Morph model to use

Example:

"morph-glm52-744b"

max_tokens
integer
required

Maximum number of tokens to generate before stopping

Example:

1024

messages
object[]
required

Conversation turns, alternating between user and assistant, oldest first

Example:
system
string

System prompt applied ahead of the conversation

Example:

"You are a senior TypeScript engineer. Reply with code only."

stream
boolean
default:false

Enable streaming response. When true the response is a text/event-stream of Anthropic-style message_start, content_block_delta, and message_stop events.

Example:

false

temperature
number
default:0

Sampling temperature for the Messages request (0.0 for deterministic output)

Example:

0

Response

Message response

Anthropic-shaped Messages response produced by a Morph model.

id
string
required

Unique identifier for the message

Example:

"msg_01XFDUDYJgAACzvnptvVoYEL"

type
enum<string>
required

Object type, always message

Available options:
message
Example:

"message"

role
enum<string>
required

The role of the message author, always assistant on a response

Available options:
assistant
Example:

"assistant"

content
object[]
required

Content blocks generated by the model

Example:
model
string
required

ID of the model that produced the message

Example:

"morph-glm52-744b"

stop_reason
enum<string>
required

Why the model stopped generating tokens

Available options:
end_turn,
max_tokens,
stop_sequence
Example:

"end_turn"

usage
object
required

Token usage for the message

Example: