openai 0.65.0 → 0.66.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 (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +1 -1
  4. data/lib/openai/models/chat/chat_completion.rb +341 -3
  5. data/lib/openai/models/chat/chat_completion_chunk.rb +341 -1
  6. data/lib/openai/models/chat/completion_create_params.rb +26 -1
  7. data/lib/openai/models/responses/response.rb +275 -1
  8. data/lib/openai/models/responses/response_create_params.rb +26 -1
  9. data/lib/openai/models/responses/responses_client_event.rb +27 -1
  10. data/lib/openai/resources/chat/completions.rb +6 -2
  11. data/lib/openai/resources/responses.rb +6 -2
  12. data/lib/openai/version.rb +1 -1
  13. data/rbi/openai/models/chat/chat_completion.rbi +620 -3
  14. data/rbi/openai/models/chat/chat_completion_chunk.rbi +621 -0
  15. data/rbi/openai/models/chat/completion_create_params.rbi +52 -0
  16. data/rbi/openai/models/responses/response.rbi +485 -0
  17. data/rbi/openai/models/responses/response_create_params.rbi +54 -0
  18. data/rbi/openai/models/responses/responses_client_event.rbi +54 -0
  19. data/rbi/openai/resources/chat/completions.rbi +12 -0
  20. data/rbi/openai/resources/responses.rbi +12 -0
  21. data/sig/openai/models/chat/chat_completion.rbs +243 -0
  22. data/sig/openai/models/chat/chat_completion_chunk.rbs +243 -0
  23. data/sig/openai/models/chat/completion_create_params.rbs +15 -0
  24. data/sig/openai/models/responses/response.rbs +189 -0
  25. data/sig/openai/models/responses/response_create_params.rbs +15 -0
  26. data/sig/openai/models/responses/responses_client_event.rbs +15 -0
  27. data/sig/openai/resources/chat/completions.rbs +2 -0
  28. data/sig/openai/resources/responses.rbs +2 -0
  29. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a5fa30c047f790a8b47104b540af59fa63faead196ff665b549fca8fdcbc389
4
- data.tar.gz: 0f1c46ebe4c7124a099ccdc6e62cddf49450503fb2eb7457ee112cb5cd4d7a4a
3
+ metadata.gz: def61cc329e11cd35421f9669cecf9c9f58e909b6e1b6874261c1488c8002eb4
4
+ data.tar.gz: 1d32ed8ed65907e7345826dc5a8709c0d93d3525e1f18f807972b01ff8ce2547
5
5
  SHA512:
6
- metadata.gz: 79597c5c13502bb29dec186d69641c8d5df202c0d08af665b14b3169327c294a97a0c011a061d36ce7b30a9a44a6ca76ce47ab6aef8b25ed706aadaf9aa08d01
7
- data.tar.gz: 1eafbf4d2a836289e33500620ac9a1d258a252462437ae468bec5370867ed51423bf1de2e6e50dac3909f2b4d3b6dbca83c51e05d155948e2e43083971aae4b4
6
+ metadata.gz: b2ace6e03dce77274deacb50ebc17952721f235b7c3f9ef5b477b800baa9c08479eae1e9e8866b3426889a106230f10c8c1410119a6b9d1b1d4089c9515a5354
7
+ data.tar.gz: c23affbd799ec9c17f08004dedb608a56f8074ab117573bcc35b23871b4337c51ddbf2729b25639f6e319d01827822f4ca08881204791f02b2ab61fd2e5f4550
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.66.0 (2026-06-03)
4
+
5
+ Full Changelog: [v0.65.0...v0.66.0](https://github.com/openai/openai-ruby/compare/v0.65.0...v0.66.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** responses.moderation and chat_completions.moderation ([39eeb8b](https://github.com/openai/openai-ruby/commit/39eeb8b3152476aff78c54f196f2e360f58d3408))
10
+
3
11
  ## 0.65.0 (2026-06-01)
4
12
 
5
13
  Full Changelog: [v0.64.0...v0.65.0](https://github.com/openai/openai-ruby/compare/v0.64.0...v0.65.0)
data/README.md CHANGED
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
15
15
  <!-- x-release-please-start-version -->
16
16
 
17
17
  ```ruby
18
- gem "openai", "~> 0.65.0"
18
+ gem "openai", "~> 0.66.0"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -38,6 +38,13 @@ module OpenAI
38
38
  # @return [Symbol, :"chat.completion"]
39
39
  required :object, const: :"chat.completion"
40
40
 
41
+ # @!attribute moderation
42
+ # Moderation results for the request input and generated output, if moderated
43
+ # completions were requested.
44
+ #
45
+ # @return [OpenAI::Models::Chat::ChatCompletion::Moderation, nil]
46
+ optional :moderation, -> { OpenAI::Chat::ChatCompletion::Moderation }, nil?: true
47
+
41
48
  # @!attribute service_tier
42
49
  # Specifies the processing type used for serving the request.
43
50
  #
@@ -76,7 +83,7 @@ module OpenAI
76
83
  # @return [OpenAI::Models::CompletionUsage, nil]
77
84
  optional :usage, -> { OpenAI::CompletionUsage }
78
85
 
79
- # @!method initialize(id:, choices:, created:, model:, service_tier: nil, system_fingerprint: nil, usage: nil, object: :"chat.completion")
86
+ # @!method initialize(id:, choices:, created:, model:, moderation: nil, service_tier: nil, system_fingerprint: nil, usage: nil, object: :"chat.completion")
80
87
  # Some parameter documentations has been truncated, see
81
88
  # {OpenAI::Models::Chat::ChatCompletion} for more details.
82
89
  #
@@ -91,6 +98,8 @@ module OpenAI
91
98
  #
92
99
  # @param model [String] The model used for the chat completion.
93
100
  #
101
+ # @param moderation [OpenAI::Models::Chat::ChatCompletion::Moderation, nil] Moderation results for the request input and generated output, if moderated
102
+ #
94
103
  # @param service_tier [Symbol, OpenAI::Models::Chat::ChatCompletion::ServiceTier, nil] Specifies the processing type used for serving the request.
95
104
  #
96
105
  # @param system_fingerprint [String] This fingerprint represents the backend configuration that the model runs with.
@@ -106,7 +115,8 @@ module OpenAI
106
115
  # number of tokens specified in the request was reached, `content_filter` if
107
116
  # content was omitted due to a flag from our content filters, `tool_calls` if the
108
117
  # model called a tool, or `function_call` (deprecated) if the model called a
109
- # function.
118
+ # function. Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html)
119
+ # for more.
110
120
  #
111
121
  # @return [Symbol, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason]
112
122
  required :finish_reason, enum: -> { OpenAI::Chat::ChatCompletion::Choice::FinishReason }
@@ -146,7 +156,8 @@ module OpenAI
146
156
  # number of tokens specified in the request was reached, `content_filter` if
147
157
  # content was omitted due to a flag from our content filters, `tool_calls` if the
148
158
  # model called a tool, or `function_call` (deprecated) if the model called a
149
- # function.
159
+ # function. Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html)
160
+ # for more.
150
161
  #
151
162
  # @see OpenAI::Models::Chat::ChatCompletion::Choice#finish_reason
152
163
  module FinishReason
@@ -189,6 +200,333 @@ module OpenAI
189
200
  end
190
201
  end
191
202
 
203
+ # @see OpenAI::Models::Chat::ChatCompletion#moderation
204
+ class Moderation < OpenAI::Internal::Type::BaseModel
205
+ # @!attribute input
206
+ # Moderation for the request input.
207
+ #
208
+ # @return [OpenAI::Models::Chat::ChatCompletion::Moderation::Input::ModerationResults, OpenAI::Models::Chat::ChatCompletion::Moderation::Input::Error]
209
+ required :input, union: -> { OpenAI::Chat::ChatCompletion::Moderation::Input }
210
+
211
+ # @!attribute output
212
+ # Moderation for the generated output.
213
+ #
214
+ # @return [OpenAI::Models::Chat::ChatCompletion::Moderation::Output::ModerationResults, OpenAI::Models::Chat::ChatCompletion::Moderation::Output::Error]
215
+ required :output, union: -> { OpenAI::Chat::ChatCompletion::Moderation::Output }
216
+
217
+ # @!method initialize(input:, output:)
218
+ # Moderation results for the request input and generated output, if moderated
219
+ # completions were requested.
220
+ #
221
+ # @param input [OpenAI::Models::Chat::ChatCompletion::Moderation::Input::ModerationResults, OpenAI::Models::Chat::ChatCompletion::Moderation::Input::Error] Moderation for the request input.
222
+ #
223
+ # @param output [OpenAI::Models::Chat::ChatCompletion::Moderation::Output::ModerationResults, OpenAI::Models::Chat::ChatCompletion::Moderation::Output::Error] Moderation for the generated output.
224
+
225
+ # Moderation for the request input.
226
+ #
227
+ # @see OpenAI::Models::Chat::ChatCompletion::Moderation#input
228
+ module Input
229
+ extend OpenAI::Internal::Type::Union
230
+
231
+ discriminator :type
232
+
233
+ # Successful moderation results for the request input or generated output.
234
+ variant :moderation_results, -> { OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults }
235
+
236
+ # An error produced while attempting moderation.
237
+ variant :error, -> { OpenAI::Chat::ChatCompletion::Moderation::Input::Error }
238
+
239
+ class ModerationResults < OpenAI::Internal::Type::BaseModel
240
+ # @!attribute model
241
+ # The moderation model used to generate the results.
242
+ #
243
+ # @return [String]
244
+ required :model, String
245
+
246
+ # @!attribute results
247
+ # A list of moderation results.
248
+ #
249
+ # @return [Array<OpenAI::Models::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result>]
250
+ required :results,
251
+ -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result] }
252
+
253
+ # @!attribute type
254
+ # The object type, which is always `moderation_results`.
255
+ #
256
+ # @return [Symbol, :moderation_results]
257
+ required :type, const: :moderation_results
258
+
259
+ # @!method initialize(model:, results:, type: :moderation_results)
260
+ # Successful moderation results for the request input or generated output.
261
+ #
262
+ # @param model [String] The moderation model used to generate the results.
263
+ #
264
+ # @param results [Array<OpenAI::Models::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result>] A list of moderation results.
265
+ #
266
+ # @param type [Symbol, :moderation_results] The object type, which is always `moderation_results`.
267
+
268
+ class Result < OpenAI::Internal::Type::BaseModel
269
+ # @!attribute categories
270
+ # A dictionary of moderation categories to booleans, True if the input is flagged
271
+ # under this category.
272
+ #
273
+ # @return [Hash{Symbol=>Boolean}]
274
+ required :categories, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Boolean]
275
+
276
+ # @!attribute category_applied_input_types
277
+ # Which modalities of input are reflected by the score for each category.
278
+ #
279
+ # @return [Hash{Symbol=>Array<Symbol, OpenAI::Models::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::CategoryAppliedInputType>}]
280
+ required :category_applied_input_types,
281
+ -> do
282
+ OpenAI::Internal::Type::HashOf[
283
+ OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::CategoryAppliedInputType]
284
+ ]
285
+ end
286
+
287
+ # @!attribute category_scores
288
+ # A dictionary of moderation categories to scores.
289
+ #
290
+ # @return [Hash{Symbol=>Float}]
291
+ required :category_scores, OpenAI::Internal::Type::HashOf[Float]
292
+
293
+ # @!attribute flagged
294
+ # A boolean indicating whether the content was flagged by any category.
295
+ #
296
+ # @return [Boolean]
297
+ required :flagged, OpenAI::Internal::Type::Boolean
298
+
299
+ # @!attribute model
300
+ # The moderation model that produced this result.
301
+ #
302
+ # @return [String]
303
+ required :model, String
304
+
305
+ # @!attribute type
306
+ # The object type, which was always `moderation_result` for successful moderation
307
+ # results.
308
+ #
309
+ # @return [Symbol, :moderation_result]
310
+ required :type, const: :moderation_result
311
+
312
+ # @!method initialize(categories:, category_applied_input_types:, category_scores:, flagged:, model:, type: :moderation_result)
313
+ # Some parameter documentations has been truncated, see
314
+ # {OpenAI::Models::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result}
315
+ # for more details.
316
+ #
317
+ # A moderation result produced for the response input or output.
318
+ #
319
+ # @param categories [Hash{Symbol=>Boolean}] A dictionary of moderation categories to booleans, True if the input is flagged
320
+ #
321
+ # @param category_applied_input_types [Hash{Symbol=>Array<Symbol, OpenAI::Models::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::CategoryAppliedInputType>}] Which modalities of input are reflected by the score for each category.
322
+ #
323
+ # @param category_scores [Hash{Symbol=>Float}] A dictionary of moderation categories to scores.
324
+ #
325
+ # @param flagged [Boolean] A boolean indicating whether the content was flagged by any category.
326
+ #
327
+ # @param model [String] The moderation model that produced this result.
328
+ #
329
+ # @param type [Symbol, :moderation_result] The object type, which was always `moderation_result` for successful moderation
330
+
331
+ module CategoryAppliedInputType
332
+ extend OpenAI::Internal::Type::Enum
333
+
334
+ TEXT = :text
335
+ IMAGE = :image
336
+
337
+ # @!method self.values
338
+ # @return [Array<Symbol>]
339
+ end
340
+ end
341
+ end
342
+
343
+ class Error < OpenAI::Internal::Type::BaseModel
344
+ # @!attribute code
345
+ # The error code.
346
+ #
347
+ # @return [String]
348
+ required :code, String
349
+
350
+ # @!attribute message
351
+ # The error message.
352
+ #
353
+ # @return [String]
354
+ required :message, String
355
+
356
+ # @!attribute type
357
+ # The object type, which is always `error`.
358
+ #
359
+ # @return [Symbol, :error]
360
+ required :type, const: :error
361
+
362
+ # @!method initialize(code:, message:, type: :error)
363
+ # An error produced while attempting moderation.
364
+ #
365
+ # @param code [String] The error code.
366
+ #
367
+ # @param message [String] The error message.
368
+ #
369
+ # @param type [Symbol, :error] The object type, which is always `error`.
370
+ end
371
+
372
+ # @!method self.variants
373
+ # @return [Array(OpenAI::Models::Chat::ChatCompletion::Moderation::Input::ModerationResults, OpenAI::Models::Chat::ChatCompletion::Moderation::Input::Error)]
374
+ end
375
+
376
+ # Moderation for the generated output.
377
+ #
378
+ # @see OpenAI::Models::Chat::ChatCompletion::Moderation#output
379
+ module Output
380
+ extend OpenAI::Internal::Type::Union
381
+
382
+ discriminator :type
383
+
384
+ # Successful moderation results for the request input or generated output.
385
+ variant :moderation_results, -> { OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults }
386
+
387
+ # An error produced while attempting moderation.
388
+ variant :error, -> { OpenAI::Chat::ChatCompletion::Moderation::Output::Error }
389
+
390
+ class ModerationResults < OpenAI::Internal::Type::BaseModel
391
+ # @!attribute model
392
+ # The moderation model used to generate the results.
393
+ #
394
+ # @return [String]
395
+ required :model, String
396
+
397
+ # @!attribute results
398
+ # A list of moderation results.
399
+ #
400
+ # @return [Array<OpenAI::Models::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result>]
401
+ required :results,
402
+ -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result] }
403
+
404
+ # @!attribute type
405
+ # The object type, which is always `moderation_results`.
406
+ #
407
+ # @return [Symbol, :moderation_results]
408
+ required :type, const: :moderation_results
409
+
410
+ # @!method initialize(model:, results:, type: :moderation_results)
411
+ # Successful moderation results for the request input or generated output.
412
+ #
413
+ # @param model [String] The moderation model used to generate the results.
414
+ #
415
+ # @param results [Array<OpenAI::Models::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result>] A list of moderation results.
416
+ #
417
+ # @param type [Symbol, :moderation_results] The object type, which is always `moderation_results`.
418
+
419
+ class Result < OpenAI::Internal::Type::BaseModel
420
+ # @!attribute categories
421
+ # A dictionary of moderation categories to booleans, True if the input is flagged
422
+ # under this category.
423
+ #
424
+ # @return [Hash{Symbol=>Boolean}]
425
+ required :categories, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Boolean]
426
+
427
+ # @!attribute category_applied_input_types
428
+ # Which modalities of input are reflected by the score for each category.
429
+ #
430
+ # @return [Hash{Symbol=>Array<Symbol, OpenAI::Models::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType>}]
431
+ required :category_applied_input_types,
432
+ -> do
433
+ OpenAI::Internal::Type::HashOf[
434
+ OpenAI::Internal::Type::ArrayOf[
435
+ enum: OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType
436
+ ]
437
+ ]
438
+ end
439
+
440
+ # @!attribute category_scores
441
+ # A dictionary of moderation categories to scores.
442
+ #
443
+ # @return [Hash{Symbol=>Float}]
444
+ required :category_scores, OpenAI::Internal::Type::HashOf[Float]
445
+
446
+ # @!attribute flagged
447
+ # A boolean indicating whether the content was flagged by any category.
448
+ #
449
+ # @return [Boolean]
450
+ required :flagged, OpenAI::Internal::Type::Boolean
451
+
452
+ # @!attribute model
453
+ # The moderation model that produced this result.
454
+ #
455
+ # @return [String]
456
+ required :model, String
457
+
458
+ # @!attribute type
459
+ # The object type, which was always `moderation_result` for successful moderation
460
+ # results.
461
+ #
462
+ # @return [Symbol, :moderation_result]
463
+ required :type, const: :moderation_result
464
+
465
+ # @!method initialize(categories:, category_applied_input_types:, category_scores:, flagged:, model:, type: :moderation_result)
466
+ # Some parameter documentations has been truncated, see
467
+ # {OpenAI::Models::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result}
468
+ # for more details.
469
+ #
470
+ # A moderation result produced for the response input or output.
471
+ #
472
+ # @param categories [Hash{Symbol=>Boolean}] A dictionary of moderation categories to booleans, True if the input is flagged
473
+ #
474
+ # @param category_applied_input_types [Hash{Symbol=>Array<Symbol, OpenAI::Models::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType>}] Which modalities of input are reflected by the score for each category.
475
+ #
476
+ # @param category_scores [Hash{Symbol=>Float}] A dictionary of moderation categories to scores.
477
+ #
478
+ # @param flagged [Boolean] A boolean indicating whether the content was flagged by any category.
479
+ #
480
+ # @param model [String] The moderation model that produced this result.
481
+ #
482
+ # @param type [Symbol, :moderation_result] The object type, which was always `moderation_result` for successful moderation
483
+
484
+ module CategoryAppliedInputType
485
+ extend OpenAI::Internal::Type::Enum
486
+
487
+ TEXT = :text
488
+ IMAGE = :image
489
+
490
+ # @!method self.values
491
+ # @return [Array<Symbol>]
492
+ end
493
+ end
494
+ end
495
+
496
+ class Error < OpenAI::Internal::Type::BaseModel
497
+ # @!attribute code
498
+ # The error code.
499
+ #
500
+ # @return [String]
501
+ required :code, String
502
+
503
+ # @!attribute message
504
+ # The error message.
505
+ #
506
+ # @return [String]
507
+ required :message, String
508
+
509
+ # @!attribute type
510
+ # The object type, which is always `error`.
511
+ #
512
+ # @return [Symbol, :error]
513
+ required :type, const: :error
514
+
515
+ # @!method initialize(code:, message:, type: :error)
516
+ # An error produced while attempting moderation.
517
+ #
518
+ # @param code [String] The error code.
519
+ #
520
+ # @param message [String] The error message.
521
+ #
522
+ # @param type [Symbol, :error] The object type, which is always `error`.
523
+ end
524
+
525
+ # @!method self.variants
526
+ # @return [Array(OpenAI::Models::Chat::ChatCompletion::Moderation::Output::ModerationResults, OpenAI::Models::Chat::ChatCompletion::Moderation::Output::Error)]
527
+ end
528
+ end
529
+
192
530
  # Specifies the processing type used for serving the request.
193
531
  #
194
532
  # - If set to 'auto', then the request will be processed with the service tier