get /organization/usage/code_interpreter_sessions
Get code interpreter sessions usage details for the organization.
-
start_time: integerStart time (Unix seconds) of the query time range, inclusive.
-
bucket_width: optional "1m" or "1h" or "1d" (default: "1d")Width of each time bucket in response. Currently
1m,1hand1dare supported, default to1d.-
"1m" -
"1h" -
"1d"
-
-
end_time: optional integerEnd time (Unix seconds) of the query time range, exclusive.
-
group_by: optional array of "project_id"Group the usage data by the specified fields. Support fields include
project_id."project_id"
-
limit: optional integerSpecifies the number of buckets to return.
bucket_width=1d: default: 7, max: 31bucket_width=1h: default: 24, max: 168bucket_width=1m: default: 60, max: 1440
-
page: optional stringA cursor for use in pagination. Corresponding to the
next_pagefield from the previous response. -
project_ids: optional array of stringReturn only usage for these projects.
-
data: array of object { end_time, object, results, start_time }-
end_time: integer -
object: "bucket""bucket"
-
results: array of OrganizationUsageCompletionsResult { input_tokens, num_model_requests, object, 22 more } or OrganizationUsageEmbeddingsResult { input_tokens, num_model_requests, object, 4 more } or OrganizationUsageModerationsResult { input_tokens, num_model_requests, object, 4 more } or 8 more-
OrganizationUsageCompletionsResult object { input_tokens, num_model_requests, object, 22 more }The aggregated completions usage details of the specific time bucket.
-
input_tokens: integerThe aggregated number of input tokens used, including cached and cache-write tokens. This includes text, audio, and image tokens. For customers subscribed to Scale Tier, this includes Scale Tier tokens.
-
num_model_requests: integerThe count of requests made to the model.
-
object: "organization.usage.completions.result""organization.usage.completions.result"
-
output_tokens: integerThe aggregated number of output tokens used across text, audio, and image outputs. For customers subscribed to Scale Tier, this includes Scale Tier tokens.
-
api_key_id: optional string or nullWhen
group_by=api_key_id, this field provides the API key ID of the grouped usage result. -
api_source: optional "agents_api" or "unlabeled" or nullWhen grouped by
api_source,agents_apiidentifies attributed Agents API activity andunlabeledincludes all records without published source attribution, including historical and unknown origins. Unlabeled does not imply direct API usage. Without source grouping, this field is null.-
"agents_api" -
"unlabeled"
-
-
batch: optional boolean or nullWhen
group_by=batch, this field tells whether the grouped usage result is batch or not. -
input_audio_tokens: optional integerThe aggregated number of uncached audio input tokens used.
-
input_cache_write_12h_tokens: optional integerThe aggregated number of input tokens written to the cache with a 12-hour retention period.
-
input_cache_write_30m_tokens: optional integer or nullThe aggregated number of input tokens written to the cache with a 30-minute retention period. May be absent or null for older responses.
-
input_cache_write_tokens: optional integerThe aggregated number of input tokens written to the cache across 30-minute and 12-hour retention periods.
-
input_cached_audio_tokens: optional integerThe aggregated number of cached audio input tokens used.
-
input_cached_image_tokens: optional integerThe aggregated number of cached image input tokens used.
-
input_cached_text_tokens: optional integerThe aggregated number of cached text input tokens used.
-
input_cached_tokens: optional integerThe aggregated number of cached input tokens used across text, audio, and image inputs. For customers subscribed to Scale Tier, this includes Scale Tier tokens.
-
input_image_tokens: optional integerThe aggregated number of uncached image input tokens used.
-
input_text_tokens: optional integerThe aggregated number of uncached text input tokens used, excluding cache-write tokens.
-
input_uncached_tokens: optional integerThe aggregated number of uncached input tokens used across text, audio, and image inputs, excluding cache-write tokens.
-
model: optional string or nullWhen
group_by=model, this field provides the model name of the grouped usage result. -
output_audio_tokens: optional integerThe aggregated number of audio output tokens used.
-
output_image_tokens: optional integerThe aggregated number of image output tokens used.
-
output_text_tokens: optional integerThe aggregated number of text output tokens used.
-
project_id: optional string or nullWhen
group_by=project_id, this field provides the project ID of the grouped usage result. -
service_tier: optional string or nullWhen
group_by=service_tier, this field provides the service tier of the grouped usage result. -
user_id: optional string or nullWhen
group_by=user_id, this field provides the user ID of the grouped usage result.
-
-
OrganizationUsageEmbeddingsResult object { input_tokens, num_model_requests, object, 4 more }The aggregated embeddings usage details of the specific time bucket.
-
input_tokens: integerThe aggregated number of input tokens used.
-
num_model_requests: integerThe count of requests made to the model.
-
object: "organization.usage.embeddings.result""organization.usage.embeddings.result"
-
api_key_id: optional string or nullWhen
group_by=api_key_id, this field provides the API key ID of the grouped usage result. -
model: optional string or nullWhen
group_by=model, this field provides the model name of the grouped usage result. -
project_id: optional string or nullWhen
group_by=project_id, this field provides the project ID of the grouped usage result. -
user_id: optional string or nullWhen
group_by=user_id, this field provides the user ID of the grouped usage result.
-
-
OrganizationUsageModerationsResult object { input_tokens, num_model_requests, object, 4 more }The aggregated moderations usage details of the specific time bucket.
-
input_tokens: integerThe aggregated number of input tokens used.
-
num_model_requests: integerThe count of requests made to the model.
-
object: "organization.usage.moderations.result""organization.usage.moderations.result"
-
api_key_id: optional string or nullWhen
group_by=api_key_id, this field provides the API key ID of the grouped usage result. -
model: optional string or nullWhen
group_by=model, this field provides the model name of the grouped usage result. -
project_id: optional string or nullWhen
group_by=project_id, this field provides the project ID of the grouped usage result. -
user_id: optional string or nullWhen
group_by=user_id, this field provides the user ID of the grouped usage result.
-
-
OrganizationUsageImagesResult object { images, num_model_requests, object, 6 more }The aggregated images usage details of the specific time bucket.
-
images: integerThe number of images processed.
-
num_model_requests: integerThe count of requests made to the model.
-
object: "organization.usage.images.result""organization.usage.images.result"
-
api_key_id: optional string or nullWhen
group_by=api_key_id, this field provides the API key ID of the grouped usage result. -
model: optional string or nullWhen
group_by=model, this field provides the model name of the grouped usage result. -
project_id: optional string or nullWhen
group_by=project_id, this field provides the project ID of the grouped usage result. -
size: optional string or nullWhen
group_by=size, this field provides the image size of the grouped usage result. -
source: optional string or nullWhen
group_by=source, this field provides the source of the grouped usage result, possible values areimage.generation,image.edit,image.variation. -
user_id: optional string or nullWhen
group_by=user_id, this field provides the user ID of the grouped usage result.
-
-
OrganizationUsageAudioSpeechesResult object { characters, num_model_requests, object, 4 more }The aggregated audio speeches usage details of the specific time bucket.
-
characters: integerThe number of characters processed.
-
num_model_requests: integerThe count of requests made to the model.
-
object: "organization.usage.audio_speeches.result""organization.usage.audio_speeches.result"
-
api_key_id: optional string or nullWhen
group_by=api_key_id, this field provides the API key ID of the grouped usage result. -
model: optional string or nullWhen
group_by=model, this field provides the model name of the grouped usage result. -
project_id: optional string or nullWhen
group_by=project_id, this field provides the project ID of the grouped usage result. -
user_id: optional string or nullWhen
group_by=user_id, this field provides the user ID of the grouped usage result.
-
-
OrganizationUsageAudioTranscriptionsResult object { num_model_requests, object, seconds, 4 more }The aggregated audio transcriptions usage details of the specific time bucket.
-
num_model_requests: integerThe count of requests made to the model.
-
object: "organization.usage.audio_transcriptions.result""organization.usage.audio_transcriptions.result"
-
seconds: integerThe number of seconds processed.
format: int64 -
api_key_id: optional string or nullWhen
group_by=api_key_id, this field provides the API key ID of the grouped usage result. -
model: optional string or nullWhen
group_by=model, this field provides the model name of the grouped usage result. -
project_id: optional string or nullWhen
group_by=project_id, this field provides the project ID of the grouped usage result. -
user_id: optional string or nullWhen
group_by=user_id, this field provides the user ID of the grouped usage result.
-
-
OrganizationUsageVectorStoresResult object { object, usage_bytes, project_id }The aggregated vector stores usage details of the specific time bucket.
-
object: "organization.usage.vector_stores.result""organization.usage.vector_stores.result"
-
usage_bytes: integerThe vector stores usage in bytes.
-
project_id: optional string or nullWhen
group_by=project_id, this field provides the project ID of the grouped usage result.
-
-
OrganizationUsageCodeInterpreterSessionsResult object { num_sessions, object, project_id }The aggregated code interpreter sessions usage details of the specific time bucket.
-
num_sessions: integerThe number of code interpreter sessions.
-
object: "organization.usage.code_interpreter_sessions.result""organization.usage.code_interpreter_sessions.result"
-
project_id: optional string or nullWhen
group_by=project_id, this field provides the project ID of the grouped usage result.
-
-
OrganizationUsageFileSearchesResult object { num_requests, object, api_key_id, 3 more }The aggregated file search calls usage details of the specific time bucket.
-
num_requests: integerThe count of file search calls.
-
object: "organization.usage.file_searches.result""organization.usage.file_searches.result"
-
api_key_id: optional string or nullWhen
group_by=api_key_id, this field provides the API key ID of the grouped usage result. -
project_id: optional string or nullWhen
group_by=project_id, this field provides the project ID of the grouped usage result. -
user_id: optional string or nullWhen
group_by=user_id, this field provides the user ID of the grouped usage result. -
vector_store_id: optional string or nullWhen
group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.
-
-
OrganizationUsageWebSearchesResult object { num_model_requests, num_requests, object, 6 more }The aggregated web search calls usage details of the specific time bucket.
-
num_model_requests: integerThe count of model requests.
-
num_requests: integerThe count of web search calls.
-
object: "organization.usage.web_searches.result""organization.usage.web_searches.result"
-
api_key_id: optional string or nullWhen
group_by=api_key_id, this field provides the API key ID of the grouped usage result. -
api_source: optional "agents_api" or "unlabeled" or nullWhen grouped by
api_source,agents_apiidentifies attributed Agents API activity andunlabeledincludes all records without published source attribution, including historical and unknown origins. Unlabeled does not imply direct API usage. Without source grouping, this field is null.-
"agents_api" -
"unlabeled"
-
-
context_level: optional string or nullWhen
group_by=context_level, this field provides the search context size of the grouped usage result. -
model: optional string or nullWhen
group_by=model, this field provides the model name of the grouped usage result. -
project_id: optional string or nullWhen
group_by=project_id, this field provides the project ID of the grouped usage result. -
user_id: optional string or nullWhen
group_by=user_id, this field provides the user ID of the grouped usage result.
-
-
OrganizationCostsResult object { object, amount, api_key_id, 6 more }The aggregated costs details of the specific time bucket.
-
object: "organization.costs.result""organization.costs.result"
-
amount: optional object { currency, value }The monetary value in its associated currency.
-
currency: optional stringLowercase ISO-4217 currency e.g. "usd"
-
value: optional numberThe numeric value of the cost.
-
-
api_key_id: optional string or nullWhen
group_by=api_key_id, this field provides the API Key ID of the grouped costs result. -
api_source: optional "agents_api" or "unlabeled" or nullWhen grouped by
api_source,agents_apiidentifies attributed Agents API activity andunlabeledincludes all records without published source attribution, including historical and unknown origins. Unlabeled does not imply direct API usage. Without source grouping, this field is null.-
"agents_api" -
"unlabeled"
-
-
line_item: optional string or nullWhen
group_by=line_item, this field provides the line item of the grouped costs result. -
project_id: optional string or nullWhen
group_by=project_id, this field provides the project ID of the grouped costs result. -
quantity: optional number or nullWhen
group_by=line_item, this field provides the quantity of the grouped costs result. -
quantity_unit: optional CostQuantityUnit or nullThe unit of the
quantityvalue. If no single supported unit applies to the result, this field isnull.-
string -
"tokens" or "1000_tokens" or "duration_seconds" or 5 moreThe unit of the
quantityvalue. If no single supported unit applies to the result, this field isnull.-
"tokens" -
"1000_tokens" -
"duration_seconds" -
"duration_minutes" -
"duration_hours" -
"gibibyte_hours" -
"images" -
"characters"
-
-
-
user_id: optional string or nullWhen
group_by=user_id, this field provides the user ID of the grouped costs result.
-
-
-
start_time: integer
-
-
has_more: boolean -
next_page: string or null -
object: "page""page"
curl "https://api.openai.com/v1/organization/usage/code_interpreter_sessions?start_time=0" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY"{
"data": [
{
"end_time": 0,
"object": "bucket",
"results": [
{
"input_tokens": 0,
"num_model_requests": 0,
"object": "organization.usage.completions.result",
"output_tokens": 0,
"api_key_id": "api_key_id",
"api_source": "agents_api",
"batch": true,
"input_audio_tokens": 0,
"input_cache_write_12h_tokens": 0,
"input_cache_write_30m_tokens": 0,
"input_cache_write_tokens": 0,
"input_cached_audio_tokens": 0,
"input_cached_image_tokens": 0,
"input_cached_text_tokens": 0,
"input_cached_tokens": 0,
"input_image_tokens": 0,
"input_text_tokens": 0,
"input_uncached_tokens": 0,
"model": "model",
"output_audio_tokens": 0,
"output_image_tokens": 0,
"output_text_tokens": 0,
"project_id": "project_id",
"service_tier": "service_tier",
"user_id": "user_id"
}
],
"start_time": 0
}
],
"has_more": true,
"next_page": "next_page",
"object": "page"
}curl "https://api.openai.com/v1/organization/usage/code_interpreter_sessions?start_time=1730419200&limit=1" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
-H "Content-Type: application/json"{
"object": "page",
"data": [
{
"object": "bucket",
"start_time": 1730419200,
"end_time": 1730505600,
"results": [
{
"object": "organization.usage.code_interpreter_sessions.result",
"num_sessions": 1,
"project_id": null
}
]
}
],
"has_more": false,
"next_page": null
}