claude/types/content

Types

A citation attached to a text content block.

pub type Citation {
  CharLocationCitation(
    cited_text: String,
    document_index: Int,
    start_char_index: Int,
    end_char_index: Int,
  )
  PageLocationCitation(
    cited_text: String,
    document_index: Int,
    start_page: Int,
    end_page: Int,
  )
  ContentBlockLocationCitation(
    cited_text: String,
    document_index: Int,
    start_block_index: Int,
    end_block_index: Int,
  )
  WebSearchResultLocationCitation(
    cited_text: String,
    url: String,
    title: String,
  )
}

Constructors

  • CharLocationCitation(
      cited_text: String,
      document_index: Int,
      start_char_index: Int,
      end_char_index: Int,
    )
  • PageLocationCitation(
      cited_text: String,
      document_index: Int,
      start_page: Int,
      end_page: Int,
    )
  • ContentBlockLocationCitation(
      cited_text: String,
      document_index: Int,
      start_block_index: Int,
      end_block_index: Int,
    )
  • WebSearchResultLocationCitation(
      cited_text: String,
      url: String,
      title: String,
    )

Content blocks returned by the API (assistant responses).

pub type ContentBlock {
  Text(text: String, citations: List(Citation))
  Thinking(thinking: String, signature: String)
  RedactedThinking(data: String)
  ToolUse(id: String, name: String, input: String)
  ServerToolUse(id: String, name: String, input: String)
  WebSearchResult(
    id: String,
    title: String,
    url: String,
    encrypted_content: String,
  )
}

Constructors

  • Text(text: String, citations: List(Citation))
  • Thinking(thinking: String, signature: String)
  • RedactedThinking(data: String)
  • ToolUse(id: String, name: String, input: String)
  • ServerToolUse(id: String, name: String, input: String)
  • WebSearchResult(
      id: String,
      title: String,
      url: String,
      encrypted_content: String,
    )

Content blocks sent TO the API (in user/assistant message params).

pub type ContentBlockParam {
  TextParam(text: String)
  ImageParam(source: ImageSource)
  DocumentParam(source: DocumentSource)
  ToolUseParam(id: String, name: String, input: String)
  ToolResultParam(
    tool_use_id: String,
    content: ToolResultContent,
    is_error: Bool,
  )
  ThinkingParam(thinking: String, signature: String)
  RedactedThinkingParam(data: String)
  ServerToolUseParam(id: String, name: String, input: String)
}

Constructors

  • TextParam(text: String)
  • ImageParam(source: ImageSource)
  • DocumentParam(source: DocumentSource)
  • ToolUseParam(id: String, name: String, input: String)
  • ToolResultParam(
      tool_use_id: String,
      content: ToolResultContent,
      is_error: Bool,
    )
  • ThinkingParam(thinking: String, signature: String)
  • RedactedThinkingParam(data: String)
  • ServerToolUseParam(id: String, name: String, input: String)

Source for an inline document.

pub type DocumentSource {
  Base64Document(media_type: String, data: String)
  UrlDocument(url: String)
}

Constructors

  • Base64Document(media_type: String, data: String)
  • UrlDocument(url: String)

Source for an inline image.

pub type ImageSource {
  Base64Image(media_type: String, data: String)
  UrlImage(url: String)
}

Constructors

  • Base64Image(media_type: String, data: String)
  • UrlImage(url: String)

The content field of a tool result — either a plain string or a list of blocks.

pub type ToolResultContent {
  StringResult(String)
  BlocksResult(List(ContentBlockParam))
}

Constructors

Values

pub fn text(t: String) -> ContentBlock

Create a simple text content block with no citations.

pub fn tool_result(
  tool_use_id id: String,
  content content: String,
  is_error is_error: Bool,
) -> ContentBlockParam

Create a tool-result content block param with string content.

pub fn tool_use(
  id id: String,
  name name: String,
  input input: String,
) -> ContentBlock

Create a tool-use content block.

Search Document