Sending a local PNG image to Claude in the request body
CCDV-F
Applications & Integration
Medium
Question 91 of 105
A developer is building a document processing service that sends local PNG diagrams to Claude through the Messages API. Security policy forbids hosting the images on public servers or external storage, so each image must travel inside the request body.
Which content block structure should the request use?
Show answer and explanation
AUse an image block with source type base64, media_type image/png, and the encoded data.
The Messages API requires images passed directly in request bodies to be formatted as an image content block with a source object of type base64, an explicit media type such as image/png, and the base64-encoded string. Specifying a binary block type with raw buffer payloads is unsupported because the Messages API accepts JSON payloads that require text-encoded data structures. Specifying a file block type with local filesystem path strings is invalid because Claude processes API requests remotely and cannot resolve local host file paths. Specifying an attachment block type with inline URI strings is also not a recognized content block structure within the Messages API specification.
Source: platform.claude.com/
Anonymous, no account needed. Your tally stays in this browser.