cURL
CLI
Python
TypeScript
C#
Go
Java
PHP
Ruby

message
=
anthropic.Anthropic().messages.create(
model
=
"claude-opus-5-5"
,
max_tokens
=
1024
,
messages
=
[{
"role"
:
"user"
,
"content"
:
"Hello, Claude"
}],
)
print
(message)
Output

{
"id"
:
"msg_01XFDUDYJgAACzvnptvVoYEL"
,
"type"
:
"message"
,
"role"
:
"assistant"
,
"content"
: [
{
"type"
:
"text"
,
"text"
:
"Hello!"
}
],
"model"
:
"claude-opus-5-5"
,
"stop_reason"
:
"end_turn"
,
"stop_sequence"
:
null
,
"usage"
: {
"input_tokens"
:
12
,
"output_tokens"
:
6
}
}
Refusal responses (
stop_reason: "refusal"
) also include a
stop_details
object identifying the policy category that triggered the refusal, on every model. See
Handling stop reasons
for the field reference and example handling code.
