Class StructuredBetaMessageThreadAsync

  • All Implemented Interfaces:

    
    public final class StructuredBetaMessageThreadAsync<T extends Object>
    
                        

    A BetaMessageThreadAsync whose replies are in the JSON schema derived from a class. It does what StructuredBetaMessageThread does, and returns futures and asynchronous streams.

    Create one with MessageServiceAsync.thread. For example:

    StructuredBetaMessageThreadAsync<Forecast> thread = client.beta().messages().thread(
        ThreadCreateParams.builder()
            .model("claude-sonnet-5-5")
            .maxTokens(1024)
            .outputConfig(Forecast.class)
            .build());
    
    CompletableFuture<StructuredMessage<Forecast>> tomorrow =
        thread.send("Today?").thenCompose(today -> thread.send("Tomorrow?"));