Record Class AnthropicApi.ChatCompletionRequest
java.lang.Object
java.lang.Record
org.springframework.ai.anthropic.api.AnthropicApi.ChatCompletionRequest
- Record Components:
model- The model that will complete your prompt. See the list of models for additional details and options.messages- Input messages.system- System prompt. Can be a String (for compatibility) or a List<ContentBlock> (for caching support). A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our guide to system prompts.maxTokens- The maximum number of tokens to generate before stopping. Note that our models may stop before reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate. Different models have different maximum values for this parameter.metadata- An object describing metadata about the request.stopSequences- 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.stream- Whether to incrementally stream the response using server-sent events.temperature- Amount of randomness injected into the response.Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic.topP- 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.topK- 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.tools- Definitions of tools that the model may use. If provided the model may return tool_use content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using tool_result content blocks.toolChoice- How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.thinking- Configuration for the model's thinking mode. When enabled, the model can perform more in-depth reasoning before responding to a query.
- Enclosing class:
- AnthropicApi
public static record AnthropicApi.ChatCompletionRequest(String model, List<AnthropicApi.AnthropicMessage> messages, Object system, Integer maxTokens, AnthropicApi.ChatCompletionRequest.Metadata metadata, List<String> stopSequences, Boolean stream, Double temperature, Double topP, Integer topK, List<AnthropicApi.Tool> tools, AnthropicApi.ToolChoice toolChoice, AnthropicApi.ChatCompletionRequest.ThinkingConfig thinking)
extends Record
Chat completion request object.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic final recordMetadata about the request.static final recordConfiguration for the model's thinking mode. -
Constructor Summary
ConstructorsConstructorDescriptionChatCompletionRequest(String model, List<AnthropicApi.AnthropicMessage> messages, Object system, Integer maxTokens, Double temperature, Boolean stream) ChatCompletionRequest(String model, List<AnthropicApi.AnthropicMessage> messages, Object system, Integer maxTokens, List<String> stopSequences, Double temperature, Boolean stream) ChatCompletionRequest(String model, List<AnthropicApi.AnthropicMessage> messages, Object system, Integer maxTokens, AnthropicApi.ChatCompletionRequest.Metadata metadata, List<String> stopSequences, Boolean stream, Double temperature, Double topP, Integer topK, List<AnthropicApi.Tool> tools, AnthropicApi.ToolChoice toolChoice, AnthropicApi.ChatCompletionRequest.ThinkingConfig thinking) Creates an instance of aChatCompletionRequestrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()final booleanIndicates whether some other object is "equal to" this one.from(AnthropicApi.ChatCompletionRequest request) final inthashCode()Returns a hash code value for this object.Returns the value of themaxTokensrecord component.messages()Returns the value of themessagesrecord component.metadata()Returns the value of themetadatarecord component.model()Returns the value of themodelrecord component.Returns the value of thestopSequencesrecord component.stream()Returns the value of thestreamrecord component.system()Returns the value of thesystemrecord component.Returns the value of thetemperaturerecord component.thinking()Returns the value of thethinkingrecord component.Returns the value of thetoolChoicerecord component.tools()Returns the value of thetoolsrecord component.topK()Returns the value of thetopKrecord component.topP()Returns the value of thetopPrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ChatCompletionRequest
-
ChatCompletionRequest
-
ChatCompletionRequest
public ChatCompletionRequest(String model, List<AnthropicApi.AnthropicMessage> messages, Object system, Integer maxTokens, AnthropicApi.ChatCompletionRequest.Metadata metadata, List<String> stopSequences, Boolean stream, Double temperature, Double topP, Integer topK, List<AnthropicApi.Tool> tools, AnthropicApi.ToolChoice toolChoice, AnthropicApi.ChatCompletionRequest.ThinkingConfig thinking) Creates an instance of aChatCompletionRequestrecord class.- Parameters:
model- the value for themodelrecord componentmessages- the value for themessagesrecord componentsystem- the value for thesystemrecord componentmaxTokens- the value for themaxTokensrecord componentmetadata- the value for themetadatarecord componentstopSequences- the value for thestopSequencesrecord componentstream- the value for thestreamrecord componenttemperature- the value for thetemperaturerecord componenttopP- the value for thetopPrecord componenttopK- the value for thetopKrecord componenttools- the value for thetoolsrecord componenttoolChoice- the value for thetoolChoicerecord componentthinking- the value for thethinkingrecord component
-
-
Method Details
-
builder
-
from
public static AnthropicApi.ChatCompletionRequestBuilder from(AnthropicApi.ChatCompletionRequest request) -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
model
Returns the value of themodelrecord component.- Returns:
- the value of the
modelrecord component
-
messages
Returns the value of themessagesrecord component.- Returns:
- the value of the
messagesrecord component
-
system
Returns the value of thesystemrecord component.- Returns:
- the value of the
systemrecord component
-
maxTokens
Returns the value of themaxTokensrecord component.- Returns:
- the value of the
maxTokensrecord component
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-
stopSequences
Returns the value of thestopSequencesrecord component.- Returns:
- the value of the
stopSequencesrecord component
-
stream
Returns the value of thestreamrecord component.- Returns:
- the value of the
streamrecord component
-
temperature
Returns the value of thetemperaturerecord component.- Returns:
- the value of the
temperaturerecord component
-
topP
Returns the value of thetopPrecord component.- Returns:
- the value of the
topPrecord component
-
topK
Returns the value of thetopKrecord component.- Returns:
- the value of the
topKrecord component
-
tools
Returns the value of thetoolsrecord component.- Returns:
- the value of the
toolsrecord component
-
toolChoice
Returns the value of thetoolChoicerecord component.- Returns:
- the value of the
toolChoicerecord component
-
thinking
Returns the value of thethinkingrecord component.- Returns:
- the value of the
thinkingrecord component
-