Anthropic
Overview
Text Completions
post
Body
or
Responses
200Success
application/json
modelstringRequiredExample:
Model used to generate the response.
claude-sonnet-4-20250514idstringRequiredExample:
Unique identifier of the generated message.
msg_01SUmNmSRFZsoa6h96MxJEHHtypestringRequiredExample:
Object type.
messagerolestringRequiredExample:
Role of the message author.
assistantstop_reasonstring · nullableOptionalExample:
Reason why generation stopped.
end_turnstop_sequencestring · nullableOptional
Custom stop sequence that caused generation to stop.
stop_detailsany · nullableOptional
Additional details about why generation stopped.
post/v1/messages
curl -L \
--request POST \
--url 'https://api.aimlapi.com/v1/messages' \
--header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-sonnet-4-20250514",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'200Success
{
"model": "claude-sonnet-4-20250514",
"id": "msg_01SUmNmSRFZsoa6h96MxJEHH",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "I'm functioning well, thank you for asking! I'm ready to help you with any questions or tasks you might have. How can I assist you today?"
}
],
"stop_reason": "end_turn",
"stop_sequence": "text",
"stop_details": null,
"usage": {
"input_tokens": 27,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
"ephemeral_1h_input_tokens": 0
},
"output_tokens": 35,
"service_tier": "standard",
"inference_geo": "not_available"
},
"meta": {
"usage": {
"credits_used": 1576,
"usd_spent": 0.000788
}
}
}Example: Simple Text Response
Function Calling
Example: Get Weather Information
Streaming Mode
Batch Processing
Vision
Response Format
Last updated
Was this helpful?