Class BetaMessageThreadAsync

  • All Implemented Interfaces:

    
    public final class BetaMessageThreadAsync
    
                        

    A message thread on an asynchronous client. It does what BetaMessageThread does, and returns futures and asynchronous streams. A turn is in progress until its future has completed or its stream has ended.

    Create one with MessageServiceAsync.thread. For example:

    BetaMessageThreadAsync thread = client.beta().messages().thread(
        ThreadCreateParams.builder()
            .model("claude-sonnet-5-5")
            .maxTokens(1024)
            .build());
    
    CompletableFuture<BetaMessage> second =
        thread.send("Hello").thenCompose(first -> thread.send("And again"));

    For replies in the JSON schema derived from a class, see StructuredBetaMessageThreadAsync.