Class MessageCreateParams.FallbackCreditToken
-
- All Implemented Interfaces:
public final class MessageCreateParams.FallbackCreditTokenThe
fallback_credit_tokenfrom a prior refusal'sstop_details.When a preceding request was refused and returned a
fallback_credit_token, pass that code here on the retry to have the retry's cache-creation tokens for the prefix that was warm on the refused model billed at the cache-read rate. Must be redeemed by the same organization and workspace, with the same request body (optionally extended by one appendedassistantmessage whose content is the partial text — with any trailing whitespace stripped from the final text block — and paired server-tool blocks streamed before the refusal; the appended-assistant form is not available for requests withoutput_formatset or forcedtool_choice), on an eligible fallback model, on the same platform, and within 5 minutes of the refusal; a mismatch is a 400. A token minted mid-server-tool-loop whose partial content was continuable may only be redeemed with the appended-assistant form — if an exact-body retry is rejected with a 400 saying the token must be redeemed by continuing the partial response, retry with the appended-assistant form instead.When the appended-assistant form is used on a model that otherwise disallows assistant-turn prefill, this token also authorizes that one prefill.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceMessageCreateParams.FallbackCreditToken.VisitorAn interface that defines how to map each variant of FallbackCreditToken to a value of type T.
-
Method Summary
Modifier and Type Method Description final Optional<String>string()final Optional<BetaFallbackCreditTokenParam>betaFallbackCreditTokenParam()Object form of `fallback_credit_token`: the token plus a redemption mode.final Optional<JsonValue>_json()final BooleanisString()final BooleanisBetaFallbackCreditTokenParam()final StringasString()final BetaFallbackCreditTokenParamasBetaFallbackCreditTokenParam()Object form of `fallback_credit_token`: the token plus a redemption mode.final <T extends Any> Taccept(MessageCreateParams.FallbackCreditToken.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final MessageCreateParams.FallbackCreditTokenvalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static MessageCreateParams.FallbackCreditTokenofString(String string)final static MessageCreateParams.FallbackCreditTokenofBetaFallbackCreditTokenParam(BetaFallbackCreditTokenParam betaFallbackCreditTokenParam)Object form of `fallback_credit_token`: the token plus a redemption mode.final static MessageCreateParams.FallbackCreditTokenofBetaFallbackCreditTokenParam(String token)Returns an immutable instance of FallbackCreditToken whose ofBetaFallbackCreditTokenParam variant is built from the given required token. -
-
Method Detail
-
betaFallbackCreditTokenParam
final Optional<BetaFallbackCreditTokenParam> betaFallbackCreditTokenParam()
Object form of
`fallback_credit_token`: the token plus a redemption mode.Requires
`anthropic-beta: fallback-credit-2026-07-01`; without that header the field accepts the bare string only. The bare string and the mode-less object are equivalent (both select`strict`), so wrapping an existing token changes nothing by itself.
-
isBetaFallbackCreditTokenParam
final Boolean isBetaFallbackCreditTokenParam()
-
asBetaFallbackCreditTokenParam
final BetaFallbackCreditTokenParam asBetaFallbackCreditTokenParam()
Object form of
`fallback_credit_token`: the token plus a redemption mode.Requires
`anthropic-beta: fallback-credit-2026-07-01`; without that header the field accepts the bare string only. The bare string and the mode-less object are equivalent (both select`strict`), so wrapping an existing token changes nothing by itself.
-
accept
final <T extends Any> T accept(MessageCreateParams.FallbackCreditToken.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 = fallbackCreditToken.accept(new FallbackCreditToken.Visitor<Optional<String>>() { @Override public Optional<String> visitString(String string) { return Optional.of(string.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final MessageCreateParams.FallbackCreditToken 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.
-
ofString
final static MessageCreateParams.FallbackCreditToken ofString(String string)
-
ofBetaFallbackCreditTokenParam
final static MessageCreateParams.FallbackCreditToken ofBetaFallbackCreditTokenParam(BetaFallbackCreditTokenParam betaFallbackCreditTokenParam)
Object form of
`fallback_credit_token`: the token plus a redemption mode.Requires
`anthropic-beta: fallback-credit-2026-07-01`; without that header the field accepts the bare string only. The bare string and the mode-less object are equivalent (both select`strict`), so wrapping an existing token changes nothing by itself.
-
ofBetaFallbackCreditTokenParam
final static MessageCreateParams.FallbackCreditToken ofBetaFallbackCreditTokenParam(String token)
Returns an immutable instance of FallbackCreditToken whose ofBetaFallbackCreditTokenParam variant is built from the given required token.
-
-
-
-