This version is still in development and is not considered stable yet. For the latest snapshot version, please use Spring AI 1.0.0-SNAPSHOT!spring-doc.cn

Anthropic’s Claude models are also available through Amazon Bedrock. Spring AI provides dedicated Amazon Bedrock Anthropic client implementations as well.
Refer to the Dependency Management section to add the Spring AI BOM to your build file.
Property Description Default

spring.ai.retry.max-attemptsspring-doc.cn

Maximum number of retry attempts.spring-doc.cn

10spring-doc.cn

spring.ai.retry.backoff.initial-intervalspring-doc.cn

Initial sleep duration for the exponential backoff policy.spring-doc.cn

2 sec.spring-doc.cn

spring.ai.retry.backoff.multiplierspring-doc.cn

Backoff interval multiplier.spring-doc.cn

5spring-doc.cn

spring.ai.retry.backoff.max-intervalspring-doc.cn

Maximum backoff duration.spring-doc.cn

3 min.spring-doc.cn

spring.ai.retry.on-client-errorsspring-doc.cn

If false, throw a NonTransientAiException, and do not attempt retry for 4xx client error codesspring-doc.cn

falsespring-doc.cn

spring.ai.retry.exclude-on-http-codesspring-doc.cn

List of HTTP status codes that should NOT trigger a retry (e.g. to throw NonTransientAiException).spring-doc.cn

emptyspring-doc.cn

spring.ai.retry.on-http-codesspring-doc.cn

List of HTTP status codes that should trigger a retry (e.g. to throw TransientAiException).spring-doc.cn

emptyspring-doc.cn

currently the retry policies are not applicable for the streaming API.
Property Description Default

spring.ai.anthropic.base-urlspring-doc.cn

The URL to connect tospring-doc.cn

api.anthropic.comspring-doc.cn

spring.ai.anthropic.versionspring-doc.cn

Anthropic API versionspring-doc.cn

2023-06-01spring-doc.cn

spring.ai.anthropic.api-keyspring-doc.cn

The API Keyspring-doc.cn

-spring-doc.cn

spring.ai.anthropic.beta-versionspring-doc.cn

Enables new/experimental features. If set to max-tokens-3-5-sonnet-2024-07-15 the output tokens limit is increased from 4096 to 8192 tokens (for claude-3-5-sonnet only).spring-doc.cn

tools-2024-04-04spring-doc.cn

Property Description Default

spring.ai.anthropic.chat.enabledspring-doc.cn

Enable Anthropic chat model.spring-doc.cn

truespring-doc.cn

spring.ai.anthropic.chat.options.modelspring-doc.cn

This is the Anthropic Chat model to use. Supports: claude-3-5-sonnet-20240620, claude-3-opus-20240229, claude-3-sonnet-20240229, claude-3-haiku-20240307 and the legacy claude-2.1, claude-2.0 and claude-instant-1.2 models.spring-doc.cn

claude-3-opus-20240229spring-doc.cn

spring.ai.anthropic.chat.options.temperaturespring-doc.cn

The sampling temperature to use that controls the apparent creativity of generated completions. Higher values will make output more random while lower values will make results more focused and deterministic. It is not recommended to modify temperature and top_p for the same completions request as the interaction of these two settings is difficult to predict.spring-doc.cn

0.8spring-doc.cn

spring.ai.anthropic.chat.options.max-tokensspring-doc.cn

The maximum number of tokens to generate in the chat completion. The total length of input tokens and generated tokens is limited by the model’s context length.spring-doc.cn

500spring-doc.cn

spring.ai.anthropic.chat.options.stop-sequencespring-doc.cn

Custom text sequences that will cause the model to stop generating. Our models will normally stop when they have naturally completed their turn, which will result in a response stop_reason of "end_turn". If you want the model to stop generating when it encounters custom strings of text, you can use the stop_sequences parameter. If the model encounters one of the custom sequences, the response stop_reason value will be "stop_sequence" and the response stop_sequence value will contain the matched stop sequence.spring-doc.cn

-spring-doc.cn

spring.ai.anthropic.chat.options.top-pspring-doc.cn

Use nucleus sampling. In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by top_p. You should either alter temperature or top_p, but not both. Recommended for advanced use cases only. You usually only need to use temperature.spring-doc.cn

-spring-doc.cn

spring.ai.anthropic.chat.options.top-kspring-doc.cn

Only sample from the top K options for each subsequent token. Used to remove "long tail" low probability responses. Learn more technical details here. Recommended for advanced use cases only. You usually only need to use temperature.spring-doc.cn

-spring-doc.cn

spring.ai.mistralai.chat.options.functionsspring-doc.cn

List of functions, identified by their names, to enable for function calling in a single prompt requests. Functions with those names must exist in the functionCallbacks registry.spring-doc.cn

-spring-doc.cn

spring.ai.mistralai.chat.options.functionCallbacksspring-doc.cn

MistralAI Tool Function Callbacks to register with the ChatModel.spring-doc.cn

-spring-doc.cn

All properties prefixed with spring.ai.anthropic.chat.options can be overridden at runtime by adding a request specific Runtime Options to the Prompt call.
In addition to the model specific AnthropicChatOptions you can use a portable ChatOptions instance, created with the ChatOptionsBuilder#builder().
replace the api-key with your Anthropic credentials.
Refer to the Dependency Management section to add the Spring AI BOM to your build file.