package anthropic

  1. Overview
  2. Docs

Module Anthropic.Content_blockSource

Helper functions for creating content blocks.

Sourceval text : string -> input_content_block

text s creates a text content block.

Sourceval image : media_type:string -> data:string -> input_content_block

image ~media_type ~data creates an image content block.

The data must be base64-encoded image data. Supported formats include JPEG, PNG, GIF, and WebP.

Sourceval document : name:string -> content:string -> media_type:string -> input_content_block

document ~name ~content ~media_type creates a document content block.

The content must be base64-encoded document data. The name is displayed to the model for context.

Sourceval tool_result : tool_use_id:string -> content:Yojson.Safe.t -> ?is_error:bool -> unit -> input_content_block

tool_result ~tool_use_id ~content ?is_error () creates a tool result block.

Tool results must reference a tool_use_id from a previous assistant message. Set is_error to true when the tool execution failed. The content parameter accepts structured JSON data which will be automatically serialized.

Sourceval tool_use : id:string -> name:string -> input:Yojson.Safe.t -> input_content_block

tool_use ~id ~name ~input creates a tool use content block.

This is used to represent tool invocations from assistant responses when maintaining conversation history.