Migrating from Text Completions to Messages
role
and content
.
\n\nHuman:
and \n\nAssistant:
turns, but the Messages API expects user
and assistant
roles. You may see documentation referring to either “human” or “user” turns. These refer to the same role, and will be “user” going forward.completion
values of the response:
content
value, which is a list of content blocks:
assistant
role:
content
will continue from the last input message content
:
\n\nHuman:
turn:
system
parameter:
claude-sonnet-4-20250514
).
We previously supported specifying only the major version number (e.g. claude-2
), which resulted in automatic upgrades to minor versions. However, we no longer recommend this integration pattern, and Messages do not support it.
stop_reason
of either:
"stop_sequence"
: The model either ended its turn naturally, or one of your custom stop sequences was generated."max_tokens"
: Either the model generated your specified max_tokens
of content, or it reached its absolute maximum.stop_reason
of one of the following values:
"end_turn"
: The conversational turn ended naturally."stop_sequence"
: One of your specified custom stop sequences was generated."max_tokens"
: (unchanged)max_tokens_to_sample
parameter. No validation, but capped values per-model.max_tokens
parameter. If passing a value higher than the model supports, returns a validation error."stream": true
in with Text Completions, the response included any of completion
, ping
, and error
server-sent-events.
Messages can contain multiple content blocks of varying types, and so its streaming format is somewhat more complex. See Messages streaming for details.