CreateChatCompletionRequest class
Request object for the Create chat completion endpoint.
- Annotations
-
- @freezed
Constructors
-
CreateChatCompletionRequest.new({@_ChatCompletionModelConverter() required ChatCompletionModel model, required List<
ChatCompletionMessage> messages, @JsonKey(includeIfNull: false) bool? store, @JsonKey(includeIfNull: false) Map<String, String> ? metadata, @JsonKey(name: 'frequency_penalty', includeIfNull: false) @Default(0.0) double? frequencyPenalty, @JsonKey(name: 'logit_bias', includeIfNull: false) Map<String, int> ? logitBias, @JsonKey(includeIfNull: false) bool? logprobs, @JsonKey(name: 'top_logprobs', includeIfNull: false) int? topLogprobs, @JsonKey(name: 'max_tokens', includeIfNull: false) int? maxTokens, @JsonKey(name: 'max_completion_tokens', includeIfNull: false) int? maxCompletionTokens, @JsonKey(includeIfNull: false) @Default(1) int? n, @JsonKey(includeIfNull: false) List<ChatCompletionModality> ? modalities, @JsonKey(includeIfNull: false) PredictionContent? prediction, @JsonKey(includeIfNull: false) ChatCompletionAudioOptions? audio, @JsonKey(name: 'presence_penalty', includeIfNull: false) @Default(0.0) double? presencePenalty, @JsonKey(name: 'response_format', includeIfNull: false) ResponseFormat? responseFormat, @JsonKey(includeIfNull: false) int? seed, @JsonKey(name: 'service_tier', includeIfNull: false, unknownEnumValue: JsonKey.nullForUndefinedEnumValue) CreateChatCompletionRequestServiceTier? serviceTier, @_ChatCompletionStopConverter() @JsonKey(includeIfNull: false) ChatCompletionStop? stop, @JsonKey(includeIfNull: false) @Default(false) bool? stream, @JsonKey(name: 'stream_options', includeIfNull: false) ChatCompletionStreamOptions? streamOptions, @JsonKey(includeIfNull: false) @Default(1.0) double? temperature, @JsonKey(name: 'top_p', includeIfNull: false) @Default(1.0) double? topP, @JsonKey(includeIfNull: false) List<ChatCompletionTool> ? tools, @_ChatCompletionToolChoiceOptionConverter() @JsonKey(name: 'tool_choice', includeIfNull: false) ChatCompletionToolChoiceOption? toolChoice, @JsonKey(name: 'parallel_tool_calls', includeIfNull: false) bool? parallelToolCalls, @JsonKey(includeIfNull: false) String? user, @_ChatCompletionFunctionCallConverter() @JsonKey(name: 'function_call', includeIfNull: false) ChatCompletionFunctionCall? functionCall, @JsonKey(includeIfNull: false) List<FunctionObject> ? functions}) -
Factory constructor for CreateChatCompletionRequest
constfactory
-
CreateChatCompletionRequest.fromJson(Map<
String, dynamic> json) -
Object construction from a JSON representation
factory
Properties
- audio → ChatCompletionAudioOptions?
-
Parameters for audio output. Required when audio output is requested with
modalities: ["audio"]
. Learn more.no setterinherited -
copyWith
→ $CreateChatCompletionRequestCopyWith<
CreateChatCompletionRequest> -
Create a copy of CreateChatCompletionRequest
with the given fields replaced by the non-null parameter values.
no setterinherited
- frequencyPenalty → double?
-
Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the
text so far, decreasing the model's likelihood to repeat the same line verbatim.
no setterinherited
- functionCall → ChatCompletionFunctionCall?
-
Deprecated in favor of
tool_choice
.no setterinherited -
functions
→ List<
FunctionObject> ? -
Deprecated in favor of
tools
.no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
-
logitBias
→ Map<
String, int> ? -
Modify the likelihood of specified tokens appearing in the completion.
no setterinherited
- logprobs → bool?
-
Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of
each output token returned in the
content
ofmessage
.no setterinherited - maxCompletionTokens → int?
-
An upper bound for the number of tokens that can be generated for a completion, including visible output
tokens and reasoning tokens.
no setterinherited
- maxTokens → int?
-
The maximum number of tokens that can be generated in the chat
completion. This value can be used to control costs for text generated
via API.
no setterinherited
-
messages
→ List<
ChatCompletionMessage> -
A list of messages comprising the conversation so far. Depending on the model you use,
different message types (modalities) are supported,
like text,
images,
and audio.
no setterinherited
-
metadata
→ Map<
String, String> ? -
Developer-defined tags and values used for filtering completions
in the dashboard.
no setterinherited
-
modalities
→ List<
ChatCompletionModality> ? -
A list of modalities that the model may use to generate the completion.
no setterinherited
- model → ChatCompletionModel
-
ID of the model to use. See the model endpoint compatibility
table for details on which models work with the Chat API.
no setterinherited
- n → int?
-
How many chat completion choices to generate for each input message. Note that you will be charged based on
the number of generated tokens across all of the choices. Keep
n
as1
to minimize costs.no setterinherited - parallelToolCalls → bool?
-
Whether to enable parallel function calling
during tool use.
no setterinherited
- prediction → PredictionContent?
-
Configuration for a Predicted Output,
which can greatly improve response times when large parts of the model
response are known ahead of time. This is most common when you are
regenerating a file with only minor changes to most of the content.
no setterinherited
- presencePenalty → double?
-
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
no setterinherited
- responseFormat → ResponseFormat?
-
An object specifying the format that the model must output. Compatible with
GPT-4o,
GPT-4o mini,
GPT-4 Turbo and all GPT-3.5 Turbo models newer
than
gpt-3.5-turbo-1106
.no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- seed → int?
-
This feature is in Beta.
If specified, our system will make a best effort to sample deterministically, such that repeated requests
with the same
seed
and parameters should return the same result. Determinism is not guaranteed, and you should refer to thesystem_fingerprint
response parameter to monitor changes in the backend.no setterinherited - serviceTier → CreateChatCompletionRequestServiceTier?
-
Specifies the latency tier to use for processing the request. This parameter is relevant for customers
subscribed to the scale tier service:
no setterinherited
- stop → ChatCompletionStop?
-
Up to 4 sequences where the API will stop generating further tokens.
no setterinherited
- store → bool?
-
Whether or not to store the output of this chat completion request for use in our
model distillation
or evals products.
no setterinherited
- stream → bool?
-
If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a
data: [DONE]
message. Example Python code.no setterinherited - streamOptions → ChatCompletionStreamOptions?
-
Options for streaming response. Only set this when you set
stream: true
.no setterinherited - temperature → double?
-
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
no setterinherited
- toolChoice → ChatCompletionToolChoiceOption?
-
Controls which (if any) tool is called by the model.
none
means the model will not call any tool and instead generates a message.auto
means the model can pick between generating a message or calling one or more tools.required
means the model must call one or more tools. Specifying a particular tool via{"type": "function", "function": {"name": "my_function"}}
forces the model to call that tool.no setterinherited -
tools
→ List<
ChatCompletionTool> ? -
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. A max of 128 functions are
supported.
no setterinherited
- topLogprobs → int?
-
An integer between 0 and 20 specifying the number of most likely tokens to return at each token position,
each with an associated log probability.
logprobs
must be set totrue
if this parameter is used.no setterinherited - topP → double?
-
An alternative to sampling with temperature, called 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.
no setterinherited
- user → String?
-
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> -
Serializes this CreateChatCompletionRequest to a JSON map.
inherited
-
toMap(
) → Map< String, dynamic> - Map representation of object (not serialized)
-
toString(
) → String -
A string representation of this object.
inherited
-
validateSchema(
) → String? - Perform validations on the schema property values
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- frequencyPenaltyDefaultValue → const double
- Validation constants
- frequencyPenaltyMaxValue → const double
- frequencyPenaltyMinValue → const double
- nDefaultValue → const int
- nMaxValue → const int
- nMinValue → const int
- presencePenaltyDefaultValue → const double
- presencePenaltyMaxValue → const double
- presencePenaltyMinValue → const double
-
propertyNames
→ const List<
String> - List of all property names of schema
- temperatureDefaultValue → const double
- temperatureMaxValue → const double
- temperatureMinValue → const double
- topLogprobsMaxValue → const int
- topLogprobsMinValue → const int
- topPDefaultValue → const double
- topPMaxValue → const double
- topPMinValue → const double