Record Class MistralAiApi.ChatCompletionRequest
java.lang.Object
java.lang.Record
org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionRequest
- Record Components:
model- ID of the model to use.messages- The prompt(s) to generate completions for, encoded as a list of dict with role and content. The first prompt role should be user or system.tools- A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for.toolChoice- Controls which (if any) function is called by the model. none means the model will not call a function and instead generates a message. auto means the model can pick between generating a message or calling a function. Any means the model must call a function.temperature- What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.topP- Nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.maxTokens- The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length.n- Number of completions to return for each request, input tokens are only billed once. Minimum is 1.presencePenalty- The presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative. Supported range is between -2.0 and 2.0.frequencyPenalty- The frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition. Supported range is between -2.0 and 2.0.stream- Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.safePrompt- Whether to inject a safety prompt before all conversations.stop- A list of tokens that the model should stop generating after.reasoningEffort- Controls the reasoning effort level for reasoning models.randomSeed- The seed to use for random sampling. If set, different calls will generate deterministic results.responseFormat- An object specifying the format or schema that the model must output. Setting to { "type": "json_object" } enables JSON mode, which guarantees the message the model generates is valid JSON. Setting to { "type": "json_object" , "json_schema": schema} allows you to ensure the model provides an answer in a very specific JSON format by supplying a clear JSON schema.
- Enclosing class:
- MistralAiApi
public static record MistralAiApi.ChatCompletionRequest(@Nullable String model, List<MistralAiApi.ChatCompletionMessage> messages, @Nullable List<MistralAiApi.FunctionTool> tools, @Nullable MistralAiApi.ChatCompletionRequest.ToolChoice toolChoice, @Nullable Double temperature, @Nullable Double topP, @Nullable Integer maxTokens, @Nullable Integer n, @Nullable Double presencePenalty, @Nullable Double frequencyPenalty, @Nullable Boolean stream, @Nullable Boolean safePrompt, @Nullable List<String> stop, @Nullable MistralAiApi.ChatCompletionRequest.ReasoningEffort reasoningEffort, @Nullable Integer randomSeed, @Nullable MistralAiApi.ChatCompletionRequest.ResponseFormat responseFormat)
extends Record
Creates a model request for chat conversation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumControls the reasoning effort level for adjustable reasoning models.static classAn object specifying the format that the model must output.static enumSpecifies a tool the model should use. -
Constructor Summary
ConstructorsConstructorDescriptionChatCompletionRequest(@Nullable String model, List<MistralAiApi.ChatCompletionMessage> messages, @Nullable List<MistralAiApi.FunctionTool> tools, @Nullable MistralAiApi.ChatCompletionRequest.ToolChoice toolChoice, @Nullable Double temperature, @Nullable Double topP, @Nullable Integer maxTokens, @Nullable Integer n, @Nullable Double presencePenalty, @Nullable Double frequencyPenalty, @Nullable Boolean stream, @Nullable Boolean safePrompt, @Nullable List<String> stop, @Nullable MistralAiApi.ChatCompletionRequest.ReasoningEffort reasoningEffort, @Nullable Integer randomSeed, @Nullable MistralAiApi.ChatCompletionRequest.ResponseFormat responseFormat) Creates an instance of aChatCompletionRequestrecord class.ChatCompletionRequest(List<MistralAiApi.ChatCompletionMessage> messages, Boolean stream) Shortcut constructor for a chat completion request with the given messages and stream.ChatCompletionRequest(List<MistralAiApi.ChatCompletionMessage> messages, String model) Shortcut constructor for a chat completion request with the given messages and model.ChatCompletionRequest(List<MistralAiApi.ChatCompletionMessage> messages, String model, Double temperature) Shortcut constructor for a chat completion request with the given messages, model and temperature.ChatCompletionRequest(List<MistralAiApi.ChatCompletionMessage> messages, String model, Double temperature, boolean stream) Shortcut constructor for a chat completion request with the given messages, model and temperature.ChatCompletionRequest(List<MistralAiApi.ChatCompletionMessage> messages, String model, List<MistralAiApi.FunctionTool> tools, MistralAiApi.ChatCompletionRequest.ToolChoice toolChoice) Shortcut constructor for a chat completion request with the given messages, model, tools and tool choice. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.@Nullable DoubleReturns the value of thefrequencyPenaltyrecord component.final inthashCode()Returns a hash code value for this object.@Nullable IntegerReturns the value of themaxTokensrecord component.messages()Returns the value of themessagesrecord component.@Nullable Stringmodel()Returns the value of themodelrecord component.@Nullable Integern()Returns the value of thenrecord component.@Nullable DoubleReturns the value of thepresencePenaltyrecord component.@Nullable IntegerReturns the value of therandomSeedrecord component.Returns the value of thereasoningEffortrecord component.Returns the value of theresponseFormatrecord component.@Nullable BooleanReturns the value of thesafePromptrecord component.stop()Returns the value of thestoprecord component.@Nullable Booleanstream()Returns the value of thestreamrecord component.@Nullable DoubleReturns the value of thetemperaturerecord component.Returns the value of thetoolChoicerecord component.@Nullable List<MistralAiApi.FunctionTool>tools()Returns the value of thetoolsrecord component.@Nullable DoubletopP()Returns the value of thetopPrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ChatCompletionRequest
Shortcut constructor for a chat completion request with the given messages and model.- Parameters:
messages- The prompt(s) to generate completions for, encoded as a list of dict with role and content. The first prompt role should be user or system.model- ID of the model to use.
-
ChatCompletionRequest
public ChatCompletionRequest(List<MistralAiApi.ChatCompletionMessage> messages, String model, Double temperature, boolean stream) Shortcut constructor for a chat completion request with the given messages, model and temperature.- Parameters:
messages- The prompt(s) to generate completions for, encoded as a list of dict with role and content. The first prompt role should be user or system.model- ID of the model to use.temperature- What sampling temperature to use, between 0.0 and 1.0.stream- Whether to stream back partial progress. If set, tokens will be sent
-
ChatCompletionRequest
public ChatCompletionRequest(List<MistralAiApi.ChatCompletionMessage> messages, String model, Double temperature) Shortcut constructor for a chat completion request with the given messages, model and temperature.- Parameters:
messages- The prompt(s) to generate completions for, encoded as a list of dict with role and content. The first prompt role should be user or system.model- ID of the model to use.temperature- What sampling temperature to use, between 0.0 and 1.0.
-
ChatCompletionRequest
public ChatCompletionRequest(List<MistralAiApi.ChatCompletionMessage> messages, String model, List<MistralAiApi.FunctionTool> tools, MistralAiApi.ChatCompletionRequest.ToolChoice toolChoice) Shortcut constructor for a chat completion request with the given messages, model, tools and tool choice. Streaming is set to false, temperature to 0.8 and all other parameters are null.- Parameters:
messages- A list of messages comprising the conversation so far.model- ID of the model to use.tools- A list of tools the model may call. Currently, only functions are supported as a tool.toolChoice- Controls which (if any) function is called by the model.
-
ChatCompletionRequest
Shortcut constructor for a chat completion request with the given messages and stream. -
ChatCompletionRequest
public ChatCompletionRequest(@Nullable String model, List<MistralAiApi.ChatCompletionMessage> messages, @Nullable List<MistralAiApi.FunctionTool> tools, @Nullable MistralAiApi.ChatCompletionRequest.ToolChoice toolChoice, @Nullable Double temperature, @Nullable Double topP, @Nullable Integer maxTokens, @Nullable Integer n, @Nullable Double presencePenalty, @Nullable Double frequencyPenalty, @Nullable Boolean stream, @Nullable Boolean safePrompt, @Nullable List<String> stop, @Nullable MistralAiApi.ChatCompletionRequest.ReasoningEffort reasoningEffort, @Nullable Integer randomSeed, @Nullable MistralAiApi.ChatCompletionRequest.ResponseFormat responseFormat) Creates an instance of aChatCompletionRequestrecord class.- Parameters:
model- the value for themodelrecord componentmessages- the value for themessagesrecord componenttools- the value for thetoolsrecord componenttoolChoice- the value for thetoolChoicerecord componenttemperature- the value for thetemperaturerecord componenttopP- the value for thetopPrecord componentmaxTokens- the value for themaxTokensrecord componentn- the value for thenrecord componentpresencePenalty- the value for thepresencePenaltyrecord componentfrequencyPenalty- the value for thefrequencyPenaltyrecord componentstream- the value for thestreamrecord componentsafePrompt- the value for thesafePromptrecord componentstop- the value for thestoprecord componentreasoningEffort- the value for thereasoningEffortrecord componentrandomSeed- the value for therandomSeedrecord componentresponseFormat- the value for theresponseFormatrecord component
-
-
Method Details
-
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
-
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
-
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
-
maxTokens
Returns the value of themaxTokensrecord component.- Returns:
- the value of the
maxTokensrecord component
-
n
Returns the value of thenrecord component.- Returns:
- the value of the
nrecord component
-
presencePenalty
Returns the value of thepresencePenaltyrecord component.- Returns:
- the value of the
presencePenaltyrecord component
-
frequencyPenalty
Returns the value of thefrequencyPenaltyrecord component.- Returns:
- the value of the
frequencyPenaltyrecord component
-
stream
Returns the value of thestreamrecord component.- Returns:
- the value of the
streamrecord component
-
safePrompt
Returns the value of thesafePromptrecord component.- Returns:
- the value of the
safePromptrecord component
-
stop
Returns the value of thestoprecord component.- Returns:
- the value of the
stoprecord component
-
reasoningEffort
Returns the value of thereasoningEffortrecord component.- Returns:
- the value of the
reasoningEffortrecord component
-
randomSeed
Returns the value of therandomSeedrecord component.- Returns:
- the value of the
randomSeedrecord component
-
responseFormat
Returns the value of theresponseFormatrecord component.- Returns:
- the value of the
responseFormatrecord component
-