Interface MessageService
-
- All Implemented Interfaces:
public interface MessageService
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceMessageService.WithRawResponseA view of MessageService that provides access to raw HTTP responses for each method.
-
Method Summary
Modifier and Type Method Description abstract MessageService.WithRawResponsewithRawResponse()Returns a view of this service that provides access to raw HTTP responses for each method. abstract MessageServicewithOptions(Consumer<ClientOptions.Builder> modifier)Returns a view of this service with the given option modifications applied. abstract BatchServicebatches()BetaMessagecreate(MessageCreateParams params)Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation. abstract BetaMessagecreate(MessageCreateParams params, RequestOptions requestOptions)<T extends Any> StructuredMessage<T>create(StructuredMessageCreateParams<T> params)Creates a model response for the given message parameters. <T extends Any> StructuredMessage<T>create(StructuredMessageCreateParams<T> params, RequestOptions requestOptions)Creates a model response for the given message parameters. StreamResponse<BetaRawMessageStreamEvent>createStreaming(MessageCreateParams params)Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation. abstract StreamResponse<BetaRawMessageStreamEvent>createStreaming(MessageCreateParams params, RequestOptions requestOptions)StreamResponse<BetaRawMessageStreamEvent>createStreaming(StructuredMessageCreateParams<?> params)Creates a streaming model response for the given message. StreamResponse<BetaRawMessageStreamEvent>createStreaming(StructuredMessageCreateParams<?> params, RequestOptions requestOptions)BetaMessageTokensCountcountTokens(MessageCountTokensParams params)Count the number of tokens in a Message. abstract BetaMessageTokensCountcountTokens(MessageCountTokensParams params, RequestOptions requestOptions)BetaToolRunnertoolRunner(MessageCreateParams params)BetaToolRunnertoolRunner(MessageCreateParams params, RequestOptions requestOptions)BetaToolRunnertoolRunner(ToolRunnerCreateParams params)abstract BetaToolRunnertoolRunner(ToolRunnerCreateParams params, RequestOptions requestOptions)-
-
Method Detail
-
withRawResponse
abstract MessageService.WithRawResponse withRawResponse()
Returns a view of this service that provides access to raw HTTP responses for each method.
-
withOptions
abstract MessageService withOptions(Consumer<ClientOptions.Builder> modifier)
Returns a view of this service with the given option modifications applied.
The original service is not modified.
-
batches
abstract BatchService batches()
-
create
BetaMessage create(MessageCreateParams params)
Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.
The Messages API can be used for either single queries or stateless multi-turn conversations.
Learn more about the Messages API in our user guide
-
create
abstract BetaMessage create(MessageCreateParams params, RequestOptions requestOptions)
-
create
<T extends Any> StructuredMessage<T> create(StructuredMessageCreateParams<T> params)
Creates a model response for the given message parameters. The model's structured output in JSON form will be deserialized automatically into an instance of the class
T. See the SDK documentation for more details.
-
create
<T extends Any> StructuredMessage<T> create(StructuredMessageCreateParams<T> params, RequestOptions requestOptions)
Creates a model response for the given message parameters. The model's structured output in JSON form will be deserialized automatically into an instance of the class
T. See the SDK documentation for more details.
-
createStreaming
@MustBeClosed() StreamResponse<BetaRawMessageStreamEvent> createStreaming(MessageCreateParams params)
Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.
The Messages API can be used for either single queries or stateless multi-turn conversations.
Learn more about the Messages API in our user guide
-
createStreaming
@MustBeClosed() abstract StreamResponse<BetaRawMessageStreamEvent> createStreaming(MessageCreateParams params, RequestOptions requestOptions)
-
createStreaming
@MustBeClosed() StreamResponse<BetaRawMessageStreamEvent> createStreaming(StructuredMessageCreateParams<?> params)
Creates a streaming model response for the given message. The message parameters can define a JSON schema derived automatically from an arbitrary class to request a structured output in JSON form. However, that structured output is split over multiple streamed events, so it will not be deserialized automatically into an instance of that class. To deserialize the output, first use a helper class to accumulate the stream of events into a single output value. See the SDK documentation for full details.
-
createStreaming
@MustBeClosed() StreamResponse<BetaRawMessageStreamEvent> createStreaming(StructuredMessageCreateParams<?> params, RequestOptions requestOptions)
-
countTokens
BetaMessageTokensCount countTokens(MessageCountTokensParams params)
Count the number of tokens in a Message.
The Token Count API can be used to count the number of tokens in a Message, including tools, images, and documents, without creating it.
Learn more about token counting in our user guide
-
countTokens
abstract BetaMessageTokensCount countTokens(MessageCountTokensParams params, RequestOptions requestOptions)
-
toolRunner
BetaToolRunner toolRunner(MessageCreateParams params)
-
toolRunner
BetaToolRunner toolRunner(MessageCreateParams params, RequestOptions requestOptions)
-
toolRunner
BetaToolRunner toolRunner(ToolRunnerCreateParams params)
-
toolRunner
abstract BetaToolRunner toolRunner(ToolRunnerCreateParams params, RequestOptions requestOptions)
-
-
-
-