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 recordInput messages.static classstatic final recordChat completion request object.static final classstatic final recordChat completion response object.static enumCheck the Models overview and model comparison for additional details and options.static final recordThe content block of the message.static final recordContent block delta event.static final recordContent block start event.static final recordContent block stop event.static final recordError event.static enumThe event type of the streamed chunk.static final recordMessage delta event.static final recordMessage start event.static final recordMessage stop event.static final recordPing event.static enumThe role of the author of this message.static interfacestatic enumThe thinking type.static final recordTool description.static classSpecial event used to aggregate multiple tool use events into a single event with list of aggregated ContentBlockToolUse.static final recordUsage statistics. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic AnthropicApi.Builderbuilder()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.ChatCompletionResponseas 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.ChatCompletionResponseas 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
Fluxstream 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
Fluxstream from chat completion chunks.
-