Messages(识图)
方法: POST路径: /v1/messages
请求参数
Header 参数
text
Authorization
string
可选
默认值:
Bearer {{YOUR_API_KEY}}Body 参数 application/json
text
object
示例
{
"model"
:
"claude-3-5-sonnet-20240620"
,
"max_tokens"
:
1024
,
"messages"
:
[
{
"role"
:
"user"
,
"content"
:
[
{
"type"
:
"image"
,
"source"
:
{
"type"
:
"base64"
,
"media_type"
:
"image/jpeg"
,
"data"
:
"/9j/4AAQSkZJRg..."
// base64 data; 仅支持 base64 传递图片
}
}
,
{
"type"
:
"text"
,
"text"
:
"What is in this image?"
}
]
}
]
}请求示例代码
Shell
bash
curl --location --request POST '/v1/messages' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "claude-3-5-sonnet-20240620",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "/9j/4AAQSkZJRg..." // base64 data; 仅支持 base64 传递图片
}
},
{
"type": "text",
"text": "What is in this image?"
}
]
}
]
}'返回响应
🟢 200 成功
内容类型: application/json
响应结构
text
object示例
json
{}