Module Message.Assistant

Messages from Claude assistant.

type error = [
  1. | `Authentication_failed
    (*

    Authentication with Claude API failed

    *)
  2. | `Billing_error
    (*

    Billing or account issue

    *)
  3. | `Rate_limit
    (*

    Rate limit exceeded

    *)
  4. | `Invalid_request
    (*

    Request was invalid

    *)
  5. | `Server_error
    (*

    Internal server error

    *)
  6. | `Unknown
    (*

    Unknown error type

    *)
]

The type of assistant message errors based on Python SDK error types.

type t

The type of assistant messages.

val jsont : t Jsont.t

jsont is the Jsont codec for assistant messages.

val incoming_jsont : t Jsont.t

incoming_jsont is the codec for parsing incoming assistant messages from CLI. This parses the envelope format with "message" wrapper.

val create : content:Content_block.t list -> model:string -> ?error:error -> unit -> t

create ~content ~model ?error () creates an assistant message.

  • parameter content

    List of content blocks in the response

  • parameter model

    The model identifier used for the response

  • parameter error

    Optional error that occurred during message generation

val content : t -> Content_block.t list

content t returns the content blocks of the assistant message.

val model : t -> string

model t returns the model identifier.

val error : t -> error option

error t returns the optional error that occurred during message generation.

val unknown : t -> Unknown.t

unknown t returns the unknown fields preserved from JSON.