ruby/resources/moderations/index.md +0 −934 deleted
File Deleted View Diff
1# Moderations
2
3## Create moderation
4
5`moderations.create(**kwargs) -> ModerationCreateResponse`
6
7**post** `/moderations`
8
9Classifies if text and/or image inputs are potentially harmful. Learn
10more in the [moderation guide](https://platform.openai.com/docs/guides/moderation).
11
12### Parameters
13
14- `input: String | Array[String] | Array[ModerationMultiModalInput]`
15
16 Input (or inputs) to classify. Can be a single string, an array of strings, or
17 an array of multi-modal input objects similar to other models.
18
19 - `String = String`
20
21 A string of text to classify for moderation.
22
23 - `UnionMember1 = Array[String]`
24
25 An array of strings to classify for moderation.
26
27 - `ModerationMultiModalArray = Array[ModerationMultiModalInput]`
28
29 An array of multi-modal inputs to the moderation model.
30
31 - `class ModerationImageURLInput`
32
33 An object describing an image to classify.
34
35 - `image_url: ImageURL{ url}`
36
37 Contains either an image URL or a data URL for a base64 encoded image.
38
39 - `url: String`
40
41 Either a URL of the image or the base64 encoded image data.
42
43 - `type: :image_url`
44
45 Always `image_url`.
46
47 - `:image_url`
48
49 - `class ModerationTextInput`
50
51 An object describing text to classify.
52
53 - `text: String`
54
55 A string of text to classify.
56
57 - `type: :text`
58
59 Always `text`.
60
61 - `:text`
62
63- `model: String | ModerationModel`
64
65 The content moderation model you would like to use. Learn more in
66 [the moderation guide](https://platform.openai.com/docs/guides/moderation), and learn about
67 available models [here](https://platform.openai.com/docs/models#moderation).
68
69 - `String = String`
70
71 - `ModerationModel = :"omni-moderation-latest" | :"omni-moderation-2024-09-26" | :"text-moderation-latest" | :"text-moderation-stable"`
72
73 - `:"omni-moderation-latest"`
74
75 - `:"omni-moderation-2024-09-26"`
76
77 - `:"text-moderation-latest"`
78
79 - `:"text-moderation-stable"`
80
81### Returns
82
83- `class ModerationCreateResponse`
84
85 Represents if a given text input is potentially harmful.
86
87 - `id: String`
88
89 The unique identifier for the moderation request.
90
91 - `model: String`
92
93 The model used to generate the moderation results.
94
95 - `results: Array[Moderation]`
96
97 A list of moderation objects.
98
99 - `categories: Categories{ harassment, harassment_threatening, hate, 10 more}`
100
101 A list of the categories, and whether they are flagged or not.
102
103 - `harassment: bool`
104
105 Content that expresses, incites, or promotes harassing language towards any target.
106
107 - `harassment_threatening: bool`
108
109 Harassment content that also includes violence or serious harm towards any target.
110
111 - `hate: bool`
112
113 Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment.
114
115 - `hate_threatening: bool`
116
117 Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste.
118
119 - `illicit: bool`
120
121 Content that includes instructions or advice that facilitate the planning or execution of wrongdoing, or that gives advice or instruction on how to commit illicit acts. For example, "how to shoplift" would fit this category.
122
123 - `illicit_violent: bool`
124
125 Content that includes instructions or advice that facilitate the planning or execution of wrongdoing that also includes violence, or that gives advice or instruction on the procurement of any weapon.
126
127 - `self_harm: bool`
128
129 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.
130
131 - `self_harm_instructions: bool`
132
133 Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts.
134
135 - `self_harm_intent: bool`
136
137 Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders.
138
139 - `sexual: bool`
140
141 Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).
142
143 - `sexual_minors: bool`
144
145 Sexual content that includes an individual who is under 18 years old.
146
147 - `violence: bool`
148
149 Content that depicts death, violence, or physical injury.
150
151 - `violence_graphic: bool`
152
153 Content that depicts death, violence, or physical injury in graphic detail.
154
155 - `category_applied_input_types: CategoryAppliedInputTypes{ harassment, harassment_threatening, hate, 10 more}`
156
157 A list of the categories along with the input type(s) that the score applies to.
158
159 - `harassment: Array[:text]`
160
161 The applied input type(s) for the category 'harassment'.
162
163 - `:text`
164
165 - `harassment_threatening: Array[:text]`
166
167 The applied input type(s) for the category 'harassment/threatening'.
168
169 - `:text`
170
171 - `hate: Array[:text]`
172
173 The applied input type(s) for the category 'hate'.
174
175 - `:text`
176
177 - `hate_threatening: Array[:text]`
178
179 The applied input type(s) for the category 'hate/threatening'.
180
181 - `:text`
182
183 - `illicit: Array[:text]`
184
185 The applied input type(s) for the category 'illicit'.
186
187 - `:text`
188
189 - `illicit_violent: Array[:text]`
190
191 The applied input type(s) for the category 'illicit/violent'.
192
193 - `:text`
194
195 - `self_harm: Array[:text | :image]`
196
197 The applied input type(s) for the category 'self-harm'.
198
199 - `:text`
200
201 - `:image`
202
203 - `self_harm_instructions: Array[:text | :image]`
204
205 The applied input type(s) for the category 'self-harm/instructions'.
206
207 - `:text`
208
209 - `:image`
210
211 - `self_harm_intent: Array[:text | :image]`
212
213 The applied input type(s) for the category 'self-harm/intent'.
214
215 - `:text`
216
217 - `:image`
218
219 - `sexual: Array[:text | :image]`
220
221 The applied input type(s) for the category 'sexual'.
222
223 - `:text`
224
225 - `:image`
226
227 - `sexual_minors: Array[:text]`
228
229 The applied input type(s) for the category 'sexual/minors'.
230
231 - `:text`
232
233 - `violence: Array[:text | :image]`
234
235 The applied input type(s) for the category 'violence'.
236
237 - `:text`
238
239 - `:image`
240
241 - `violence_graphic: Array[:text | :image]`
242
243 The applied input type(s) for the category 'violence/graphic'.
244
245 - `:text`
246
247 - `:image`
248
249 - `category_scores: CategoryScores{ harassment, harassment_threatening, hate, 10 more}`
250
251 A list of the categories along with their scores as predicted by model.
252
253 - `harassment: Float`
254
255 The score for the category 'harassment'.
256
257 - `harassment_threatening: Float`
258
259 The score for the category 'harassment/threatening'.
260
261 - `hate: Float`
262
263 The score for the category 'hate'.
264
265 - `hate_threatening: Float`
266
267 The score for the category 'hate/threatening'.
268
269 - `illicit: Float`
270
271 The score for the category 'illicit'.
272
273 - `illicit_violent: Float`
274
275 The score for the category 'illicit/violent'.
276
277 - `self_harm: Float`
278
279 The score for the category 'self-harm'.
280
281 - `self_harm_instructions: Float`
282
283 The score for the category 'self-harm/instructions'.
284
285 - `self_harm_intent: Float`
286
287 The score for the category 'self-harm/intent'.
288
289 - `sexual: Float`
290
291 The score for the category 'sexual'.
292
293 - `sexual_minors: Float`
294
295 The score for the category 'sexual/minors'.
296
297 - `violence: Float`
298
299 The score for the category 'violence'.
300
301 - `violence_graphic: Float`
302
303 The score for the category 'violence/graphic'.
304
305 - `flagged: bool`
306
307 Whether any of the below categories are flagged.
308
309### Example
310
311```ruby
312require "openai"
313
314openai = OpenAI::Client.new(api_key: "My API Key")
315
316moderation = openai.moderations.create(input: "I want to kill them.")
317
318puts(moderation)
319```
320
321#### Response
322
323```json
324{
325 "id": "id",
326 "model": "model",
327 "results": [
328 {
329 "categories": {
330 "harassment": true,
331 "harassment/threatening": true,
332 "hate": true,
333 "hate/threatening": true,
334 "illicit": true,
335 "illicit/violent": true,
336 "self-harm": true,
337 "self-harm/instructions": true,
338 "self-harm/intent": true,
339 "sexual": true,
340 "sexual/minors": true,
341 "violence": true,
342 "violence/graphic": true
343 },
344 "category_applied_input_types": {
345 "harassment": [
346 "text"
347 ],
348 "harassment/threatening": [
349 "text"
350 ],
351 "hate": [
352 "text"
353 ],
354 "hate/threatening": [
355 "text"
356 ],
357 "illicit": [
358 "text"
359 ],
360 "illicit/violent": [
361 "text"
362 ],
363 "self-harm": [
364 "text"
365 ],
366 "self-harm/instructions": [
367 "text"
368 ],
369 "self-harm/intent": [
370 "text"
371 ],
372 "sexual": [
373 "text"
374 ],
375 "sexual/minors": [
376 "text"
377 ],
378 "violence": [
379 "text"
380 ],
381 "violence/graphic": [
382 "text"
383 ]
384 },
385 "category_scores": {
386 "harassment": 0,
387 "harassment/threatening": 0,
388 "hate": 0,
389 "hate/threatening": 0,
390 "illicit": 0,
391 "illicit/violent": 0,
392 "self-harm": 0,
393 "self-harm/instructions": 0,
394 "self-harm/intent": 0,
395 "sexual": 0,
396 "sexual/minors": 0,
397 "violence": 0,
398 "violence/graphic": 0
399 },
400 "flagged": true
401 }
402 ]
403}
404```
405
406## Domain Types
407
408### Moderation
409
410- `class Moderation`
411
412 - `categories: Categories{ harassment, harassment_threatening, hate, 10 more}`
413
414 A list of the categories, and whether they are flagged or not.
415
416 - `harassment: bool`
417
418 Content that expresses, incites, or promotes harassing language towards any target.
419
420 - `harassment_threatening: bool`
421
422 Harassment content that also includes violence or serious harm towards any target.
423
424 - `hate: bool`
425
426 Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment.
427
428 - `hate_threatening: bool`
429
430 Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste.
431
432 - `illicit: bool`
433
434 Content that includes instructions or advice that facilitate the planning or execution of wrongdoing, or that gives advice or instruction on how to commit illicit acts. For example, "how to shoplift" would fit this category.
435
436 - `illicit_violent: bool`
437
438 Content that includes instructions or advice that facilitate the planning or execution of wrongdoing that also includes violence, or that gives advice or instruction on the procurement of any weapon.
439
440 - `self_harm: bool`
441
442 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.
443
444 - `self_harm_instructions: bool`
445
446 Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts.
447
448 - `self_harm_intent: bool`
449
450 Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders.
451
452 - `sexual: bool`
453
454 Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).
455
456 - `sexual_minors: bool`
457
458 Sexual content that includes an individual who is under 18 years old.
459
460 - `violence: bool`
461
462 Content that depicts death, violence, or physical injury.
463
464 - `violence_graphic: bool`
465
466 Content that depicts death, violence, or physical injury in graphic detail.
467
468 - `category_applied_input_types: CategoryAppliedInputTypes{ harassment, harassment_threatening, hate, 10 more}`
469
470 A list of the categories along with the input type(s) that the score applies to.
471
472 - `harassment: Array[:text]`
473
474 The applied input type(s) for the category 'harassment'.
475
476 - `:text`
477
478 - `harassment_threatening: Array[:text]`
479
480 The applied input type(s) for the category 'harassment/threatening'.
481
482 - `:text`
483
484 - `hate: Array[:text]`
485
486 The applied input type(s) for the category 'hate'.
487
488 - `:text`
489
490 - `hate_threatening: Array[:text]`
491
492 The applied input type(s) for the category 'hate/threatening'.
493
494 - `:text`
495
496 - `illicit: Array[:text]`
497
498 The applied input type(s) for the category 'illicit'.
499
500 - `:text`
501
502 - `illicit_violent: Array[:text]`
503
504 The applied input type(s) for the category 'illicit/violent'.
505
506 - `:text`
507
508 - `self_harm: Array[:text | :image]`
509
510 The applied input type(s) for the category 'self-harm'.
511
512 - `:text`
513
514 - `:image`
515
516 - `self_harm_instructions: Array[:text | :image]`
517
518 The applied input type(s) for the category 'self-harm/instructions'.
519
520 - `:text`
521
522 - `:image`
523
524 - `self_harm_intent: Array[:text | :image]`
525
526 The applied input type(s) for the category 'self-harm/intent'.
527
528 - `:text`
529
530 - `:image`
531
532 - `sexual: Array[:text | :image]`
533
534 The applied input type(s) for the category 'sexual'.
535
536 - `:text`
537
538 - `:image`
539
540 - `sexual_minors: Array[:text]`
541
542 The applied input type(s) for the category 'sexual/minors'.
543
544 - `:text`
545
546 - `violence: Array[:text | :image]`
547
548 The applied input type(s) for the category 'violence'.
549
550 - `:text`
551
552 - `:image`
553
554 - `violence_graphic: Array[:text | :image]`
555
556 The applied input type(s) for the category 'violence/graphic'.
557
558 - `:text`
559
560 - `:image`
561
562 - `category_scores: CategoryScores{ harassment, harassment_threatening, hate, 10 more}`
563
564 A list of the categories along with their scores as predicted by model.
565
566 - `harassment: Float`
567
568 The score for the category 'harassment'.
569
570 - `harassment_threatening: Float`
571
572 The score for the category 'harassment/threatening'.
573
574 - `hate: Float`
575
576 The score for the category 'hate'.
577
578 - `hate_threatening: Float`
579
580 The score for the category 'hate/threatening'.
581
582 - `illicit: Float`
583
584 The score for the category 'illicit'.
585
586 - `illicit_violent: Float`
587
588 The score for the category 'illicit/violent'.
589
590 - `self_harm: Float`
591
592 The score for the category 'self-harm'.
593
594 - `self_harm_instructions: Float`
595
596 The score for the category 'self-harm/instructions'.
597
598 - `self_harm_intent: Float`
599
600 The score for the category 'self-harm/intent'.
601
602 - `sexual: Float`
603
604 The score for the category 'sexual'.
605
606 - `sexual_minors: Float`
607
608 The score for the category 'sexual/minors'.
609
610 - `violence: Float`
611
612 The score for the category 'violence'.
613
614 - `violence_graphic: Float`
615
616 The score for the category 'violence/graphic'.
617
618 - `flagged: bool`
619
620 Whether any of the below categories are flagged.
621
622### Moderation Image URL Input
623
624- `class ModerationImageURLInput`
625
626 An object describing an image to classify.
627
628 - `image_url: ImageURL{ url}`
629
630 Contains either an image URL or a data URL for a base64 encoded image.
631
632 - `url: String`
633
634 Either a URL of the image or the base64 encoded image data.
635
636 - `type: :image_url`
637
638 Always `image_url`.
639
640 - `:image_url`
641
642### Moderation Model
643
644- `ModerationModel = :"omni-moderation-latest" | :"omni-moderation-2024-09-26" | :"text-moderation-latest" | :"text-moderation-stable"`
645
646 - `:"omni-moderation-latest"`
647
648 - `:"omni-moderation-2024-09-26"`
649
650 - `:"text-moderation-latest"`
651
652 - `:"text-moderation-stable"`
653
654### Moderation Multi Modal Input
655
656- `ModerationMultiModalInput = ModerationImageURLInput | ModerationTextInput`
657
658 An object describing an image to classify.
659
660 - `class ModerationImageURLInput`
661
662 An object describing an image to classify.
663
664 - `image_url: ImageURL{ url}`
665
666 Contains either an image URL or a data URL for a base64 encoded image.
667
668 - `url: String`
669
670 Either a URL of the image or the base64 encoded image data.
671
672 - `type: :image_url`
673
674 Always `image_url`.
675
676 - `:image_url`
677
678 - `class ModerationTextInput`
679
680 An object describing text to classify.
681
682 - `text: String`
683
684 A string of text to classify.
685
686 - `type: :text`
687
688 Always `text`.
689
690 - `:text`
691
692### Moderation Text Input
693
694- `class ModerationTextInput`
695
696 An object describing text to classify.
697
698 - `text: String`
699
700 A string of text to classify.
701
702 - `type: :text`
703
704 Always `text`.
705
706 - `:text`
707
708### Moderation Create Response
709
710- `class ModerationCreateResponse`
711
712 Represents if a given text input is potentially harmful.
713
714 - `id: String`
715
716 The unique identifier for the moderation request.
717
718 - `model: String`
719
720 The model used to generate the moderation results.
721
722 - `results: Array[Moderation]`
723
724 A list of moderation objects.
725
726 - `categories: Categories{ harassment, harassment_threatening, hate, 10 more}`
727
728 A list of the categories, and whether they are flagged or not.
729
730 - `harassment: bool`
731
732 Content that expresses, incites, or promotes harassing language towards any target.
733
734 - `harassment_threatening: bool`
735
736 Harassment content that also includes violence or serious harm towards any target.
737
738 - `hate: bool`
739
740 Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment.
741
742 - `hate_threatening: bool`
743
744 Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste.
745
746 - `illicit: bool`
747
748 Content that includes instructions or advice that facilitate the planning or execution of wrongdoing, or that gives advice or instruction on how to commit illicit acts. For example, "how to shoplift" would fit this category.
749
750 - `illicit_violent: bool`
751
752 Content that includes instructions or advice that facilitate the planning or execution of wrongdoing that also includes violence, or that gives advice or instruction on the procurement of any weapon.
753
754 - `self_harm: bool`
755
756 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.
757
758 - `self_harm_instructions: bool`
759
760 Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts.
761
762 - `self_harm_intent: bool`
763
764 Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders.
765
766 - `sexual: bool`
767
768 Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).
769
770 - `sexual_minors: bool`
771
772 Sexual content that includes an individual who is under 18 years old.
773
774 - `violence: bool`
775
776 Content that depicts death, violence, or physical injury.
777
778 - `violence_graphic: bool`
779
780 Content that depicts death, violence, or physical injury in graphic detail.
781
782 - `category_applied_input_types: CategoryAppliedInputTypes{ harassment, harassment_threatening, hate, 10 more}`
783
784 A list of the categories along with the input type(s) that the score applies to.
785
786 - `harassment: Array[:text]`
787
788 The applied input type(s) for the category 'harassment'.
789
790 - `:text`
791
792 - `harassment_threatening: Array[:text]`
793
794 The applied input type(s) for the category 'harassment/threatening'.
795
796 - `:text`
797
798 - `hate: Array[:text]`
799
800 The applied input type(s) for the category 'hate'.
801
802 - `:text`
803
804 - `hate_threatening: Array[:text]`
805
806 The applied input type(s) for the category 'hate/threatening'.
807
808 - `:text`
809
810 - `illicit: Array[:text]`
811
812 The applied input type(s) for the category 'illicit'.
813
814 - `:text`
815
816 - `illicit_violent: Array[:text]`
817
818 The applied input type(s) for the category 'illicit/violent'.
819
820 - `:text`
821
822 - `self_harm: Array[:text | :image]`
823
824 The applied input type(s) for the category 'self-harm'.
825
826 - `:text`
827
828 - `:image`
829
830 - `self_harm_instructions: Array[:text | :image]`
831
832 The applied input type(s) for the category 'self-harm/instructions'.
833
834 - `:text`
835
836 - `:image`
837
838 - `self_harm_intent: Array[:text | :image]`
839
840 The applied input type(s) for the category 'self-harm/intent'.
841
842 - `:text`
843
844 - `:image`
845
846 - `sexual: Array[:text | :image]`
847
848 The applied input type(s) for the category 'sexual'.
849
850 - `:text`
851
852 - `:image`
853
854 - `sexual_minors: Array[:text]`
855
856 The applied input type(s) for the category 'sexual/minors'.
857
858 - `:text`
859
860 - `violence: Array[:text | :image]`
861
862 The applied input type(s) for the category 'violence'.
863
864 - `:text`
865
866 - `:image`
867
868 - `violence_graphic: Array[:text | :image]`
869
870 The applied input type(s) for the category 'violence/graphic'.
871
872 - `:text`
873
874 - `:image`
875
876 - `category_scores: CategoryScores{ harassment, harassment_threatening, hate, 10 more}`
877
878 A list of the categories along with their scores as predicted by model.
879
880 - `harassment: Float`
881
882 The score for the category 'harassment'.
883
884 - `harassment_threatening: Float`
885
886 The score for the category 'harassment/threatening'.
887
888 - `hate: Float`
889
890 The score for the category 'hate'.
891
892 - `hate_threatening: Float`
893
894 The score for the category 'hate/threatening'.
895
896 - `illicit: Float`
897
898 The score for the category 'illicit'.
899
900 - `illicit_violent: Float`
901
902 The score for the category 'illicit/violent'.
903
904 - `self_harm: Float`
905
906 The score for the category 'self-harm'.
907
908 - `self_harm_instructions: Float`
909
910 The score for the category 'self-harm/instructions'.
911
912 - `self_harm_intent: Float`
913
914 The score for the category 'self-harm/intent'.
915
916 - `sexual: Float`
917
918 The score for the category 'sexual'.
919
920 - `sexual_minors: Float`
921
922 The score for the category 'sexual/minors'.
923
924 - `violence: Float`
925
926 The score for the category 'violence'.
927
928 - `violence_graphic: Float`
929
930 The score for the category 'violence/graphic'.
931
932 - `flagged: bool`
933
934 Whether any of the below categories are flagged.