top_p
but not both.temperature
but not both.data: [DONE]
message. Python code example.finish_reason="length"
, the message content may be partially truncated, indicating generation exceeded max_tokens or the conversation exceeded the maximum context length. Show properties.system_fingerprint
response parameter to monitor backend changes.none
means the model will not call a function but will generate a message. auto
means the model can choose between generating a message and calling a function. Forcing the model to call a function can be done with {"type": "function", "function": {"name": "my_function"}}. If no functions exist, the default is none
. If functions exist, the default is auto
. Show possible types.{
"model": "claude-3-5-sonnet-20240620",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image? Please describe it in detail."},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
}
]
}
],
"stream": false
}
curl --location --request POST '/v1/chat/completions' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "claude-3-5-sonnet-20240620",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image? Please describe it in detail."},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
}
]
}
],
"stream": false
}'
{
"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
}
}