03
Content blocks
Each block has a type and the fields for that variant. Image and document inputs accept an uploaded file ID or inline data. Inline attachments must contain 1 byte to 8 MiB after decoding; standard base64 is required for binary data.
Text · type: text
text is a required string. Multiple text blocks are joined with newlines after any prompt.
{
"type": "text",
"text": "Describe what is in this image."
}Image · source.type: base64
source requires type: "base64", media_type and data. Accepted image media types are image/jpeg, image/png, image/gif and image/webp. Send the base64 bytes themselves in data.
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "<base64 image bytes>"
}
}An optional title becomes the attachment filename. Omission uses attachment with the matching file extension.
Document · source.type: base64
source requires type: "base64", media_type and data. Accepted document media types for this source are application/pdf and text/plain.
{
"type": "document",
"title": "report.pdf",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": "<base64 PDF bytes>"
}
}Document · source.type: text
Provide a plain-text document without base64 encoding. All three source fields are required; media_type must be "text/plain" and data must be a nonempty string.
{
"type": "document",
"title": "notes.txt",
"source": {
"type": "text",
"media_type": "text/plain",
"data": "Revenue grew by 12% this quarter."
}
}Image or document · source.type: file
Use type: "image" for an uploaded image, or type: "document" for an uploaded document. The source requires type: "file" and file_id. The stored file already carries its name and media type; this variant takes only type and source at the block level.
{
"type": "document",
"source": {
"type": "file",
"file_id": "file_11111111111141118111111111111111"
}
}Multipart upload accepts PNG, JPEG, GIF, WebP, PDF, plain text, CSV and JSON. Uploaded file references expire with the rental. Generated output files are for download.
For inline images or documents, title is an optional filename of 1–200 UTF-8 bytes, without slashes, backslashes, double quotes or control characters. Default filenames use the detected media type’s extension.
▸ ▾ Full request with text and an uploaded document
{
"account_id": "1",
"model": "claude-sonnet-5-5",
"content": [
{
"type": "text",
"text": "Summarize the main findings."
},
{
"type": "document",
"source": {
"type": "file",
"file_id": "file_11111111111141118111111111111111"
}
}
]
}