Class BetaContentBlock
-
- All Implemented Interfaces:
public final class BetaContentBlockResponse model for a file uploaded to the container.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBetaContentBlock.VisitorAn interface that defines how to map each variant of BetaContentBlock to a value of type T.
-
Method Summary
-
-
Method Detail
-
toParam
final BetaContentBlockParam toParam()
-
text
final Optional<BetaTextBlock> text()
-
thinking
final Optional<BetaThinkingBlock> thinking()
-
redactedThinking
final Optional<BetaRedactedThinkingBlock> redactedThinking()
-
toolUse
final Optional<BetaToolUseBlock> toolUse()
-
serverToolUse
final Optional<BetaServerToolUseBlock> serverToolUse()
-
webSearchToolResult
final Optional<BetaWebSearchToolResultBlock> webSearchToolResult()
-
webFetchToolResult
final Optional<BetaWebFetchToolResultBlock> webFetchToolResult()
-
advisorToolResult
final Optional<BetaAdvisorToolResultBlock> advisorToolResult()
-
codeExecutionToolResult
final Optional<BetaCodeExecutionToolResultBlock> codeExecutionToolResult()
-
bashCodeExecutionToolResult
final Optional<BetaBashCodeExecutionToolResultBlock> bashCodeExecutionToolResult()
-
textEditorCodeExecutionToolResult
final Optional<BetaTextEditorCodeExecutionToolResultBlock> textEditorCodeExecutionToolResult()
-
toolSearchToolResult
final Optional<BetaToolSearchToolResultBlock> toolSearchToolResult()
-
mcpToolUse
final Optional<BetaMcpToolUseBlock> mcpToolUse()
-
mcpToolResult
final Optional<BetaMcpToolResultBlock> mcpToolResult()
-
containerUpload
final Optional<BetaContainerUploadBlock> containerUpload()
Response model for a file uploaded to the container.
-
compaction
final Optional<BetaCompactionBlock> compaction()
A compaction block returned when autocompact is triggered.
When content is None, it indicates the compaction failed to produce a valid summary (e.g., malformed output from the model). Clients may round-trip compaction blocks with null content; the server treats them as no-ops.
-
fallback
final Optional<BetaFallbackBlock> fallback()
Marks the point in
contentwhere one model's output gives way to the next.One block appears per hop where a preceding model actually ran this turn and declined. A turn routed directly by the sticky decision has no such boundary and carries no block — the signal for whether a fallback model served the response is the presence of a
fallback_messageentry inusage.iterations, not this block.The block is treated like a server-tool content block for streaming: it arrives via the standard
content_block_start/content_block_stoppair and carries no deltas.
-
isThinking
final Boolean isThinking()
-
isRedactedThinking
final Boolean isRedactedThinking()
-
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()
-
isFallback
final Boolean isFallback()
-
asText
final BetaTextBlock asText()
-
asThinking
final BetaThinkingBlock asThinking()
-
asRedactedThinking
final BetaRedactedThinkingBlock asRedactedThinking()
-
asToolUse
final BetaToolUseBlock asToolUse()
-
asServerToolUse
final BetaServerToolUseBlock asServerToolUse()
-
asWebSearchToolResult
final BetaWebSearchToolResultBlock asWebSearchToolResult()
-
asWebFetchToolResult
final BetaWebFetchToolResultBlock asWebFetchToolResult()
-
asAdvisorToolResult
final BetaAdvisorToolResultBlock asAdvisorToolResult()
-
asCodeExecutionToolResult
final BetaCodeExecutionToolResultBlock asCodeExecutionToolResult()
-
asBashCodeExecutionToolResult
final BetaBashCodeExecutionToolResultBlock asBashCodeExecutionToolResult()
-
asTextEditorCodeExecutionToolResult
final BetaTextEditorCodeExecutionToolResultBlock asTextEditorCodeExecutionToolResult()
-
asToolSearchToolResult
final BetaToolSearchToolResultBlock asToolSearchToolResult()
-
asMcpToolUse
final BetaMcpToolUseBlock asMcpToolUse()
-
asMcpToolResult
final BetaMcpToolResultBlock asMcpToolResult()
-
asContainerUpload
final BetaContainerUploadBlock asContainerUpload()
Response model for a file uploaded to the container.
-
asCompaction
final BetaCompactionBlock asCompaction()
A compaction block returned when autocompact is triggered.
When content is None, it indicates the compaction failed to produce a valid summary (e.g., malformed output from the model). Clients may round-trip compaction blocks with null content; the server treats them as no-ops.
-
asFallback
final BetaFallbackBlock asFallback()
Marks the point in
contentwhere one model's output gives way to the next.One block appears per hop where a preceding model actually ran this turn and declined. A turn routed directly by the sticky decision has no such boundary and carries no block — the signal for whether a fallback model served the response is the presence of a
fallback_messageentry inusage.iterations, not this block.The block is treated like a server-tool content block for streaming: it arrives via the standard
content_block_start/content_block_stoppair and carries no deltas.
-
accept
final <T extends Any> T accept(BetaContentBlock.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 = betaContentBlock.accept(new BetaContentBlock.Visitor<Optional<String>>() { @Override public Optional<String> visitText(BetaTextBlock text) { return Optional.of(text.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final BetaContentBlock 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 BetaContentBlock ofText(BetaTextBlock text)
-
ofThinking
final static BetaContentBlock ofThinking(BetaThinkingBlock thinking)
-
ofRedactedThinking
final static BetaContentBlock ofRedactedThinking(BetaRedactedThinkingBlock redactedThinking)
-
ofToolUse
final static BetaContentBlock ofToolUse(BetaToolUseBlock toolUse)
-
ofServerToolUse
final static BetaContentBlock ofServerToolUse(BetaServerToolUseBlock serverToolUse)
-
ofWebSearchToolResult
final static BetaContentBlock ofWebSearchToolResult(BetaWebSearchToolResultBlock webSearchToolResult)
-
ofWebFetchToolResult
final static BetaContentBlock ofWebFetchToolResult(BetaWebFetchToolResultBlock webFetchToolResult)
-
ofAdvisorToolResult
final static BetaContentBlock ofAdvisorToolResult(BetaAdvisorToolResultBlock advisorToolResult)
-
ofCodeExecutionToolResult
final static BetaContentBlock ofCodeExecutionToolResult(BetaCodeExecutionToolResultBlock codeExecutionToolResult)
-
ofBashCodeExecutionToolResult
final static BetaContentBlock ofBashCodeExecutionToolResult(BetaBashCodeExecutionToolResultBlock bashCodeExecutionToolResult)
-
ofTextEditorCodeExecutionToolResult
final static BetaContentBlock ofTextEditorCodeExecutionToolResult(BetaTextEditorCodeExecutionToolResultBlock textEditorCodeExecutionToolResult)
-
ofToolSearchToolResult
final static BetaContentBlock ofToolSearchToolResult(BetaToolSearchToolResultBlock toolSearchToolResult)
-
ofMcpToolUse
final static BetaContentBlock ofMcpToolUse(BetaMcpToolUseBlock mcpToolUse)
-
ofMcpToolResult
final static BetaContentBlock ofMcpToolResult(BetaMcpToolResultBlock mcpToolResult)
-
ofContainerUpload
final static BetaContentBlock ofContainerUpload(BetaContainerUploadBlock containerUpload)
Response model for a file uploaded to the container.
-
ofCompaction
final static BetaContentBlock ofCompaction(BetaCompactionBlock compaction)
A compaction block returned when autocompact is triggered.
When content is None, it indicates the compaction failed to produce a valid summary (e.g., malformed output from the model). Clients may round-trip compaction blocks with null content; the server treats them as no-ops.
-
ofFallback
final static BetaContentBlock ofFallback(BetaFallbackBlock fallback)
Marks the point in
contentwhere one model's output gives way to the next.One block appears per hop where a preceding model actually ran this turn and declined. A turn routed directly by the sticky decision has no such boundary and carries no block — the signal for whether a fallback model served the response is the presence of a
fallback_messageentry inusage.iterations, not this block.The block is treated like a server-tool content block for streaming: it arrives via the standard
content_block_start/content_block_stoppair and carries no deltas.
-
-
-
-