View Source ExOpenAI.Components.CreateChatCompletionRequest (ex_openai.ex v2.0.0-beta2)
Module for representing the OpenAI schema CreateChatCompletionRequest.
Fields
:audio- optional -{:%{}, [], [{{:required, [], [:format]}, {:|, [], [{:|, [], [{:|, [], [{:|, [], [{:|, [], [:wav, :aac]}, :mp3]}, :flac]}, :opus]}, :pcm16]}}, {{:required, [], [:voice]}, {{:., [], [ExOpenAI.Components.VoiceIdsOrCustomVoice, :t]}, [], []}}]} | nil
Parameters for audio output. Required when audio output is requested withmodalities: ["audio"]. Learn more.:frequency_penalty- optional -number() | nil
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.
Default:0
Constraints: minimum: -2, maximum: 2:function_call- optional -:none | :auto | ExOpenAI.Components.ChatCompletionFunctionCallOption.t()
Deprecated in favor oftool_choice.
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.
Specifying a particular function via {"name": "my_function"} forces the
model to call that function.
none is the default when no functions are present. auto is the default
if functions are present.
:functions- optional -[ExOpenAI.Components.ChatCompletionFunctions.t()]
Deprecated in favor oftools.
A list of functions the model may generate JSON inputs for.
Constraints: minItems: 1, maxItems: 128
:logit_bias- optional -map() | nil
Modify the likelihood of specified tokens appearing in the completion.
Accepts a JSON object that maps tokens (specified by their token ID in the
tokenizer) to an associated bias value from -100 to 100. Mathematically,
the bias is added to the logits generated by the model prior to sampling.
The exact effect will vary per model, but values between -1 and 1 should
decrease or increase likelihood of selection; values like -100 or 100
should result in a ban or exclusive selection of the relevant token.
Default: nil
:logprobs- optional -boolean() | nil
Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in thecontentofmessage.
Default:false:max_completion_tokens- optional -integer() | nil
An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.:max_tokens- optional -integer() | nil
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.
This value is now deprecated in favor of max_completion_tokens, and is
not compatible with o-series models.
:messages- required -[ExOpenAI.Components.ChatCompletionRequestMessage.t()]
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.
Constraints: minItems: 1:metadata- optional -ExOpenAI.Components.Metadata.t():modalities- optional -ExOpenAI.Components.ResponseModalities.t():model- required -ExOpenAI.Components.ModelIdsShared.t()
Model ID used to generate the response, likegpt-4ooro3. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models.:n- optional -integer() | nil
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. Keepnas1to minimize costs.
Default:1
Constraints: minimum: 1, maximum: 128:parallel_tool_calls- optional -ExOpenAI.Components.ParallelToolCalls.t():prediction- optional -ExOpenAI.Components.PredictionContent.t() | nil
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.:presence_penalty- optional -number() | nil
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.
Default:0
Constraints: minimum: -2, maximum: 2:prompt_cache_key- optional -String.t()
Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces theuserfield. Learn more.:prompt_cache_retention- optional -:"in-memory" | :"24h" | any():reasoning_effort- optional -ExOpenAI.Components.ReasoningEffort.t():response_format- optional -ExOpenAI.Components.ResponseFormatText.t() | ExOpenAI.Components.ResponseFormatJsonSchema.t() | ExOpenAI.Components.ResponseFormatJsonObject.t()
An object specifying the format that the model must output.
Setting to { "type": "json_schema", "json_schema": {...} } enables
Structured Outputs which ensures the model will match your supplied JSON
schema. Learn more in the Structured Outputs
guide.
Setting to { "type": "json_object" } enables the older JSON mode, which
ensures the message the model generates is valid JSON. Using json_schema
is preferred for models that support it.
:safety_identifier- optional -String.t()
A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies. The IDs should be a string that uniquely identifies each user, with a maximum length of 64 characters. We recommend hashing their username or email address, in order to avoid sending us any identifying information. Learn more.
Constraints: maxLength: 64:seed- optional -integer() | nil
This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the sameseedand parameters should return the same result. Determinism is not guaranteed, and you should refer to thesystem_fingerprintresponse parameter to monitor changes in the backend.
Constraints: minimum: -9223372036854776000, maximum: 9223372036854776000:service_tier- optional -ExOpenAI.Components.ServiceTier.t():stop- optional -ExOpenAI.Components.StopConfiguration.t():store- optional -boolean() | nil
Whether or not to store the output of this chat completion request for use in our model distillation or evals products.
Supports text and image inputs. Note: image inputs over 8MB will be dropped.
Default: false
:stream- optional -boolean() | nil
If set to true, the model response data will be streamed to the client as it is generated using server-sent events. See the Streaming section below for more information, along with the streaming responses guide for more information on how to handle the streaming events.
Default:false:stream_options- optional -ExOpenAI.Components.ChatCompletionStreamOptions.t():temperature- optional -number() | any():tool_choice- optional -ExOpenAI.Components.ChatCompletionToolChoiceOption.t():tools- optional -[ExOpenAI.Components.ChatCompletionTool.t() | ExOpenAI.Components.CustomToolChatCompletions.t()]
A list of tools the model may call. You can provide either custom tools or function tools.:top_logprobs- optional -integer() | nil
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.logprobsmust be set totrueif this parameter is used.
Constraints: minimum: 0, maximum: 20:top_p- optional -number() | any():user- optional -String.t()
This field is being replaced bysafety_identifierandprompt_cache_key. Useprompt_cache_keyinstead to maintain caching optimizations. A stable identifier for your end-users. Used to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. Learn more.:verbosity- optional -ExOpenAI.Components.Verbosity.t():web_search_options- optional -{:%{}, [], [{{:optional, [], [:search_context_size]}, {{:., [], [ExOpenAI.Components.WebSearchContextSize, :t]}, [], []}}, {{:optional, [], [:user_location]}, {:|, [], [{:%{}, [], [{{:required, [], [:approximate]}, {{:., [], [ExOpenAI.Components.WebSearchLocation, :t]}, [], []}}, {{:required, [], [:type]}, :approximate}]}, nil]}}]}
This tool searches the web for relevant results to use in a response. Learn more about the web search tool.
Summary
Types
@type t() :: %ExOpenAI.Components.CreateChatCompletionRequest{ audio: %{ format: ((((:wav | :aac) | :mp3) | :flac) | :opus) | :pcm16, voice: ExOpenAI.Components.VoiceIdsOrCustomVoice.t() } | nil, frequency_penalty: number() | nil, function_call: ((:none | :auto) | ExOpenAI.Components.ChatCompletionFunctionCallOption.t()) | nil, functions: [ExOpenAI.Components.ChatCompletionFunctions.t()] | nil, logit_bias: map() | nil, logprobs: boolean() | nil, max_completion_tokens: integer() | nil, max_tokens: integer() | nil, messages: [ExOpenAI.Components.ChatCompletionRequestMessage.t()], metadata: ExOpenAI.Components.Metadata.t() | nil, modalities: ExOpenAI.Components.ResponseModalities.t() | nil, model: ExOpenAI.Components.ModelIdsShared.t(), n: integer() | nil, parallel_tool_calls: ExOpenAI.Components.ParallelToolCalls.t() | nil, prediction: ExOpenAI.Components.PredictionContent.t() | nil, presence_penalty: number() | nil, prompt_cache_key: String.t() | nil, prompt_cache_retention: ((:"in-memory" | :"24h") | any()) | nil, reasoning_effort: ExOpenAI.Components.ReasoningEffort.t() | nil, response_format: ((ExOpenAI.Components.ResponseFormatText.t() | ExOpenAI.Components.ResponseFormatJsonSchema.t()) | ExOpenAI.Components.ResponseFormatJsonObject.t()) | nil, safety_identifier: String.t() | nil, seed: integer() | nil, service_tier: ExOpenAI.Components.ServiceTier.t() | nil, stop: ExOpenAI.Components.StopConfiguration.t() | nil, store: boolean() | nil, stream: boolean() | nil, stream_options: ExOpenAI.Components.ChatCompletionStreamOptions.t() | nil, temperature: (number() | any()) | nil, tool_choice: ExOpenAI.Components.ChatCompletionToolChoiceOption.t() | nil, tools: [ ExOpenAI.Components.ChatCompletionTool.t() | ExOpenAI.Components.CustomToolChatCompletions.t() ] | nil, top_logprobs: integer() | nil, top_p: (number() | any()) | nil, user: String.t() | nil, verbosity: ExOpenAI.Components.Verbosity.t() | nil, web_search_options: %{ optional(:search_context_size) => ExOpenAI.Components.WebSearchContextSize.t(), optional(:user_location) => %{ approximate: ExOpenAI.Components.WebSearchLocation.t(), type: :approximate } | nil } | nil }