Class AnthropicApi
java.lang.Object
org.springframework.ai.anthropic.api.AnthropicApi
The Anthropic API client.
- Since:
- 1.0.0
- Author:
- Christian Tzolov, Mariusz Bernacki, Thomas Vitale, Jihoon Kim, Alexandros Pappas, Jonghoon Park, Claudio Silva Junior, Filip Hrisafov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Input messages.static class
static final record
Chat completion request object.static final class
static final record
Chat completion response object.static enum
Check the Models overview and model comparison for additional details and options.static final record
The content block of the message.static final record
Content block delta event.static final record
Content block start event.static final record
Content block stop event.static final record
Error event.static enum
The event type of the streamed chunk.static final record
Message delta event.static final record
Message start event.static final record
Message stop event.static final record
Ping event.static enum
The role of the author of this message.static interface
static enum
The thinking type.static final record
Tool description.static class
Special event used to aggregate multiple tool use events into a single event with list of aggregated ContentBlockToolUse.static final record
Usage statistics. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic AnthropicApi.Builder
builder()
org.springframework.http.ResponseEntity<AnthropicApi.ChatCompletionResponse>
chatCompletionEntity
(AnthropicApi.ChatCompletionRequest chatRequest) Creates a model response for the given chat conversation.org.springframework.http.ResponseEntity<AnthropicApi.ChatCompletionResponse>
chatCompletionEntity
(AnthropicApi.ChatCompletionRequest chatRequest, org.springframework.util.MultiValueMap<String, String> additionalHttpHeader) Creates a model response for the given chat conversation.reactor.core.publisher.Flux<AnthropicApi.ChatCompletionResponse>
chatCompletionStream
(AnthropicApi.ChatCompletionRequest chatRequest) Creates a streaming chat response for the given chat conversation.reactor.core.publisher.Flux<AnthropicApi.ChatCompletionResponse>
chatCompletionStream
(AnthropicApi.ChatCompletionRequest chatRequest, org.springframework.util.MultiValueMap<String, String> additionalHttpHeader) Creates a streaming chat response for the given chat conversation.
-
Field Details
-
PROVIDER_NAME
-
DEFAULT_BASE_URL
- See Also:
-
DEFAULT_MESSAGE_COMPLETIONS_PATH
- See Also:
-
DEFAULT_ANTHROPIC_VERSION
- See Also:
-
DEFAULT_ANTHROPIC_BETA_VERSION
- See Also:
-
BETA_MAX_TOKENS
- See Also:
-
-
Method Details
-
builder
-
chatCompletionEntity
public org.springframework.http.ResponseEntity<AnthropicApi.ChatCompletionResponse> chatCompletionEntity(AnthropicApi.ChatCompletionRequest chatRequest) Creates a model response for the given chat conversation.- Parameters:
chatRequest
- The chat completion request.- Returns:
- Entity response with
AnthropicApi.ChatCompletionResponse
as a body and HTTP status code and headers.
-
chatCompletionEntity
public org.springframework.http.ResponseEntity<AnthropicApi.ChatCompletionResponse> chatCompletionEntity(AnthropicApi.ChatCompletionRequest chatRequest, org.springframework.util.MultiValueMap<String, String> additionalHttpHeader) Creates a model response for the given chat conversation.- Parameters:
chatRequest
- The chat completion request.additionalHttpHeader
- Additional HTTP headers.- Returns:
- Entity response with
AnthropicApi.ChatCompletionResponse
as a body and HTTP status code and headers.
-
chatCompletionStream
public reactor.core.publisher.Flux<AnthropicApi.ChatCompletionResponse> chatCompletionStream(AnthropicApi.ChatCompletionRequest chatRequest) Creates a streaming chat response for the given chat conversation.- Parameters:
chatRequest
- The chat completion request. Must have the stream property set to true.- Returns:
- Returns a
Flux
stream from chat completion chunks.
-
chatCompletionStream
public reactor.core.publisher.Flux<AnthropicApi.ChatCompletionResponse> chatCompletionStream(AnthropicApi.ChatCompletionRequest chatRequest, org.springframework.util.MultiValueMap<String, String> additionalHttpHeader) Creates a streaming chat response for the given chat conversation.- Parameters:
chatRequest
- The chat completion request. Must have the stream property set to true.additionalHttpHeader
- Additional HTTP headers.- Returns:
- Returns a
Flux
stream from chat completion chunks.
-