Module Proto.Content_block

Content blocks for Claude messages wire format.

This module defines the wire format types for content blocks that can appear in Claude messages, including text, tool use, tool results, and thinking blocks.

Text Blocks

module Text : sig ... end

Plain text content blocks.

Tool Use Blocks

module Tool_use : sig ... end

Tool invocation requests from the assistant.

Tool Result Blocks

module Tool_result : sig ... end

Results from tool invocations.

Thinking Blocks

module Thinking : sig ... end

Assistant's internal reasoning blocks.

Content Block Union Type

type t =
  1. | Text of Text.t
  2. | Tool_use of Tool_use.t
  3. | Tool_result of Tool_result.t
  4. | Thinking of Thinking.t
    (*

    The type of content blocks, which can be text, tool use, tool result, or thinking.

    *)
val jsont : t Jsont.t

jsont is the Jsont codec for content blocks. Use Jsont.Json.encode jsont and Jsont.Json.decode jsont for serialization. Use Jsont.pp_value jsont () for pretty-printing.

val text : string -> t

text s creates a text content block.

val tool_use : id:string -> name:string -> input:Jsont.json -> t

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

val tool_result : tool_use_id:string -> ?content:Jsont.json -> ?is_error:bool -> unit -> t

tool_result ~tool_use_id ?content ?is_error () creates a tool result content block. Content can be a string or an array of content blocks.

val thinking : thinking:string -> signature:string -> t

thinking ~thinking ~signature creates a thinking content block.