Class BetaContentBlockParam
-
- All Implemented Interfaces:
public final class BetaContentBlockParamRegular text content.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBetaContentBlockParam.VisitorAn interface that defines how to map each variant of BetaContentBlockParam to a value of type T.
-
Method Summary
-
-
Method Detail
-
text
final Optional<BetaTextBlockParam> text()
Regular text content.
-
image
final Optional<BetaImageBlockParam> image()
Image content specified directly as base64 data or as a reference via a URL.
-
document
final Optional<BetaRequestDocumentBlock> document()
Document content, either specified directly as base64 data, as text, or as a reference via a URL.
-
searchResult
final Optional<BetaSearchResultBlockParam> searchResult()
A search result block containing source, title, and content from search operations.
-
thinking
final Optional<BetaThinkingBlockParam> thinking()
A block specifying internal thinking by the model.
-
redactedThinking
final Optional<BetaRedactedThinkingBlockParam> redactedThinking()
A block specifying internal, redacted thinking by the model.
-
toolUse
final Optional<BetaToolUseBlockParam> toolUse()
A block indicating a tool use by the model.
-
toolResult
final Optional<BetaToolResultBlockParam> toolResult()
A block specifying the results of a tool use by the model.
-
serverToolUse
final Optional<BetaServerToolUseBlockParam> serverToolUse()
-
webSearchToolResult
final Optional<BetaWebSearchToolResultBlockParam> webSearchToolResult()
-
webFetchToolResult
final Optional<BetaWebFetchToolResultBlockParam> webFetchToolResult()
-
advisorToolResult
final Optional<BetaAdvisorToolResultBlockParam> advisorToolResult()
-
codeExecutionToolResult
final Optional<BetaCodeExecutionToolResultBlockParam> codeExecutionToolResult()
-
bashCodeExecutionToolResult
final Optional<BetaBashCodeExecutionToolResultBlockParam> bashCodeExecutionToolResult()
-
textEditorCodeExecutionToolResult
final Optional<BetaTextEditorCodeExecutionToolResultBlockParam> textEditorCodeExecutionToolResult()
-
toolSearchToolResult
final Optional<BetaToolSearchToolResultBlockParam> toolSearchToolResult()
-
mcpToolUse
final Optional<BetaMcpToolUseBlockParam> mcpToolUse()
-
mcpToolResult
final Optional<BetaRequestMcpToolResultBlockParam> mcpToolResult()
-
containerUpload
final Optional<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.
-
compaction
final Optional<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.
-
midConvSystem
final Optional<BetaMidConversationSystemBlockParam> midConvSystem()
System instructions that appear mid-conversation.
Use this block to provide or update system-level instructions at a specific point in the conversation, rather than only via the top-level
systemparameter.
-
fallback
final Optional<BetaFallbackBlockParam> fallback()
A
fallbackblock echoed back from a prior response.Accepted in
messages[].contentand never rendered into the prompt, not validated against the request'sfallbackschain or top-levelmodel, and stripped before the sticky-routing cache key is computed.Callers should echo the assistant turn verbatim — block included. The block's position is load-bearing for thinking verification: the thinking runs on either side of a fallback hop carry independently-rooted verification hash chains, and this block is the only record of where one chain ends and the next begins. When thinking runs flank the boundary, omitting the block merges the runs into one contiguous span whose hashes cannot verify (the request is rejected), and moving it into the middle of a single run splits that run's chain and is likewise rejected; between non-thinking blocks the block's placement has no verification effect.
-
isDocument
final Boolean isDocument()
-
isSearchResult
final Boolean isSearchResult()
-
isThinking
final Boolean isThinking()
-
isRedactedThinking
final Boolean isRedactedThinking()
-
isToolResult
final Boolean isToolResult()
-
isServerToolUse
final Boolean isServerToolUse()
-
isWebSearchToolResult
final Boolean isWebSearchToolResult()
-
isWebFetchToolResult
final Boolean isWebFetchToolResult()
-
isAdvisorToolResult
final Boolean isAdvisorToolResult()
-
isCodeExecutionToolResult
final Boolean isCodeExecutionToolResult()
-
isBashCodeExecutionToolResult
final Boolean isBashCodeExecutionToolResult()
-
isTextEditorCodeExecutionToolResult
final Boolean isTextEditorCodeExecutionToolResult()
-
isToolSearchToolResult
final Boolean isToolSearchToolResult()
-
isMcpToolUse
final Boolean isMcpToolUse()
-
isMcpToolResult
final Boolean isMcpToolResult()
-
isContainerUpload
final Boolean isContainerUpload()
-
isCompaction
final Boolean isCompaction()
-
isMidConvSystem
final Boolean isMidConvSystem()
-
isFallback
final Boolean isFallback()
-
asText
final BetaTextBlockParam asText()
Regular text content.
-
asImage
final BetaImageBlockParam asImage()
Image content specified directly as base64 data or as a reference via a URL.
-
asDocument
final BetaRequestDocumentBlock asDocument()
Document content, either specified directly as base64 data, as text, or as a reference via a URL.
-
asSearchResult
final BetaSearchResultBlockParam asSearchResult()
A search result block containing source, title, and content from search operations.
-
asThinking
final BetaThinkingBlockParam asThinking()
A block specifying internal thinking by the model.
-
asRedactedThinking
final BetaRedactedThinkingBlockParam asRedactedThinking()
A block specifying internal, redacted thinking by the model.
-
asToolUse
final BetaToolUseBlockParam asToolUse()
A block indicating a tool use by the model.
-
asToolResult
final BetaToolResultBlockParam asToolResult()
A block specifying the results of a tool use by the model.
-
asServerToolUse
final BetaServerToolUseBlockParam asServerToolUse()
-
asWebSearchToolResult
final BetaWebSearchToolResultBlockParam asWebSearchToolResult()
-
asWebFetchToolResult
final BetaWebFetchToolResultBlockParam asWebFetchToolResult()
-
asAdvisorToolResult
final BetaAdvisorToolResultBlockParam asAdvisorToolResult()
-
asCodeExecutionToolResult
final BetaCodeExecutionToolResultBlockParam asCodeExecutionToolResult()
-
asBashCodeExecutionToolResult
final BetaBashCodeExecutionToolResultBlockParam asBashCodeExecutionToolResult()
-
asTextEditorCodeExecutionToolResult
final BetaTextEditorCodeExecutionToolResultBlockParam asTextEditorCodeExecutionToolResult()
-
asToolSearchToolResult
final BetaToolSearchToolResultBlockParam asToolSearchToolResult()
-
asMcpToolUse
final BetaMcpToolUseBlockParam asMcpToolUse()
-
asMcpToolResult
final BetaRequestMcpToolResultBlockParam asMcpToolResult()
-
asContainerUpload
final BetaContainerUploadBlockParam asContainerUpload()
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.
-
asCompaction
final BetaCompactionBlockParam asCompaction()
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.
-
asMidConvSystem
final BetaMidConversationSystemBlockParam asMidConvSystem()
System instructions that appear mid-conversation.
Use this block to provide or update system-level instructions at a specific point in the conversation, rather than only via the top-level
systemparameter.
-
asFallback
final BetaFallbackBlockParam asFallback()
A
fallbackblock echoed back from a prior response.Accepted in
messages[].contentand never rendered into the prompt, not validated against the request'sfallbackschain or top-levelmodel, and stripped before the sticky-routing cache key is computed.Callers should echo the assistant turn verbatim — block included. The block's position is load-bearing for thinking verification: the thinking runs on either side of a fallback hop carry independently-rooted verification hash chains, and this block is the only record of where one chain ends and the next begins. When thinking runs flank the boundary, omitting the block merges the runs into one contiguous span whose hashes cannot verify (the request is rejected), and moving it into the middle of a single run splits that run's chain and is likewise rejected; between non-thinking blocks the block's placement has no verification effect.
-
accept
final <T extends Any> T accept(BetaContentBlockParam.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.anthropic.core.JsonValue; import java.util.Optional; Optional<String> result = betaContentBlockParam.accept(new BetaContentBlockParam.Visitor<Optional<String>>() { @Override public Optional<String> visitText(BetaTextBlockParam text) { return Optional.of(text.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final BetaContentBlockParam validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofText
final static BetaContentBlockParam ofText(BetaTextBlockParam text)
Regular text content.
-
ofImage
final static BetaContentBlockParam ofImage(BetaImageBlockParam image)
Image content specified directly as base64 data or as a reference via a URL.
-
ofDocument
final static BetaContentBlockParam ofDocument(BetaRequestDocumentBlock document)
Document content, either specified directly as base64 data, as text, or as a reference via a URL.
-
ofSearchResult
final static BetaContentBlockParam ofSearchResult(BetaSearchResultBlockParam searchResult)
A search result block containing source, title, and content from search operations.
-
ofThinking
final static BetaContentBlockParam ofThinking(BetaThinkingBlockParam thinking)
A block specifying internal thinking by the model.
-
ofRedactedThinking
final static BetaContentBlockParam ofRedactedThinking(BetaRedactedThinkingBlockParam redactedThinking)
A block specifying internal, redacted thinking by the model.
-
ofToolUse
final static BetaContentBlockParam ofToolUse(BetaToolUseBlockParam toolUse)
A block indicating a tool use by the model.
-
ofToolResult
final static BetaContentBlockParam ofToolResult(BetaToolResultBlockParam toolResult)
A block specifying the results of a tool use by the model.
-
ofServerToolUse
final static BetaContentBlockParam ofServerToolUse(BetaServerToolUseBlockParam serverToolUse)
-
ofWebSearchToolResult
final static BetaContentBlockParam ofWebSearchToolResult(BetaWebSearchToolResultBlockParam webSearchToolResult)
-
ofWebFetchToolResult
final static BetaContentBlockParam ofWebFetchToolResult(BetaWebFetchToolResultBlockParam webFetchToolResult)
-
ofAdvisorToolResult
final static BetaContentBlockParam ofAdvisorToolResult(BetaAdvisorToolResultBlockParam advisorToolResult)
-
ofCodeExecutionToolResult
final static BetaContentBlockParam ofCodeExecutionToolResult(BetaCodeExecutionToolResultBlockParam codeExecutionToolResult)
-
ofBashCodeExecutionToolResult
final static BetaContentBlockParam ofBashCodeExecutionToolResult(BetaBashCodeExecutionToolResultBlockParam bashCodeExecutionToolResult)
-
ofTextEditorCodeExecutionToolResult
final static BetaContentBlockParam ofTextEditorCodeExecutionToolResult(BetaTextEditorCodeExecutionToolResultBlockParam textEditorCodeExecutionToolResult)
-
ofToolSearchToolResult
final static BetaContentBlockParam ofToolSearchToolResult(BetaToolSearchToolResultBlockParam toolSearchToolResult)
-
ofMcpToolUse
final static BetaContentBlockParam ofMcpToolUse(BetaMcpToolUseBlockParam mcpToolUse)
-
ofMcpToolResult
final static BetaContentBlockParam ofMcpToolResult(BetaRequestMcpToolResultBlockParam mcpToolResult)
-
ofContainerUpload
final static BetaContentBlockParam ofContainerUpload(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.
-
ofCompaction
final static BetaContentBlockParam ofCompaction(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.
-
ofMidConvSystem
final static BetaContentBlockParam ofMidConvSystem(BetaMidConversationSystemBlockParam midConvSystem)
System instructions that appear mid-conversation.
Use this block to provide or update system-level instructions at a specific point in the conversation, rather than only via the top-level
systemparameter.
-
ofFallback
final static BetaContentBlockParam ofFallback(BetaFallbackBlockParam fallback)
A
fallbackblock echoed back from a prior response.Accepted in
messages[].contentand never rendered into the prompt, not validated against the request'sfallbackschain or top-levelmodel, and stripped before the sticky-routing cache key is computed.Callers should echo the assistant turn verbatim — block included. The block's position is load-bearing for thinking verification: the thinking runs on either side of a fallback hop carry independently-rooted verification hash chains, and this block is the only record of where one chain ends and the next begins. When thinking runs flank the boundary, omitting the block merges the runs into one contiguous span whose hashes cannot verify (the request is rejected), and moving it into the middle of a single run splits that run's chain and is likewise rejected; between non-thinking blocks the block's placement has no verification effect.
-
-
-
-