Given a hint, the model will return the completion of one or more predictions, and can also return the probability of the alternative label at each location.Completed creation based on the provided prompts and parametersOfficial documentation: https://docs.anthropic.com/en/api/messages
Request
Header Params
Body Params application/json
Example
{"model":"claude-sonnet-4-20250514","system":"You are an intelligent AI assistant named Xiao Wang","messages":[{"role":"user","content":"Who are you?!"}],"stream":true}
Request Code Samples
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl--location'/v1/messages' \
--header'Accept: application/json' \
--header'x-api-key: {{YOUR_API_KEY}}' \
--header'Content-Type: application/json' \
--data'{
"model": "claude-sonnet-4-20250514",
"system": "You are an intelligent AI assistant named Xiao Wang",
"messages": [
{
"role": "user",
"content": "Who are you?!"
}
],
"stream": true
}'
Responses
🟢200OK
application/json
Bodyapplication/json
Example
{"id":"chatcmpl-123","object":"chat.completion","created":1677652288,"choices":[{"index":0,"message":{"role":"assistant","content":"\n\nHello there, how may I assist you today?"},"finish_reason":"stop"}],"usage":{"prompt_tokens":9,"completion_tokens":12,"total_tokens":21}}