Class: Telnyx::Models::AI::ChatCompletionRequest
- Inherits:
-
Internal::Type::BaseModel
- Object
- Internal::Type::BaseModel
- Telnyx::Models::AI::ChatCompletionRequest
- Defined in:
- lib/telnyx/models/ai/chat_completion_request.rb,
sig/telnyx/models/ai/chat_completion_request.rbs
Direct Known Subclasses
ChatCreateCompletionParams, OpenAI::ChatCreateCompletionParams
Defined Under Namespace
Modules: Stop, Tool, ToolChoice Classes: Message, ResponseFormat
Instance Attribute Summary collapse
-
#api_key_ref ⇒ String?
If you are using an external inference provider like xAI or OpenAI, this field allows you to pass along a reference to your API key.
-
#best_of ⇒ Integer?
This is used with
use_beam_searchto determine how many candidate beams to explore. -
#early_stopping ⇒ Boolean?
This is used with
use_beam_search. -
#enable_thinking ⇒ Boolean?
Whether to enable the thinking/reasoning phase for models that support it (e.g., QwQ, Qwen3).
-
#frequency_penalty ⇒ Float?
Higher values will penalize the model from repeating the same output tokens.
-
#guided_choice ⇒ Array<String>?
If specified, the output will be exactly one of the choices.
-
#guided_json ⇒ Hash{Symbol=>Object}?
Must be a valid JSON schema.
-
#guided_regex ⇒ String?
If specified, the output will follow the regex pattern.
-
#length_penalty ⇒ Float?
This is used with
use_beam_searchto prefer shorter or longer completions. -
#logprobs ⇒ Boolean?
Whether to return log probabilities of the output tokens or not.
-
#max_tokens ⇒ Integer?
Maximum number of completion tokens the model should generate.
-
#messages ⇒ Array<Telnyx::Models::AI::ChatCompletionRequest::Message>
A list of the previous chat messages for context.
-
#min_p ⇒ Float?
This is an alternative to
top_pthat many prefer. -
#model ⇒ String?
The language model to chat with.
-
#n ⇒ Float?
This will return multiple choices for you instead of a single chat completion.
-
#presence_penalty ⇒ Float?
Higher values will penalize the model from repeating the same output tokens.
-
#response_format ⇒ Telnyx::Models::AI::ChatCompletionRequest::ResponseFormat?
Use this is you want to guarantee a JSON output without defining a schema.
-
#seed ⇒ Integer?
If specified, the system will make a best effort to sample deterministically, such that repeated requests with the same
seedand parameters should return the same result. -
#stop ⇒ String, ...
Up to 4 sequences where the API will stop generating further tokens.
-
#stream ⇒ Boolean?
Whether or not to stream data-only server-sent events as they become available.
-
#temperature ⇒ Float?
Adjusts the "creativity" of the model.
- #tool_choice ⇒ Symbol, ...
-
#tools ⇒ Array<Telnyx::Models::AI::ChatCompletionRequest::Tool::Function, Telnyx::Models::AI::ChatCompletionRequest::Tool::Retrieval>?
The
functiontool type follows the same schema as the OpenAI Chat Completions API. -
#top_logprobs ⇒ Integer?
This is used with
logprobs. -
#top_p ⇒ Float?
An alternative or complement to
temperature. -
#use_beam_search ⇒ Boolean?
Setting this to
truewill allow the model to explore more completion options.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize ⇒ Object constructor
- #to_hash ⇒ {
Methods inherited from Internal::Type::BaseModel
==, #==, #[], coerce, #deconstruct_keys, #deep_to_h, dump, fields, hash, #hash, inherited, inspect, #inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml
Methods included from Internal::Type::Converter
#coerce, coerce, #dump, dump, #inspect, inspect, meta_info, new_coerce_state, type_info
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize ⇒ Object
145 |
# File 'sig/telnyx/models/ai/chat_completion_request.rbs', line 145
def initialize: (
|
Instance Attribute Details
#api_key_ref ⇒ String?
If you are using an external inference provider like xAI or OpenAI, this field
allows you to pass along a reference to your API key. After creating an
integration secret
for you API key, pass the secret's identifier in this field.
20 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 20 optional :api_key_ref, String |
#best_of ⇒ Integer?
This is used with use_beam_search to determine how many candidate beams to
explore.
27 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 27 optional :best_of, Integer |
#early_stopping ⇒ Boolean?
This is used with use_beam_search. If true, generation stops as soon as
there are best_of complete candidates; if false, a heuristic is applied and
the generation stops when is it very unlikely to find better candidates.
35 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 35 optional :early_stopping, Telnyx::Internal::Type::Boolean |
#enable_thinking ⇒ Boolean?
Whether to enable the thinking/reasoning phase for models that support it (e.g., QwQ, Qwen3). When set to false, the model will skip the internal reasoning step and respond directly, which can reduce latency. Defaults to true.
43 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 43 optional :enable_thinking, Telnyx::Internal::Type::Boolean |
#frequency_penalty ⇒ Float?
Higher values will penalize the model from repeating the same output tokens.
49 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 49 optional :frequency_penalty, Float |
#guided_choice ⇒ Array<String>?
If specified, the output will be exactly one of the choices.
55 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 55 optional :guided_choice, Telnyx::Internal::Type::ArrayOf[String] |
#guided_json ⇒ Hash{Symbol=>Object}?
Must be a valid JSON schema. If specified, the output will follow the JSON schema.
62 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 62 optional :guided_json, Telnyx::Internal::Type::HashOf[Telnyx::Internal::Type::Unknown] |
#guided_regex ⇒ String?
If specified, the output will follow the regex pattern.
68 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 68 optional :guided_regex, String |
#length_penalty ⇒ Float?
This is used with use_beam_search to prefer shorter or longer completions.
74 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 74 optional :length_penalty, Float |
#logprobs ⇒ Boolean?
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 of
message.
82 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 82 optional :logprobs, Telnyx::Internal::Type::Boolean |
#max_tokens ⇒ Integer?
Maximum number of completion tokens the model should generate.
88 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 88 optional :max_tokens, Integer |
#messages ⇒ Array<Telnyx::Models::AI::ChatCompletionRequest::Message>
A list of the previous chat messages for context.
11 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 11 required :messages, -> { Telnyx::Internal::Type::ArrayOf[Telnyx::AI::ChatCompletionRequest::Message] } |
#min_p ⇒ Float?
This is an alternative to top_p that
many prefer. Must be
in [0, 1].
96 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 96 optional :min_p, Float |
#model ⇒ String?
The language model to chat with.
102 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 102 optional :model, String |
#n ⇒ Float?
This will return multiple choices for you instead of a single chat completion.
108 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 108 optional :n, Float |
#presence_penalty ⇒ Float?
Higher values will penalize the model from repeating the same output tokens.
114 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 114 optional :presence_penalty, Float |
#response_format ⇒ Telnyx::Models::AI::ChatCompletionRequest::ResponseFormat?
Use this is you want to guarantee a JSON output without defining a schema. For
control over the schema, use guided_json.
121 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 121 optional :response_format, -> { Telnyx::AI::ChatCompletionRequest::ResponseFormat } |
#seed ⇒ Integer?
If specified, the system will make a best effort to sample deterministically,
such that repeated requests with the same seed and parameters should return
the same result.
129 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 129 optional :seed, Integer |
#stop ⇒ String, ...
Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
136 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 136 optional :stop, union: -> { Telnyx::AI::ChatCompletionRequest::Stop } |
#stream ⇒ Boolean?
Whether or not to stream data-only server-sent events as they become available.
142 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 142 optional :stream, Telnyx::Internal::Type::Boolean |
#temperature ⇒ Float?
Adjusts the "creativity" of the model. Lower values make the model more deterministic and repetitive, while higher values make the model more random and creative.
150 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 150 optional :temperature, Float |
#tool_choice ⇒ Symbol, ...
155 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 155 optional :tool_choice, enum: -> { Telnyx::AI::ChatCompletionRequest::ToolChoice } |
#tools ⇒ Array<Telnyx::Models::AI::ChatCompletionRequest::Tool::Function, Telnyx::Models::AI::ChatCompletionRequest::Tool::Retrieval>?
The function tool type follows the same schema as the
OpenAI Chat Completions API.
The retrieval tool type is unique to Telnyx. You may pass a list of
embedded storage buckets
for retrieval-augmented generation.
165 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 165 optional :tools, -> { Telnyx::Internal::Type::ArrayOf[union: Telnyx::AI::ChatCompletionRequest::Tool] } |
#top_logprobs ⇒ Integer?
This is used with logprobs. 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.
173 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 173 optional :top_logprobs, Integer |
#top_p ⇒ Float?
An alternative or complement to temperature. This adjusts how many of the top
possibilities to consider.
180 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 180 optional :top_p, Float |
#use_beam_search ⇒ Boolean?
Setting this to true will allow the model to
explore more completion options.
This is not supported by OpenAI.
188 |
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 188 optional :use_beam_search, Telnyx::Internal::Type::Boolean |
Class Method Details
.values ⇒ Array<Symbol>
|
|
# File 'lib/telnyx/models/ai/chat_completion_request.rb', line 321
|
Instance Method Details
#to_hash ⇒ {
174 |
# File 'sig/telnyx/models/ai/chat_completion_request.rbs', line 174
def to_hash: -> {
|