java/resources/moderations/index.md +0 −710 deleted
File Deleted View Diff
1# Moderations
2
3## Create moderation
4
5`ModerationCreateResponse moderations().create(ModerationCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`
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- `ModerationCreateParams params`
15
16 - `Input input`
17
18 Input (or inputs) to classify. Can be a single string, an array of strings, or
19 an array of multi-modal input objects similar to other models.
20
21 - `String`
22
23 - `List<String>`
24
25 - `List<ModerationMultiModalInput>`
26
27 - `class ModerationImageUrlInput:`
28
29 An object describing an image to classify.
30
31 - `ImageUrl imageUrl`
32
33 Contains either an image URL or a data URL for a base64 encoded image.
34
35 - `String url`
36
37 Either a URL of the image or the base64 encoded image data.
38
39 - `JsonValue; type "image_url"constant`
40
41 Always `image_url`.
42
43 - `IMAGE_URL("image_url")`
44
45 - `class ModerationTextInput:`
46
47 An object describing text to classify.
48
49 - `String text`
50
51 A string of text to classify.
52
53 - `JsonValue; type "text"constant`
54
55 Always `text`.
56
57 - `TEXT("text")`
58
59 - `Optional<ModerationModel> model`
60
61 The content moderation model you would like to use. Learn more in
62 [the moderation guide](https://platform.openai.com/docs/guides/moderation), and learn about
63 available models [here](https://platform.openai.com/docs/models#moderation).
64
65 - `OMNI_MODERATION_LATEST("omni-moderation-latest")`
66
67 - `OMNI_MODERATION_2024_09_26("omni-moderation-2024-09-26")`
68
69 - `TEXT_MODERATION_LATEST("text-moderation-latest")`
70
71 - `TEXT_MODERATION_STABLE("text-moderation-stable")`
72
73### Returns
74
75- `class ModerationCreateResponse:`
76
77 Represents if a given text input is potentially harmful.
78
79 - `String id`
80
81 The unique identifier for the moderation request.
82
83 - `String model`
84
85 The model used to generate the moderation results.
86
87 - `List<Moderation> results`
88
89 A list of moderation objects.
90
91 - `Categories categories`
92
93 A list of the categories, and whether they are flagged or not.
94
95 - `boolean harassment`
96
97 Content that expresses, incites, or promotes harassing language towards any target.
98
99 - `boolean harassmentThreatening`
100
101 Harassment content that also includes violence or serious harm towards any target.
102
103 - `boolean hate`
104
105 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.
106
107 - `boolean hateThreatening`
108
109 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.
110
111 - `Optional<Boolean> illicit`
112
113 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.
114
115 - `Optional<Boolean> illicitViolent`
116
117 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.
118
119 - `boolean selfHarm`
120
121 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.
122
123 - `boolean selfHarmInstructions`
124
125 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.
126
127 - `boolean selfHarmIntent`
128
129 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.
130
131 - `boolean sexual`
132
133 Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).
134
135 - `boolean sexualMinors`
136
137 Sexual content that includes an individual who is under 18 years old.
138
139 - `boolean violence`
140
141 Content that depicts death, violence, or physical injury.
142
143 - `boolean violenceGraphic`
144
145 Content that depicts death, violence, or physical injury in graphic detail.
146
147 - `CategoryAppliedInputTypes categoryAppliedInputTypes`
148
149 A list of the categories along with the input type(s) that the score applies to.
150
151 - `List<Harassment> harassment`
152
153 The applied input type(s) for the category 'harassment'.
154
155 - `TEXT("text")`
156
157 - `List<HarassmentThreatening> harassmentThreatening`
158
159 The applied input type(s) for the category 'harassment/threatening'.
160
161 - `TEXT("text")`
162
163 - `List<Hate> hate`
164
165 The applied input type(s) for the category 'hate'.
166
167 - `TEXT("text")`
168
169 - `List<HateThreatening> hateThreatening`
170
171 The applied input type(s) for the category 'hate/threatening'.
172
173 - `TEXT("text")`
174
175 - `List<Illicit> illicit`
176
177 The applied input type(s) for the category 'illicit'.
178
179 - `TEXT("text")`
180
181 - `List<IllicitViolent> illicitViolent`
182
183 The applied input type(s) for the category 'illicit/violent'.
184
185 - `TEXT("text")`
186
187 - `List<SelfHarm> selfHarm`
188
189 The applied input type(s) for the category 'self-harm'.
190
191 - `TEXT("text")`
192
193 - `IMAGE("image")`
194
195 - `List<SelfHarmInstruction> selfHarmInstructions`
196
197 The applied input type(s) for the category 'self-harm/instructions'.
198
199 - `TEXT("text")`
200
201 - `IMAGE("image")`
202
203 - `List<SelfHarmIntent> selfHarmIntent`
204
205 The applied input type(s) for the category 'self-harm/intent'.
206
207 - `TEXT("text")`
208
209 - `IMAGE("image")`
210
211 - `List<Sexual> sexual`
212
213 The applied input type(s) for the category 'sexual'.
214
215 - `TEXT("text")`
216
217 - `IMAGE("image")`
218
219 - `List<SexualMinor> sexualMinors`
220
221 The applied input type(s) for the category 'sexual/minors'.
222
223 - `TEXT("text")`
224
225 - `List<Violence> violence`
226
227 The applied input type(s) for the category 'violence'.
228
229 - `TEXT("text")`
230
231 - `IMAGE("image")`
232
233 - `List<ViolenceGraphic> violenceGraphic`
234
235 The applied input type(s) for the category 'violence/graphic'.
236
237 - `TEXT("text")`
238
239 - `IMAGE("image")`
240
241 - `CategoryScores categoryScores`
242
243 A list of the categories along with their scores as predicted by model.
244
245 - `double harassment`
246
247 The score for the category 'harassment'.
248
249 - `double harassmentThreatening`
250
251 The score for the category 'harassment/threatening'.
252
253 - `double hate`
254
255 The score for the category 'hate'.
256
257 - `double hateThreatening`
258
259 The score for the category 'hate/threatening'.
260
261 - `double illicit`
262
263 The score for the category 'illicit'.
264
265 - `double illicitViolent`
266
267 The score for the category 'illicit/violent'.
268
269 - `double selfHarm`
270
271 The score for the category 'self-harm'.
272
273 - `double selfHarmInstructions`
274
275 The score for the category 'self-harm/instructions'.
276
277 - `double selfHarmIntent`
278
279 The score for the category 'self-harm/intent'.
280
281 - `double sexual`
282
283 The score for the category 'sexual'.
284
285 - `double sexualMinors`
286
287 The score for the category 'sexual/minors'.
288
289 - `double violence`
290
291 The score for the category 'violence'.
292
293 - `double violenceGraphic`
294
295 The score for the category 'violence/graphic'.
296
297 - `boolean flagged`
298
299 Whether any of the below categories are flagged.
300
301### Example
302
303```java
304package com.openai.example;
305
306import com.openai.client.OpenAIClient;
307import com.openai.client.okhttp.OpenAIOkHttpClient;
308import com.openai.models.moderations.ModerationCreateParams;
309import com.openai.models.moderations.ModerationCreateResponse;
310
311public final class Main {
312 private Main() {}
313
314 public static void main(String[] args) {
315 OpenAIClient client = OpenAIOkHttpClient.fromEnv();
316
317 ModerationCreateParams params = ModerationCreateParams.builder()
318 .input("I want to kill them.")
319 .build();
320 ModerationCreateResponse moderation = client.moderations().create(params);
321 }
322}
323```
324
325#### Response
326
327```json
328{
329 "id": "id",
330 "model": "model",
331 "results": [
332 {
333 "categories": {
334 "harassment": true,
335 "harassment/threatening": true,
336 "hate": true,
337 "hate/threatening": true,
338 "illicit": true,
339 "illicit/violent": true,
340 "self-harm": true,
341 "self-harm/instructions": true,
342 "self-harm/intent": true,
343 "sexual": true,
344 "sexual/minors": true,
345 "violence": true,
346 "violence/graphic": true
347 },
348 "category_applied_input_types": {
349 "harassment": [
350 "text"
351 ],
352 "harassment/threatening": [
353 "text"
354 ],
355 "hate": [
356 "text"
357 ],
358 "hate/threatening": [
359 "text"
360 ],
361 "illicit": [
362 "text"
363 ],
364 "illicit/violent": [
365 "text"
366 ],
367 "self-harm": [
368 "text"
369 ],
370 "self-harm/instructions": [
371 "text"
372 ],
373 "self-harm/intent": [
374 "text"
375 ],
376 "sexual": [
377 "text"
378 ],
379 "sexual/minors": [
380 "text"
381 ],
382 "violence": [
383 "text"
384 ],
385 "violence/graphic": [
386 "text"
387 ]
388 },
389 "category_scores": {
390 "harassment": 0,
391 "harassment/threatening": 0,
392 "hate": 0,
393 "hate/threatening": 0,
394 "illicit": 0,
395 "illicit/violent": 0,
396 "self-harm": 0,
397 "self-harm/instructions": 0,
398 "self-harm/intent": 0,
399 "sexual": 0,
400 "sexual/minors": 0,
401 "violence": 0,
402 "violence/graphic": 0
403 },
404 "flagged": true
405 }
406 ]
407}
408```
409
410## Domain Types
411
412### Moderation
413
414- `class Moderation:`
415
416 - `Categories categories`
417
418 A list of the categories, and whether they are flagged or not.
419
420 - `boolean harassment`
421
422 Content that expresses, incites, or promotes harassing language towards any target.
423
424 - `boolean harassmentThreatening`
425
426 Harassment content that also includes violence or serious harm towards any target.
427
428 - `boolean hate`
429
430 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.
431
432 - `boolean hateThreatening`
433
434 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.
435
436 - `Optional<Boolean> illicit`
437
438 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.
439
440 - `Optional<Boolean> illicitViolent`
441
442 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.
443
444 - `boolean selfHarm`
445
446 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.
447
448 - `boolean selfHarmInstructions`
449
450 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.
451
452 - `boolean selfHarmIntent`
453
454 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.
455
456 - `boolean sexual`
457
458 Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).
459
460 - `boolean sexualMinors`
461
462 Sexual content that includes an individual who is under 18 years old.
463
464 - `boolean violence`
465
466 Content that depicts death, violence, or physical injury.
467
468 - `boolean violenceGraphic`
469
470 Content that depicts death, violence, or physical injury in graphic detail.
471
472 - `CategoryAppliedInputTypes categoryAppliedInputTypes`
473
474 A list of the categories along with the input type(s) that the score applies to.
475
476 - `List<Harassment> harassment`
477
478 The applied input type(s) for the category 'harassment'.
479
480 - `TEXT("text")`
481
482 - `List<HarassmentThreatening> harassmentThreatening`
483
484 The applied input type(s) for the category 'harassment/threatening'.
485
486 - `TEXT("text")`
487
488 - `List<Hate> hate`
489
490 The applied input type(s) for the category 'hate'.
491
492 - `TEXT("text")`
493
494 - `List<HateThreatening> hateThreatening`
495
496 The applied input type(s) for the category 'hate/threatening'.
497
498 - `TEXT("text")`
499
500 - `List<Illicit> illicit`
501
502 The applied input type(s) for the category 'illicit'.
503
504 - `TEXT("text")`
505
506 - `List<IllicitViolent> illicitViolent`
507
508 The applied input type(s) for the category 'illicit/violent'.
509
510 - `TEXT("text")`
511
512 - `List<SelfHarm> selfHarm`
513
514 The applied input type(s) for the category 'self-harm'.
515
516 - `TEXT("text")`
517
518 - `IMAGE("image")`
519
520 - `List<SelfHarmInstruction> selfHarmInstructions`
521
522 The applied input type(s) for the category 'self-harm/instructions'.
523
524 - `TEXT("text")`
525
526 - `IMAGE("image")`
527
528 - `List<SelfHarmIntent> selfHarmIntent`
529
530 The applied input type(s) for the category 'self-harm/intent'.
531
532 - `TEXT("text")`
533
534 - `IMAGE("image")`
535
536 - `List<Sexual> sexual`
537
538 The applied input type(s) for the category 'sexual'.
539
540 - `TEXT("text")`
541
542 - `IMAGE("image")`
543
544 - `List<SexualMinor> sexualMinors`
545
546 The applied input type(s) for the category 'sexual/minors'.
547
548 - `TEXT("text")`
549
550 - `List<Violence> violence`
551
552 The applied input type(s) for the category 'violence'.
553
554 - `TEXT("text")`
555
556 - `IMAGE("image")`
557
558 - `List<ViolenceGraphic> violenceGraphic`
559
560 The applied input type(s) for the category 'violence/graphic'.
561
562 - `TEXT("text")`
563
564 - `IMAGE("image")`
565
566 - `CategoryScores categoryScores`
567
568 A list of the categories along with their scores as predicted by model.
569
570 - `double harassment`
571
572 The score for the category 'harassment'.
573
574 - `double harassmentThreatening`
575
576 The score for the category 'harassment/threatening'.
577
578 - `double hate`
579
580 The score for the category 'hate'.
581
582 - `double hateThreatening`
583
584 The score for the category 'hate/threatening'.
585
586 - `double illicit`
587
588 The score for the category 'illicit'.
589
590 - `double illicitViolent`
591
592 The score for the category 'illicit/violent'.
593
594 - `double selfHarm`
595
596 The score for the category 'self-harm'.
597
598 - `double selfHarmInstructions`
599
600 The score for the category 'self-harm/instructions'.
601
602 - `double selfHarmIntent`
603
604 The score for the category 'self-harm/intent'.
605
606 - `double sexual`
607
608 The score for the category 'sexual'.
609
610 - `double sexualMinors`
611
612 The score for the category 'sexual/minors'.
613
614 - `double violence`
615
616 The score for the category 'violence'.
617
618 - `double violenceGraphic`
619
620 The score for the category 'violence/graphic'.
621
622 - `boolean flagged`
623
624 Whether any of the below categories are flagged.
625
626### Moderation Image URL Input
627
628- `class ModerationImageUrlInput:`
629
630 An object describing an image to classify.
631
632 - `ImageUrl imageUrl`
633
634 Contains either an image URL or a data URL for a base64 encoded image.
635
636 - `String url`
637
638 Either a URL of the image or the base64 encoded image data.
639
640 - `JsonValue; type "image_url"constant`
641
642 Always `image_url`.
643
644 - `IMAGE_URL("image_url")`
645
646### Moderation Model
647
648- `enum ModerationModel:`
649
650 - `OMNI_MODERATION_LATEST("omni-moderation-latest")`
651
652 - `OMNI_MODERATION_2024_09_26("omni-moderation-2024-09-26")`
653
654 - `TEXT_MODERATION_LATEST("text-moderation-latest")`
655
656 - `TEXT_MODERATION_STABLE("text-moderation-stable")`
657
658### Moderation Multi Modal Input
659
660- `class ModerationMultiModalInput: A class that can be one of several variants.union`
661
662 An object describing an image to classify.
663
664 - `class ModerationImageUrlInput:`
665
666 An object describing an image to classify.
667
668 - `ImageUrl imageUrl`
669
670 Contains either an image URL or a data URL for a base64 encoded image.
671
672 - `String url`
673
674 Either a URL of the image or the base64 encoded image data.
675
676 - `JsonValue; type "image_url"constant`
677
678 Always `image_url`.
679
680 - `IMAGE_URL("image_url")`
681
682 - `class ModerationTextInput:`
683
684 An object describing text to classify.
685
686 - `String text`
687
688 A string of text to classify.
689
690 - `JsonValue; type "text"constant`
691
692 Always `text`.
693
694 - `TEXT("text")`
695
696### Moderation Text Input
697
698- `class ModerationTextInput:`
699
700 An object describing text to classify.
701
702 - `String text`
703
704 A string of text to classify.
705
706 - `JsonValue; type "text"constant`
707
708 Always `text`.
709
710 - `TEXT("text")`