go/resources/moderations/index.md +0 −723 deleted
File Deleted View Diff
1# Moderations
2
3## Create moderation
4
5`client.Moderations.New(ctx, body) (*ModerationNewResponse, error)`
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- `body ModerationNewParams`
15
16 - `Input param.Field[ModerationNewParamsInputUnion]`
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 - `type ModerationNewParamsInputArray []string`
24
25 An array of strings to classify for moderation.
26
27 - `type ModerationNewParamsInputModerationMultiModalArray []ModerationMultiModalInputUnion`
28
29 An array of multi-modal inputs to the moderation model.
30
31 - `type ModerationImageURLInput struct{…}`
32
33 An object describing an image to classify.
34
35 - `ImageURL ModerationImageURLInputImageURL`
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 ImageURL`
44
45 Always `image_url`.
46
47 - `const ImageURLImageURL ImageURL = "image_url"`
48
49 - `type ModerationTextInput struct{…}`
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 - `const TextText Text = "text"`
62
63 - `Model param.Field[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`
70
71 - `type ModerationModel string`
72
73 - `const ModerationModelOmniModerationLatest ModerationModel = "omni-moderation-latest"`
74
75 - `const ModerationModelOmniModeration2024_09_26 ModerationModel = "omni-moderation-2024-09-26"`
76
77 - `const ModerationModelTextModerationLatest ModerationModel = "text-moderation-latest"`
78
79 - `const ModerationModelTextModerationStable ModerationModel = "text-moderation-stable"`
80
81### Returns
82
83- `type ModerationNewResponse struct{…}`
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 []Moderation`
96
97 A list of moderation objects.
98
99 - `Categories ModerationCategories`
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 - `HarassmentThreatening 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 - `HateThreatening 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 - `IllicitViolent 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 - `SelfHarm bool`
128
129 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.
130
131 - `SelfHarmInstructions 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 - `SelfHarmIntent 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 - `SexualMinors 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 - `ViolenceGraphic bool`
152
153 Content that depicts death, violence, or physical injury in graphic detail.
154
155 - `CategoryAppliedInputTypes ModerationCategoryAppliedInputTypes`
156
157 A list of the categories along with the input type(s) that the score applies to.
158
159 - `Harassment []string`
160
161 The applied input type(s) for the category 'harassment'.
162
163 - `const ModerationCategoryAppliedInputTypesHarassmentText ModerationCategoryAppliedInputTypesHarassment = "text"`
164
165 - `HarassmentThreatening []string`
166
167 The applied input type(s) for the category 'harassment/threatening'.
168
169 - `const ModerationCategoryAppliedInputTypesHarassmentThreateningText ModerationCategoryAppliedInputTypesHarassmentThreatening = "text"`
170
171 - `Hate []string`
172
173 The applied input type(s) for the category 'hate'.
174
175 - `const ModerationCategoryAppliedInputTypesHateText ModerationCategoryAppliedInputTypesHate = "text"`
176
177 - `HateThreatening []string`
178
179 The applied input type(s) for the category 'hate/threatening'.
180
181 - `const ModerationCategoryAppliedInputTypesHateThreateningText ModerationCategoryAppliedInputTypesHateThreatening = "text"`
182
183 - `Illicit []string`
184
185 The applied input type(s) for the category 'illicit'.
186
187 - `const ModerationCategoryAppliedInputTypesIllicitText ModerationCategoryAppliedInputTypesIllicit = "text"`
188
189 - `IllicitViolent []string`
190
191 The applied input type(s) for the category 'illicit/violent'.
192
193 - `const ModerationCategoryAppliedInputTypesIllicitViolentText ModerationCategoryAppliedInputTypesIllicitViolent = "text"`
194
195 - `SelfHarm []string`
196
197 The applied input type(s) for the category 'self-harm'.
198
199 - `const ModerationCategoryAppliedInputTypesSelfHarmText ModerationCategoryAppliedInputTypesSelfHarm = "text"`
200
201 - `const ModerationCategoryAppliedInputTypesSelfHarmImage ModerationCategoryAppliedInputTypesSelfHarm = "image"`
202
203 - `SelfHarmInstructions []string`
204
205 The applied input type(s) for the category 'self-harm/instructions'.
206
207 - `const ModerationCategoryAppliedInputTypesSelfHarmInstructionText ModerationCategoryAppliedInputTypesSelfHarmInstruction = "text"`
208
209 - `const ModerationCategoryAppliedInputTypesSelfHarmInstructionImage ModerationCategoryAppliedInputTypesSelfHarmInstruction = "image"`
210
211 - `SelfHarmIntent []string`
212
213 The applied input type(s) for the category 'self-harm/intent'.
214
215 - `const ModerationCategoryAppliedInputTypesSelfHarmIntentText ModerationCategoryAppliedInputTypesSelfHarmIntent = "text"`
216
217 - `const ModerationCategoryAppliedInputTypesSelfHarmIntentImage ModerationCategoryAppliedInputTypesSelfHarmIntent = "image"`
218
219 - `Sexual []string`
220
221 The applied input type(s) for the category 'sexual'.
222
223 - `const ModerationCategoryAppliedInputTypesSexualText ModerationCategoryAppliedInputTypesSexual = "text"`
224
225 - `const ModerationCategoryAppliedInputTypesSexualImage ModerationCategoryAppliedInputTypesSexual = "image"`
226
227 - `SexualMinors []string`
228
229 The applied input type(s) for the category 'sexual/minors'.
230
231 - `const ModerationCategoryAppliedInputTypesSexualMinorText ModerationCategoryAppliedInputTypesSexualMinor = "text"`
232
233 - `Violence []string`
234
235 The applied input type(s) for the category 'violence'.
236
237 - `const ModerationCategoryAppliedInputTypesViolenceText ModerationCategoryAppliedInputTypesViolence = "text"`
238
239 - `const ModerationCategoryAppliedInputTypesViolenceImage ModerationCategoryAppliedInputTypesViolence = "image"`
240
241 - `ViolenceGraphic []string`
242
243 The applied input type(s) for the category 'violence/graphic'.
244
245 - `const ModerationCategoryAppliedInputTypesViolenceGraphicText ModerationCategoryAppliedInputTypesViolenceGraphic = "text"`
246
247 - `const ModerationCategoryAppliedInputTypesViolenceGraphicImage ModerationCategoryAppliedInputTypesViolenceGraphic = "image"`
248
249 - `CategoryScores ModerationCategoryScores`
250
251 A list of the categories along with their scores as predicted by model.
252
253 - `Harassment float64`
254
255 The score for the category 'harassment'.
256
257 - `HarassmentThreatening float64`
258
259 The score for the category 'harassment/threatening'.
260
261 - `Hate float64`
262
263 The score for the category 'hate'.
264
265 - `HateThreatening float64`
266
267 The score for the category 'hate/threatening'.
268
269 - `Illicit float64`
270
271 The score for the category 'illicit'.
272
273 - `IllicitViolent float64`
274
275 The score for the category 'illicit/violent'.
276
277 - `SelfHarm float64`
278
279 The score for the category 'self-harm'.
280
281 - `SelfHarmInstructions float64`
282
283 The score for the category 'self-harm/instructions'.
284
285 - `SelfHarmIntent float64`
286
287 The score for the category 'self-harm/intent'.
288
289 - `Sexual float64`
290
291 The score for the category 'sexual'.
292
293 - `SexualMinors float64`
294
295 The score for the category 'sexual/minors'.
296
297 - `Violence float64`
298
299 The score for the category 'violence'.
300
301 - `ViolenceGraphic float64`
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```go
312package main
313
314import (
315 "context"
316 "fmt"
317
318 "github.com/openai/openai-go"
319 "github.com/openai/openai-go/option"
320)
321
322func main() {
323 client := openai.NewClient(
324 option.WithAPIKey("My API Key"),
325 )
326 moderation, err := client.Moderations.New(context.TODO(), openai.ModerationNewParams{
327 Input: openai.ModerationNewParamsInputUnion{
328 OfString: openai.String("I want to kill them."),
329 },
330 })
331 if err != nil {
332 panic(err.Error())
333 }
334 fmt.Printf("%+v\n", moderation.ID)
335}
336```
337
338#### Response
339
340```json
341{
342 "id": "id",
343 "model": "model",
344 "results": [
345 {
346 "categories": {
347 "harassment": true,
348 "harassment/threatening": true,
349 "hate": true,
350 "hate/threatening": true,
351 "illicit": true,
352 "illicit/violent": true,
353 "self-harm": true,
354 "self-harm/instructions": true,
355 "self-harm/intent": true,
356 "sexual": true,
357 "sexual/minors": true,
358 "violence": true,
359 "violence/graphic": true
360 },
361 "category_applied_input_types": {
362 "harassment": [
363 "text"
364 ],
365 "harassment/threatening": [
366 "text"
367 ],
368 "hate": [
369 "text"
370 ],
371 "hate/threatening": [
372 "text"
373 ],
374 "illicit": [
375 "text"
376 ],
377 "illicit/violent": [
378 "text"
379 ],
380 "self-harm": [
381 "text"
382 ],
383 "self-harm/instructions": [
384 "text"
385 ],
386 "self-harm/intent": [
387 "text"
388 ],
389 "sexual": [
390 "text"
391 ],
392 "sexual/minors": [
393 "text"
394 ],
395 "violence": [
396 "text"
397 ],
398 "violence/graphic": [
399 "text"
400 ]
401 },
402 "category_scores": {
403 "harassment": 0,
404 "harassment/threatening": 0,
405 "hate": 0,
406 "hate/threatening": 0,
407 "illicit": 0,
408 "illicit/violent": 0,
409 "self-harm": 0,
410 "self-harm/instructions": 0,
411 "self-harm/intent": 0,
412 "sexual": 0,
413 "sexual/minors": 0,
414 "violence": 0,
415 "violence/graphic": 0
416 },
417 "flagged": true
418 }
419 ]
420}
421```
422
423## Domain Types
424
425### Moderation
426
427- `type Moderation struct{…}`
428
429 - `Categories ModerationCategories`
430
431 A list of the categories, and whether they are flagged or not.
432
433 - `Harassment bool`
434
435 Content that expresses, incites, or promotes harassing language towards any target.
436
437 - `HarassmentThreatening bool`
438
439 Harassment content that also includes violence or serious harm towards any target.
440
441 - `Hate bool`
442
443 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.
444
445 - `HateThreatening bool`
446
447 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.
448
449 - `Illicit bool`
450
451 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.
452
453 - `IllicitViolent bool`
454
455 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.
456
457 - `SelfHarm bool`
458
459 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.
460
461 - `SelfHarmInstructions bool`
462
463 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.
464
465 - `SelfHarmIntent bool`
466
467 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.
468
469 - `Sexual bool`
470
471 Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).
472
473 - `SexualMinors bool`
474
475 Sexual content that includes an individual who is under 18 years old.
476
477 - `Violence bool`
478
479 Content that depicts death, violence, or physical injury.
480
481 - `ViolenceGraphic bool`
482
483 Content that depicts death, violence, or physical injury in graphic detail.
484
485 - `CategoryAppliedInputTypes ModerationCategoryAppliedInputTypes`
486
487 A list of the categories along with the input type(s) that the score applies to.
488
489 - `Harassment []string`
490
491 The applied input type(s) for the category 'harassment'.
492
493 - `const ModerationCategoryAppliedInputTypesHarassmentText ModerationCategoryAppliedInputTypesHarassment = "text"`
494
495 - `HarassmentThreatening []string`
496
497 The applied input type(s) for the category 'harassment/threatening'.
498
499 - `const ModerationCategoryAppliedInputTypesHarassmentThreateningText ModerationCategoryAppliedInputTypesHarassmentThreatening = "text"`
500
501 - `Hate []string`
502
503 The applied input type(s) for the category 'hate'.
504
505 - `const ModerationCategoryAppliedInputTypesHateText ModerationCategoryAppliedInputTypesHate = "text"`
506
507 - `HateThreatening []string`
508
509 The applied input type(s) for the category 'hate/threatening'.
510
511 - `const ModerationCategoryAppliedInputTypesHateThreateningText ModerationCategoryAppliedInputTypesHateThreatening = "text"`
512
513 - `Illicit []string`
514
515 The applied input type(s) for the category 'illicit'.
516
517 - `const ModerationCategoryAppliedInputTypesIllicitText ModerationCategoryAppliedInputTypesIllicit = "text"`
518
519 - `IllicitViolent []string`
520
521 The applied input type(s) for the category 'illicit/violent'.
522
523 - `const ModerationCategoryAppliedInputTypesIllicitViolentText ModerationCategoryAppliedInputTypesIllicitViolent = "text"`
524
525 - `SelfHarm []string`
526
527 The applied input type(s) for the category 'self-harm'.
528
529 - `const ModerationCategoryAppliedInputTypesSelfHarmText ModerationCategoryAppliedInputTypesSelfHarm = "text"`
530
531 - `const ModerationCategoryAppliedInputTypesSelfHarmImage ModerationCategoryAppliedInputTypesSelfHarm = "image"`
532
533 - `SelfHarmInstructions []string`
534
535 The applied input type(s) for the category 'self-harm/instructions'.
536
537 - `const ModerationCategoryAppliedInputTypesSelfHarmInstructionText ModerationCategoryAppliedInputTypesSelfHarmInstruction = "text"`
538
539 - `const ModerationCategoryAppliedInputTypesSelfHarmInstructionImage ModerationCategoryAppliedInputTypesSelfHarmInstruction = "image"`
540
541 - `SelfHarmIntent []string`
542
543 The applied input type(s) for the category 'self-harm/intent'.
544
545 - `const ModerationCategoryAppliedInputTypesSelfHarmIntentText ModerationCategoryAppliedInputTypesSelfHarmIntent = "text"`
546
547 - `const ModerationCategoryAppliedInputTypesSelfHarmIntentImage ModerationCategoryAppliedInputTypesSelfHarmIntent = "image"`
548
549 - `Sexual []string`
550
551 The applied input type(s) for the category 'sexual'.
552
553 - `const ModerationCategoryAppliedInputTypesSexualText ModerationCategoryAppliedInputTypesSexual = "text"`
554
555 - `const ModerationCategoryAppliedInputTypesSexualImage ModerationCategoryAppliedInputTypesSexual = "image"`
556
557 - `SexualMinors []string`
558
559 The applied input type(s) for the category 'sexual/minors'.
560
561 - `const ModerationCategoryAppliedInputTypesSexualMinorText ModerationCategoryAppliedInputTypesSexualMinor = "text"`
562
563 - `Violence []string`
564
565 The applied input type(s) for the category 'violence'.
566
567 - `const ModerationCategoryAppliedInputTypesViolenceText ModerationCategoryAppliedInputTypesViolence = "text"`
568
569 - `const ModerationCategoryAppliedInputTypesViolenceImage ModerationCategoryAppliedInputTypesViolence = "image"`
570
571 - `ViolenceGraphic []string`
572
573 The applied input type(s) for the category 'violence/graphic'.
574
575 - `const ModerationCategoryAppliedInputTypesViolenceGraphicText ModerationCategoryAppliedInputTypesViolenceGraphic = "text"`
576
577 - `const ModerationCategoryAppliedInputTypesViolenceGraphicImage ModerationCategoryAppliedInputTypesViolenceGraphic = "image"`
578
579 - `CategoryScores ModerationCategoryScores`
580
581 A list of the categories along with their scores as predicted by model.
582
583 - `Harassment float64`
584
585 The score for the category 'harassment'.
586
587 - `HarassmentThreatening float64`
588
589 The score for the category 'harassment/threatening'.
590
591 - `Hate float64`
592
593 The score for the category 'hate'.
594
595 - `HateThreatening float64`
596
597 The score for the category 'hate/threatening'.
598
599 - `Illicit float64`
600
601 The score for the category 'illicit'.
602
603 - `IllicitViolent float64`
604
605 The score for the category 'illicit/violent'.
606
607 - `SelfHarm float64`
608
609 The score for the category 'self-harm'.
610
611 - `SelfHarmInstructions float64`
612
613 The score for the category 'self-harm/instructions'.
614
615 - `SelfHarmIntent float64`
616
617 The score for the category 'self-harm/intent'.
618
619 - `Sexual float64`
620
621 The score for the category 'sexual'.
622
623 - `SexualMinors float64`
624
625 The score for the category 'sexual/minors'.
626
627 - `Violence float64`
628
629 The score for the category 'violence'.
630
631 - `ViolenceGraphic float64`
632
633 The score for the category 'violence/graphic'.
634
635 - `Flagged bool`
636
637 Whether any of the below categories are flagged.
638
639### Moderation Image URL Input
640
641- `type ModerationImageURLInput struct{…}`
642
643 An object describing an image to classify.
644
645 - `ImageURL ModerationImageURLInputImageURL`
646
647 Contains either an image URL or a data URL for a base64 encoded image.
648
649 - `URL string`
650
651 Either a URL of the image or the base64 encoded image data.
652
653 - `Type ImageURL`
654
655 Always `image_url`.
656
657 - `const ImageURLImageURL ImageURL = "image_url"`
658
659### Moderation Model
660
661- `type ModerationModel string`
662
663 - `const ModerationModelOmniModerationLatest ModerationModel = "omni-moderation-latest"`
664
665 - `const ModerationModelOmniModeration2024_09_26 ModerationModel = "omni-moderation-2024-09-26"`
666
667 - `const ModerationModelTextModerationLatest ModerationModel = "text-moderation-latest"`
668
669 - `const ModerationModelTextModerationStable ModerationModel = "text-moderation-stable"`
670
671### Moderation Multi Modal Input
672
673- `type ModerationMultiModalInputUnion interface{…}`
674
675 An object describing an image to classify.
676
677 - `type ModerationImageURLInput struct{…}`
678
679 An object describing an image to classify.
680
681 - `ImageURL ModerationImageURLInputImageURL`
682
683 Contains either an image URL or a data URL for a base64 encoded image.
684
685 - `URL string`
686
687 Either a URL of the image or the base64 encoded image data.
688
689 - `Type ImageURL`
690
691 Always `image_url`.
692
693 - `const ImageURLImageURL ImageURL = "image_url"`
694
695 - `type ModerationTextInput struct{…}`
696
697 An object describing text to classify.
698
699 - `Text string`
700
701 A string of text to classify.
702
703 - `Type Text`
704
705 Always `text`.
706
707 - `const TextText Text = "text"`
708
709### Moderation Text Input
710
711- `type ModerationTextInput struct{…}`
712
713 An object describing text to classify.
714
715 - `Text string`
716
717 A string of text to classify.
718
719 - `Type Text`
720
721 Always `text`.
722
723 - `const TextText Text = "text"`