telnyx 5.100.0 → 5.102.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +1 -1
  4. data/lib/telnyx/models/ai/chat_create_completion_params.rb +36 -1
  5. data/lib/telnyx/models/ai/openai/chat_create_completion_params.rb +458 -0
  6. data/lib/telnyx/models/ai/openai/chat_create_completion_response.rb +12 -0
  7. data/lib/telnyx/models/ai/openai_list_models_params.rb +16 -0
  8. data/lib/telnyx/models/ai/openai_list_models_response.rb +52 -0
  9. data/lib/telnyx/resources/ai/chat.rb +9 -2
  10. data/lib/telnyx/resources/ai/openai/chat.rb +96 -0
  11. data/lib/telnyx/resources/ai/openai.rb +26 -0
  12. data/lib/telnyx/resources/ai.rb +7 -5
  13. data/lib/telnyx/resources/messaging_10dlc/brand/external_vetting.rb +5 -1
  14. data/lib/telnyx/version.rb +1 -1
  15. data/lib/telnyx.rb +5 -0
  16. data/rbi/telnyx/models/ai/chat_create_completion_params.rbi +58 -0
  17. data/rbi/telnyx/models/ai/openai/chat_create_completion_params.rbi +963 -0
  18. data/rbi/telnyx/models/ai/openai/chat_create_completion_response.rbi +15 -0
  19. data/rbi/telnyx/models/ai/openai_list_models_params.rbi +29 -0
  20. data/rbi/telnyx/models/ai/openai_list_models_response.rbi +96 -0
  21. data/rbi/telnyx/resources/ai/chat.rbi +11 -1
  22. data/rbi/telnyx/resources/ai/openai/chat.rbi +147 -0
  23. data/rbi/telnyx/resources/ai/openai.rbi +16 -0
  24. data/rbi/telnyx/resources/ai.rbi +5 -5
  25. data/rbi/telnyx/resources/messaging_10dlc/brand/external_vetting.rbi +5 -1
  26. data/sig/telnyx/models/ai/chat_create_completion_params.rbs +26 -0
  27. data/sig/telnyx/models/ai/openai/chat_create_completion_params.rbs +434 -0
  28. data/sig/telnyx/models/ai/openai/chat_create_completion_response.rbs +11 -0
  29. data/sig/telnyx/models/ai/openai_list_models_params.rbs +17 -0
  30. data/sig/telnyx/models/ai/openai_list_models_response.rbs +58 -0
  31. data/sig/telnyx/resources/ai/chat.rbs +2 -0
  32. data/sig/telnyx/resources/ai/openai/chat.rbs +41 -0
  33. data/sig/telnyx/resources/ai/openai.rbs +6 -0
  34. metadata +17 -2
@@ -0,0 +1,15 @@
1
+ # typed: strong
2
+
3
+ module Telnyx
4
+ module Models
5
+ module AI
6
+ module OpenAI
7
+ ChatCreateCompletionResponse =
8
+ T.let(
9
+ Telnyx::Internal::Type::HashOf[Telnyx::Internal::Type::Unknown],
10
+ Telnyx::Internal::Type::Converter
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ # typed: strong
2
+
3
+ module Telnyx
4
+ module Models
5
+ module AI
6
+ class OpenAIListModelsParams < Telnyx::Internal::Type::BaseModel
7
+ extend Telnyx::Internal::Type::RequestParameters::Converter
8
+ include Telnyx::Internal::Type::RequestParameters
9
+
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(Telnyx::AI::OpenAIListModelsParams, Telnyx::Internal::AnyHash)
13
+ end
14
+
15
+ sig do
16
+ params(request_options: Telnyx::RequestOptions::OrHash).returns(
17
+ T.attached_class
18
+ )
19
+ end
20
+ def self.new(request_options: {})
21
+ end
22
+
23
+ sig { override.returns({ request_options: Telnyx::RequestOptions }) }
24
+ def to_hash
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,96 @@
1
+ # typed: strong
2
+
3
+ module Telnyx
4
+ module Models
5
+ module AI
6
+ class OpenAIListModelsResponse < Telnyx::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ Telnyx::Models::AI::OpenAIListModelsResponse,
11
+ Telnyx::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ sig do
16
+ returns(T::Array[Telnyx::Models::AI::OpenAIListModelsResponse::Data])
17
+ end
18
+ attr_accessor :data
19
+
20
+ sig { returns(T.nilable(String)) }
21
+ attr_reader :object
22
+
23
+ sig { params(object: String).void }
24
+ attr_writer :object
25
+
26
+ sig do
27
+ params(
28
+ data:
29
+ T::Array[
30
+ Telnyx::Models::AI::OpenAIListModelsResponse::Data::OrHash
31
+ ],
32
+ object: String
33
+ ).returns(T.attached_class)
34
+ end
35
+ def self.new(data:, object: nil)
36
+ end
37
+
38
+ sig do
39
+ override.returns(
40
+ {
41
+ data:
42
+ T::Array[Telnyx::Models::AI::OpenAIListModelsResponse::Data],
43
+ object: String
44
+ }
45
+ )
46
+ end
47
+ def to_hash
48
+ end
49
+
50
+ class Data < Telnyx::Internal::Type::BaseModel
51
+ OrHash =
52
+ T.type_alias do
53
+ T.any(
54
+ Telnyx::Models::AI::OpenAIListModelsResponse::Data,
55
+ Telnyx::Internal::AnyHash
56
+ )
57
+ end
58
+
59
+ sig { returns(String) }
60
+ attr_accessor :id
61
+
62
+ sig { returns(Integer) }
63
+ attr_accessor :created
64
+
65
+ sig { returns(String) }
66
+ attr_accessor :owned_by
67
+
68
+ sig { returns(T.nilable(String)) }
69
+ attr_reader :object
70
+
71
+ sig { params(object: String).void }
72
+ attr_writer :object
73
+
74
+ sig do
75
+ params(
76
+ id: String,
77
+ created: Integer,
78
+ owned_by: String,
79
+ object: String
80
+ ).returns(T.attached_class)
81
+ end
82
+ def self.new(id:, created:, owned_by:, object: nil)
83
+ end
84
+
85
+ sig do
86
+ override.returns(
87
+ { id: String, created: Integer, owned_by: String, object: String }
88
+ )
89
+ end
90
+ def to_hash
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -5,7 +5,8 @@ module Telnyx
5
5
  class AI
6
6
  # Generate text with LLMs
7
7
  class Chat
8
- # Chat with a language model. This endpoint is consistent with the
8
+ # **Deprecated**: Use `POST /v2/ai/openai/chat/completions` instead. Chat with a
9
+ # language model. This endpoint is consistent with the
9
10
  # [OpenAI Chat Completions API](https://platform.openai.com/docs/api-reference/chat)
10
11
  # and may be used with the OpenAI JS or Python SDK.
11
12
  sig do
@@ -29,6 +30,8 @@ module Telnyx
29
30
  presence_penalty: Float,
30
31
  response_format:
31
32
  Telnyx::AI::ChatCreateCompletionParams::ResponseFormat::OrHash,
33
+ seed: Integer,
34
+ stop: Telnyx::AI::ChatCreateCompletionParams::Stop::Variants,
32
35
  stream: T::Boolean,
33
36
  temperature: Float,
34
37
  tool_choice:
@@ -95,6 +98,13 @@ module Telnyx
95
98
  # Use this is you want to guarantee a JSON output without defining a schema. For
96
99
  # control over the schema, use `guided_json`.
97
100
  response_format: nil,
101
+ # If specified, the system will make a best effort to sample deterministically,
102
+ # such that repeated requests with the same `seed` and parameters should return
103
+ # the same result.
104
+ seed: nil,
105
+ # Up to 4 sequences where the API will stop generating further tokens. The
106
+ # returned text will not contain the stop sequence.
107
+ stop: nil,
98
108
  # Whether or not to stream data-only server-sent events as they become available.
99
109
  stream: nil,
100
110
  # Adjusts the "creativity" of the model. Lower values make the model more
@@ -0,0 +1,147 @@
1
+ # typed: strong
2
+
3
+ module Telnyx
4
+ module Resources
5
+ class AI
6
+ class OpenAI
7
+ class Chat
8
+ # Chat with a language model. This endpoint is consistent with the
9
+ # [OpenAI Chat Completions API](https://platform.openai.com/docs/api-reference/chat)
10
+ # and may be used with the OpenAI JS or Python SDK by setting the base URL to
11
+ # `https://api.telnyx.com/v2/ai/openai`.
12
+ sig do
13
+ params(
14
+ messages:
15
+ T::Array[
16
+ Telnyx::AI::OpenAI::ChatCreateCompletionParams::Message::OrHash
17
+ ],
18
+ api_key_ref: String,
19
+ best_of: Integer,
20
+ early_stopping: T::Boolean,
21
+ enable_thinking: T::Boolean,
22
+ frequency_penalty: Float,
23
+ guided_choice: T::Array[String],
24
+ guided_json: T::Hash[Symbol, T.anything],
25
+ guided_regex: String,
26
+ length_penalty: Float,
27
+ logprobs: T::Boolean,
28
+ max_tokens: Integer,
29
+ min_p: Float,
30
+ model: String,
31
+ n: Float,
32
+ presence_penalty: Float,
33
+ response_format:
34
+ Telnyx::AI::OpenAI::ChatCreateCompletionParams::ResponseFormat::OrHash,
35
+ seed: Integer,
36
+ stop:
37
+ Telnyx::AI::OpenAI::ChatCreateCompletionParams::Stop::Variants,
38
+ stream: T::Boolean,
39
+ temperature: Float,
40
+ tool_choice:
41
+ Telnyx::AI::OpenAI::ChatCreateCompletionParams::ToolChoice::OrSymbol,
42
+ tools:
43
+ T::Array[
44
+ T.any(
45
+ Telnyx::AI::OpenAI::ChatCreateCompletionParams::Tool::Function::OrHash,
46
+ Telnyx::AI::OpenAI::ChatCreateCompletionParams::Tool::Retrieval::OrHash
47
+ )
48
+ ],
49
+ top_logprobs: Integer,
50
+ top_p: Float,
51
+ use_beam_search: T::Boolean,
52
+ request_options: Telnyx::RequestOptions::OrHash
53
+ ).returns(T::Hash[Symbol, T.anything])
54
+ end
55
+ def create_completion(
56
+ # A list of the previous chat messages for context.
57
+ messages:,
58
+ # If you are using an external inference provider like xAI or OpenAI, this field
59
+ # allows you to pass along a reference to your API key. After creating an
60
+ # [integration secret](https://developers.telnyx.com/api-reference/integration-secrets/create-a-secret)
61
+ # for you API key, pass the secret's `identifier` in this field.
62
+ api_key_ref: nil,
63
+ # This is used with `use_beam_search` to determine how many candidate beams to
64
+ # explore.
65
+ best_of: nil,
66
+ # This is used with `use_beam_search`. If `true`, generation stops as soon as
67
+ # there are `best_of` complete candidates; if `false`, a heuristic is applied and
68
+ # the generation stops when is it very unlikely to find better candidates.
69
+ early_stopping: nil,
70
+ # Whether to enable the thinking/reasoning phase for models that support it (e.g.,
71
+ # QwQ, Qwen3). When set to false, the model will skip the internal reasoning step
72
+ # and respond directly, which can reduce latency. Defaults to true.
73
+ enable_thinking: nil,
74
+ # Higher values will penalize the model from repeating the same output tokens.
75
+ frequency_penalty: nil,
76
+ # If specified, the output will be exactly one of the choices.
77
+ guided_choice: nil,
78
+ # Must be a valid JSON schema. If specified, the output will follow the JSON
79
+ # schema.
80
+ guided_json: nil,
81
+ # If specified, the output will follow the regex pattern.
82
+ guided_regex: nil,
83
+ # This is used with `use_beam_search` to prefer shorter or longer completions.
84
+ length_penalty: nil,
85
+ # Whether to return log probabilities of the output tokens or not. If true,
86
+ # returns the log probabilities of each output token returned in the `content` of
87
+ # `message`.
88
+ logprobs: nil,
89
+ # Maximum number of completion tokens the model should generate.
90
+ max_tokens: nil,
91
+ # This is an alternative to `top_p` that
92
+ # [many prefer](https://github.com/huggingface/transformers/issues/27670). Must be
93
+ # in [0, 1].
94
+ min_p: nil,
95
+ # The language model to chat with.
96
+ model: nil,
97
+ # This will return multiple choices for you instead of a single chat completion.
98
+ n: nil,
99
+ # Higher values will penalize the model from repeating the same output tokens.
100
+ presence_penalty: nil,
101
+ # Use this is you want to guarantee a JSON output without defining a schema. For
102
+ # control over the schema, use `guided_json`.
103
+ response_format: nil,
104
+ # If specified, the system will make a best effort to sample deterministically,
105
+ # such that repeated requests with the same `seed` and parameters should return
106
+ # the same result.
107
+ seed: nil,
108
+ # Up to 4 sequences where the API will stop generating further tokens. The
109
+ # returned text will not contain the stop sequence.
110
+ stop: nil,
111
+ # Whether or not to stream data-only server-sent events as they become available.
112
+ stream: nil,
113
+ # Adjusts the "creativity" of the model. Lower values make the model more
114
+ # deterministic and repetitive, while higher values make the model more random and
115
+ # creative.
116
+ temperature: nil,
117
+ tool_choice: nil,
118
+ # The `function` tool type follows the same schema as the
119
+ # [OpenAI Chat Completions API](https://platform.openai.com/docs/api-reference/chat).
120
+ # The `retrieval` tool type is unique to Telnyx. You may pass a list of
121
+ # [embedded storage buckets](https://developers.telnyx.com/api-reference/embeddings/embed-documents)
122
+ # for retrieval-augmented generation.
123
+ tools: nil,
124
+ # This is used with `logprobs`. An integer between 0 and 20 specifying the number
125
+ # of most likely tokens to return at each token position, each with an associated
126
+ # log probability.
127
+ top_logprobs: nil,
128
+ # An alternative or complement to `temperature`. This adjusts how many of the top
129
+ # possibilities to consider.
130
+ top_p: nil,
131
+ # Setting this to `true` will allow the model to
132
+ # [explore more completion options](https://huggingface.co/blog/how-to-generate#beam-search).
133
+ # This is not supported by OpenAI.
134
+ use_beam_search: nil,
135
+ request_options: {}
136
+ )
137
+ end
138
+
139
+ # @api private
140
+ sig { params(client: Telnyx::Client).returns(T.attached_class) }
141
+ def self.new(client:)
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end
@@ -9,6 +9,22 @@ module Telnyx
9
9
  sig { returns(Telnyx::Resources::AI::OpenAI::Embeddings) }
10
10
  attr_reader :embeddings
11
11
 
12
+ sig { returns(Telnyx::Resources::AI::OpenAI::Chat) }
13
+ attr_reader :chat
14
+
15
+ # This endpoint returns a list of Open Source and OpenAI models that are available
16
+ # for use. <br /><br /> **Note**: Model `id`'s will be in the form
17
+ # `{source}/{model_name}`. For example `openai/gpt-4` or
18
+ # `mistralai/Mistral-7B-Instruct-v0.1` consistent with HuggingFace naming
19
+ # conventions.
20
+ sig do
21
+ params(request_options: Telnyx::RequestOptions::OrHash).returns(
22
+ Telnyx::Models::AI::OpenAIListModelsResponse
23
+ )
24
+ end
25
+ def list_models(request_options: {})
26
+ end
27
+
12
28
  # @api private
13
29
  sig { params(client: Telnyx::Client).returns(T.attached_class) }
14
30
  def self.new(client:)
@@ -46,11 +46,11 @@ module Telnyx
46
46
  sig { returns(Telnyx::Resources::AI::Tools) }
47
47
  attr_reader :tools
48
48
 
49
- # This endpoint returns a list of Open Source and OpenAI models that are available
50
- # for use. <br /><br /> **Note**: Model `id`'s will be in the form
51
- # `{source}/{model_name}`. For example `openai/gpt-4` or
52
- # `mistralai/Mistral-7B-Instruct-v0.1` consistent with HuggingFace naming
53
- # conventions.
49
+ # **Deprecated**: Use `GET /v2/ai/openai/models` instead. This endpoint returns a
50
+ # list of Open Source and OpenAI models that are available for use. <br /><br />
51
+ # **Note**: Model `id`'s will be in the form `{source}/{model_name}`. For example
52
+ # `openai/gpt-4` or `mistralai/Mistral-7B-Instruct-v0.1` consistent with
53
+ # HuggingFace naming conventions.
54
54
  sig do
55
55
  params(request_options: Telnyx::RequestOptions::OrHash).returns(
56
56
  Telnyx::Models::AIRetrieveModelsResponse
@@ -48,7 +48,11 @@ module Telnyx
48
48
  )
49
49
  end
50
50
 
51
- # Order new external vetting for a brand
51
+ # Order new external vetting for a brand.
52
+ #
53
+ # Duplicate orders for the same `evpId` and `vettingClass` return `400` with code
54
+ # `10012` if a successful vetting exists within the last 180 days, or one is
55
+ # currently being processed. Failed vettings can be retried immediately.
52
56
  sig do
53
57
  params(
54
58
  brand_id: String,
@@ -20,6 +20,8 @@ module Telnyx
20
20
  n: Float,
21
21
  presence_penalty: Float,
22
22
  response_format: Telnyx::AI::ChatCreateCompletionParams::ResponseFormat,
23
+ seed: Integer,
24
+ stop: Telnyx::Models::AI::ChatCreateCompletionParams::stop,
23
25
  stream: bool,
24
26
  temperature: Float,
25
27
  tool_choice: Telnyx::Models::AI::ChatCreateCompletionParams::tool_choice,
@@ -102,6 +104,16 @@ module Telnyx
102
104
  Telnyx::AI::ChatCreateCompletionParams::ResponseFormat
103
105
  ) -> Telnyx::AI::ChatCreateCompletionParams::ResponseFormat
104
106
 
107
+ attr_reader seed: Integer?
108
+
109
+ def seed=: (Integer) -> Integer
110
+
111
+ attr_reader stop: Telnyx::Models::AI::ChatCreateCompletionParams::stop?
112
+
113
+ def stop=: (
114
+ Telnyx::Models::AI::ChatCreateCompletionParams::stop
115
+ ) -> Telnyx::Models::AI::ChatCreateCompletionParams::stop
116
+
105
117
  attr_reader stream: bool?
106
118
 
107
119
  def stream=: (bool) -> bool
@@ -152,6 +164,8 @@ module Telnyx
152
164
  ?n: Float,
153
165
  ?presence_penalty: Float,
154
166
  ?response_format: Telnyx::AI::ChatCreateCompletionParams::ResponseFormat,
167
+ ?seed: Integer,
168
+ ?stop: Telnyx::Models::AI::ChatCreateCompletionParams::stop,
155
169
  ?stream: bool,
156
170
  ?temperature: Float,
157
171
  ?tool_choice: Telnyx::Models::AI::ChatCreateCompletionParams::tool_choice,
@@ -180,6 +194,8 @@ module Telnyx
180
194
  n: Float,
181
195
  presence_penalty: Float,
182
196
  response_format: Telnyx::AI::ChatCreateCompletionParams::ResponseFormat,
197
+ seed: Integer,
198
+ stop: Telnyx::Models::AI::ChatCreateCompletionParams::stop,
183
199
  stream: bool,
184
200
  temperature: Float,
185
201
  tool_choice: Telnyx::Models::AI::ChatCreateCompletionParams::tool_choice,
@@ -307,6 +323,16 @@ module Telnyx
307
323
  end
308
324
  end
309
325
 
326
+ type stop = String | ::Array[String]
327
+
328
+ module Stop
329
+ extend Telnyx::Internal::Type::Union
330
+
331
+ def self?.variants: -> ::Array[Telnyx::Models::AI::ChatCreateCompletionParams::stop]
332
+
333
+ StringArray: Telnyx::Internal::Type::Converter
334
+ end
335
+
310
336
  type tool_choice = :none | :auto | :required
311
337
 
312
338
  module ToolChoice