Interface BetaContentBlockParam.Visitor
-
- All Implemented Interfaces:
public interface BetaContentBlockParam.Visitor<T extends Object>An interface that defines how to map each variant of BetaContentBlockParam to a value of type T.
-
-
Method Summary
Modifier and Type Method Description abstract TvisitText(BetaTextBlockParam text)Regular text content. abstract TvisitImage(BetaImageBlockParam image)Image content specified directly as base64 data or as a reference via a URL. abstract TvisitDocument(BetaRequestDocumentBlock document)Document content, either specified directly as base64 data, as text, or as a reference via a URL. abstract TvisitSearchResult(BetaSearchResultBlockParam searchResult)A search result block containing source, title, and content from search operations. abstract TvisitThinking(BetaThinkingBlockParam thinking)A block specifying internal thinking by the model. abstract TvisitRedactedThinking(BetaRedactedThinkingBlockParam redactedThinking)A block specifying internal, redacted thinking by the model. abstract TvisitToolUse(BetaToolUseBlockParam toolUse)A block indicating a tool use by the model. abstract TvisitToolResult(BetaToolResultBlockParam toolResult)A block specifying the results of a tool use by the model. abstract TvisitServerToolUse(BetaServerToolUseBlockParam serverToolUse)abstract TvisitWebSearchToolResult(BetaWebSearchToolResultBlockParam webSearchToolResult)abstract TvisitWebFetchToolResult(BetaWebFetchToolResultBlockParam webFetchToolResult)abstract TvisitAdvisorToolResult(BetaAdvisorToolResultBlockParam advisorToolResult)abstract TvisitCodeExecutionToolResult(BetaCodeExecutionToolResultBlockParam codeExecutionToolResult)abstract TvisitBashCodeExecutionToolResult(BetaBashCodeExecutionToolResultBlockParam bashCodeExecutionToolResult)abstract TvisitTextEditorCodeExecutionToolResult(BetaTextEditorCodeExecutionToolResultBlockParam textEditorCodeExecutionToolResult)abstract TvisitToolSearchToolResult(BetaToolSearchToolResultBlockParam toolSearchToolResult)abstract TvisitMcpToolUse(BetaMcpToolUseBlockParam mcpToolUse)abstract TvisitMcpToolResult(BetaRequestMcpToolResultBlockParam mcpToolResult)abstract TvisitContainerUpload(BetaContainerUploadBlockParam containerUpload)A content block that represents a file to be uploaded to the container Files uploaded via this block will be available in the container's input directory. abstract TvisitCompaction(BetaCompactionBlockParam compaction)A compaction block containing summary of previous context. abstract TvisitToolAddition(BetaRequestToolAdditionBlock toolAddition)Mid-conversation directive to make a tool available. abstract TvisitToolRemoval(BetaRequestToolRemovalBlock toolRemoval)Mid-conversation directive to withdraw a tool. abstract TvisitMcpToolListing(BetaMcpToolListingBlockParam mcpToolListing)The tool listing an MCP server returned while an earlier response was produced, as that response carried it. abstract TvisitFallback(BetaFallbackBlockParam fallback)A fallbackblock echoed back from a prior response.Tunknown(JsonValue json)Maps an unknown variant of BetaContentBlockParam to a value of type T. -
-
Method Detail
-
visitText
abstract T visitText(BetaTextBlockParam text)
Regular text content.
-
visitImage
abstract T visitImage(BetaImageBlockParam image)
Image content specified directly as base64 data or as a reference via a URL.
-
visitDocument
abstract T visitDocument(BetaRequestDocumentBlock document)
Document content, either specified directly as base64 data, as text, or as a reference via a URL.
-
visitSearchResult
abstract T visitSearchResult(BetaSearchResultBlockParam searchResult)
A search result block containing source, title, and content from search operations.
-
visitThinking
abstract T visitThinking(BetaThinkingBlockParam thinking)
A block specifying internal thinking by the model.
-
visitRedactedThinking
abstract T visitRedactedThinking(BetaRedactedThinkingBlockParam redactedThinking)
A block specifying internal, redacted thinking by the model.
-
visitToolUse
abstract T visitToolUse(BetaToolUseBlockParam toolUse)
A block indicating a tool use by the model.
-
visitToolResult
abstract T visitToolResult(BetaToolResultBlockParam toolResult)
A block specifying the results of a tool use by the model.
-
visitServerToolUse
abstract T visitServerToolUse(BetaServerToolUseBlockParam serverToolUse)
-
visitWebSearchToolResult
abstract T visitWebSearchToolResult(BetaWebSearchToolResultBlockParam webSearchToolResult)
-
visitWebFetchToolResult
abstract T visitWebFetchToolResult(BetaWebFetchToolResultBlockParam webFetchToolResult)
-
visitAdvisorToolResult
abstract T visitAdvisorToolResult(BetaAdvisorToolResultBlockParam advisorToolResult)
-
visitCodeExecutionToolResult
abstract T visitCodeExecutionToolResult(BetaCodeExecutionToolResultBlockParam codeExecutionToolResult)
-
visitBashCodeExecutionToolResult
abstract T visitBashCodeExecutionToolResult(BetaBashCodeExecutionToolResultBlockParam bashCodeExecutionToolResult)
-
visitTextEditorCodeExecutionToolResult
abstract T visitTextEditorCodeExecutionToolResult(BetaTextEditorCodeExecutionToolResultBlockParam textEditorCodeExecutionToolResult)
-
visitToolSearchToolResult
abstract T visitToolSearchToolResult(BetaToolSearchToolResultBlockParam toolSearchToolResult)
-
visitMcpToolUse
abstract T visitMcpToolUse(BetaMcpToolUseBlockParam mcpToolUse)
-
visitMcpToolResult
abstract T visitMcpToolResult(BetaRequestMcpToolResultBlockParam mcpToolResult)
-
visitContainerUpload
abstract T visitContainerUpload(BetaContainerUploadBlockParam containerUpload)
A content block that represents a file to be uploaded to the container Files uploaded via this block will be available in the container's input directory.
-
visitCompaction
abstract T visitCompaction(BetaCompactionBlockParam compaction)
A compaction block containing summary of previous context.
Users should round-trip these blocks from responses to subsequent requests to maintain context across compaction boundaries.
When content is None, the block represents a failed compaction. The server treats these as no-ops. Empty string content is not allowed.
-
visitToolAddition
abstract T visitToolAddition(BetaRequestToolAdditionBlock toolAddition)
Mid-conversation directive to make a tool available.
`tool`is a reference to a tool (or MCP toolset) declared in the request's`tools`. Under the`inline-tools-2026-09-15`beta it may instead be a reference to a tool defined earlier in`messages`, or a`tool_definition`object that carries an inline tool definition in`definition`(the same object a`tools`entry holds). An`mcp_toolset`definition also requires the`mcp-client-2026-09-15`beta. The tool is offered to the model from this point in the conversation onward.
-
visitToolRemoval
abstract T visitToolRemoval(BetaRequestToolRemovalBlock toolRemoval)
Mid-conversation directive to withdraw a tool.
`tool`references a tool (or MCP toolset) by name: one declared in the request's`tools`or defined earlier in`messages`. It is no longer offered to the model from this point in the conversation onward.
-
visitMcpToolListing
abstract T visitMcpToolListing(BetaMcpToolListingBlockParam mcpToolListing)
The tool listing an MCP server returned while an earlier response was produced, as that response carried it. Send the assistant message back unchanged, this block included, and the server uses this listing for the matching
mcp_toolsetinstead of asking the MCP server again.
-
visitFallback
abstract T visitFallback(BetaFallbackBlockParam fallback)
A
fallbackblock echoed back from a prior response.Accepted in
messages[].contentand not rendered into the prompt; not validated against the request'sfallbackschain or top-levelmodel.When you send the assistant turn back, keep this block in its original position. The block marks the boundary between content produced before and after a fallback hop, and the server relies on that boundary to validate the turn: when thinking runs flank the boundary, omitting the block merges them into one span the server cannot validate (the request is rejected), and moving it into the middle of a single run is likewise rejected; between non-thinking blocks the block's placement has no effect on thinking validation.
Some blocks from before the turn's final
fallbackblock must be left out when you send the turn back, and notool_resultis sent for atool_useblock you left out.See the refusals and fallback guide to learn which blocks to keep.
-
unknown
T unknown(JsonValue json)
Maps an unknown variant of BetaContentBlockParam to a value of type T.
An instance of BetaContentBlockParam can contain an unknown variant if it was deserialized from data that doesn't match any known variant. For example, if the SDK is on an older version than the API, then the API may respond with new variants that the SDK is unaware of.
-
-
-
-