OpenAI API

Classifies if text and/or image inputs are potentially harmful. Learn more in the [moderation guide](/docs/guides/moderation).

post
https://api.openai.com/v1/moderations

Body

application/json

CreateModerationRequest

inputOne Of
required

Input (or inputs) to classify. Can be a single string, an array of strings, or
an array of multi-modal input objects similar to other models.

Variant 1string

A string of text to classify for moderation.

Default:

Example:I want to kill them.

modelAny Of

The content moderation model you would like to use. Learn more in
the moderation guide, and learn about
available models here.

Default:omni-moderation-latest

Example:omni-moderation-2024-09-26

Variant 1string

Response

200 application/json

OK

CreateModerationResponse

Represents if a given text input is potentially harmful.

idstringrequired

The unique identifier for the moderation request.

modelstringrequired

The model used to generate the moderation results.

resultsarray[object]required

A list of moderation objects.

Show Child Parameters
post/moderations

Body

{ "input": "I want to kill them." }
 
200 application/json

Audit Logs

List user actions and configuration changes within this organization.

List user actions and configuration changes within this organization.

get
https://api.openai.com/v1/organization/audit_logs

Query Parameters

effective_atobject

Return only events whose effective_at (Unix seconds) is in this range.

Show Child Parameters
project_ids[]array[string]

Return only events for these projects.

event_types[]array[string]

The event type.

Allowed values:api_key.createdapi_key.updatedapi_key.deletedinvite.sentinvite.acceptedinvite.deletedlogin.succeededlogin.failedlogout.succeededlogout.failedorganization.updatedproject.createdproject.updatedproject.archivedservice_account.createdservice_account.updatedservice_account.deletedrate_limit.updatedrate_limit.deleteduser.addeduser.updateduser.deleted

actor_ids[]array[string]

Return only events performed by these actors. Can be a user ID, a service account ID, or an api key tracking ID.

actor_emails[]array[string]

Return only events performed by users with these emails.

resource_ids[]array[string]

Return only events performed on these targets. For example, a project ID updated.

limitinteger

A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

Default:20

afterstring

A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

beforestring

A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

Response

200 application/json

Audit logs listed successfully.

ListAuditLogsResponse

objectstringrequired

Allowed values:list

dataarray[object]required

A log of a user action or configuration change within this organization.

Show Child Parameters
first_idstringrequired

Example:audit_log-defb456h8dks

last_idstringrequired

Example:audit_log-hnbkd8s93s

has_morebooleanrequired
get/organization/audit_logs
 
200 application/json

Get costs details for the organization.

get
https://api.openai.com/v1/organization/costs

Query Parameters

start_timeintegerrequired

Start time (Unix seconds) of the query time range, inclusive.

end_timeinteger

End time (Unix seconds) of the query time range, exclusive.

bucket_widthstring

Width of each time bucket in response. Currently only 1d is supported, default to 1d.

Allowed values:1d

Default:1d

project_idsarray[string]

Return only costs for these projects.

group_byarray[string]

Group the costs by the specified fields. Support fields include project_id, line_item and any combination of them.

Allowed values:project_idline_item

limitinteger

A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7.

Default:7

pagestring

A cursor for use in pagination. Corresponding to the next_page field from the previous response.

Response

200 application/json

Costs data retrieved successfully.

UsageResponse

objectstringrequired

Allowed values:page

dataarray[object]required
Show Child Parameters
has_morebooleanrequired
next_pagestringrequired
get/organization/costs
 
200 application/json

Get audio speeches usage details for the organization.

get
https://api.openai.com/v1/organization/usage/audio_speeches

Query Parameters

start_timeintegerrequired

Start time (Unix seconds) of the query time range, inclusive.

end_timeinteger

End time (Unix seconds) of the query time range, exclusive.

bucket_widthstring

Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.

Allowed values:1m1h1d

Default:1d

project_idsarray[string]

Return only usage for these projects.

user_idsarray[string]

Return only usage for these users.

api_key_idsarray[string]

Return only usage for these API keys.

modelsarray[string]

Return only usage for these models.

group_byarray[string]

Group the usage data by the specified fields. Support fields include project_id, user_id, api_key_id, model or any combination of them.

Allowed values:project_iduser_idapi_key_idmodel

limitinteger

Specifies the number of buckets to return.

  • bucket_width=1d: default: 7, max: 31
  • bucket_width=1h: default: 24, max: 168
  • bucket_width=1m: default: 60, max: 1440
pagestring

A cursor for use in pagination. Corresponding to the next_page field from the previous response.

Response

200 application/json

Usage data retrieved successfully.

UsageResponse

objectstringrequired

Allowed values:page

dataarray[object]required
Show Child Parameters
has_morebooleanrequired
next_pagestringrequired
get/organization/usage/audio_speeches
 
200 application/json