Web search calls
Get web search calls usage details for the organization.
ParametersExpand Collapse
query: UsageWebSearchCallsParams { start_time, api_key_ids, bucket_width, 8 more }
bucket_width?: "1m" | "1h" | "1d"Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.
Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.
context_levels?: Array<"low" | "medium" | "high">Return only web search usage for these context levels.
Return only web search usage for these context levels.
group_by?: Array<"project_id" | "user_id" | "api_key_id" | 2 more>Group the usage data by the specified fields. Support fields include project_id, user_id, api_key_id, model, context_level or any combination of them.
Group the usage data by the specified fields. Support fields include project_id, user_id, api_key_id, model, context_level or any combination of them.
Specifies 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
ReturnsExpand Collapse
UsageWebSearchCallsResponse { data, has_more, next_page, object }
data: Array<Data>
results: Array<OrganizationUsageCompletionsResult { input_tokens, num_model_requests, object, 19 more } | OrganizationUsageEmbeddingsResult { input_tokens, num_model_requests, object, 4 more } | OrganizationUsageModerationsResult { input_tokens, num_model_requests, object, 4 more } | 8 more>
OrganizationUsageCompletionsResult { input_tokens, num_model_requests, object, 19 more } The aggregated completions usage details of the specific time bucket.
The aggregated completions usage details of the specific time bucket.
The 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.
The aggregated number of output tokens used across text, audio, and image outputs. For customers subscribed to Scale Tier, this includes Scale Tier tokens.
When group_by=api_key_id, this field provides the API key ID of the grouped usage result.
When group_by=batch, this field tells whether the grouped usage result is batch or not.
The aggregated number of cached input tokens used across text, audio, and image inputs. For customers subscribed to Scale Tier, this includes Scale Tier tokens.
The aggregated number of uncached text input tokens used, excluding cache-write tokens.
The aggregated number of uncached input tokens used across text, audio, and image inputs, excluding cache-write tokens.
When group_by=model, this field provides the model name of the grouped usage result.
When group_by=project_id, this field provides the project ID of the grouped usage result.
OrganizationUsageEmbeddingsResult { input_tokens, num_model_requests, object, 4 more } The aggregated embeddings usage details of the specific time bucket.
The aggregated embeddings usage details of the specific time bucket.
When group_by=api_key_id, this field provides the API key ID of the grouped usage result.
When group_by=model, this field provides the model name of the grouped usage result.
OrganizationUsageModerationsResult { input_tokens, num_model_requests, object, 4 more } The aggregated moderations usage details of the specific time bucket.
The aggregated moderations usage details of the specific time bucket.
When group_by=api_key_id, this field provides the API key ID of the grouped usage result.
When group_by=model, this field provides the model name of the grouped usage result.
OrganizationUsageImagesResult { images, num_model_requests, object, 6 more } The aggregated images usage details of the specific time bucket.
The aggregated images usage details of the specific time bucket.
When group_by=api_key_id, this field provides the API key ID of the grouped usage result.
When group_by=model, this field provides the model name of the grouped usage result.
When group_by=project_id, this field provides the project ID of the grouped usage result.
When group_by=size, this field provides the image size of the grouped usage result.
OrganizationUsageAudioSpeechesResult { characters, num_model_requests, object, 4 more } The aggregated audio speeches usage details of the specific time bucket.
The aggregated audio speeches usage details of the specific time bucket.
When group_by=api_key_id, this field provides the API key ID of the grouped usage result.
When group_by=model, this field provides the model name of the grouped usage result.
OrganizationUsageAudioTranscriptionsResult { num_model_requests, object, seconds, 4 more } The aggregated audio transcriptions usage details of the specific time bucket.
The aggregated audio transcriptions usage details of the specific time bucket.
When group_by=api_key_id, this field provides the API key ID of the grouped usage result.
When group_by=model, this field provides the model name of the grouped usage result.
OrganizationUsageVectorStoresResult { object, usage_bytes, project_id } The aggregated vector stores usage details of the specific time bucket.
The aggregated vector stores usage details of the specific time bucket.
OrganizationUsageCodeInterpreterSessionsResult { num_sessions, object, project_id } The aggregated code interpreter sessions usage details of the specific time bucket.
The aggregated code interpreter sessions usage details of the specific time bucket.
OrganizationUsageFileSearchesResult { num_requests, object, api_key_id, 3 more } The aggregated file search calls usage details of the specific time bucket.
The aggregated file search calls usage details of the specific time bucket.
When group_by=api_key_id, this field provides the API key ID of the grouped usage result.
When group_by=project_id, this field provides the project ID of the grouped usage result.
OrganizationUsageWebSearchesResult { num_model_requests, num_requests, object, 5 more } The aggregated web search calls usage details of the specific time bucket.
The aggregated web search calls usage details of the specific time bucket.
When group_by=api_key_id, this field provides the API key ID of the grouped usage result.
When group_by=context_level, this field provides the search context size of the grouped usage result.
When group_by=model, this field provides the model name of the grouped usage result.
OrganizationCostsResult { object, amount, api_key_id, 3 more } The aggregated costs details of the specific time bucket.
The aggregated costs details of the specific time bucket.
When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.
When group_by=line_item, this field provides the line item of the grouped costs result.
Web search calls
import OpenAI from 'openai';
const client = new OpenAI({
adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted
});
const response = await client.admin.organization.usage.webSearchCalls({ start_time: 0 });
console.log(response.data);{
"object": "page",
"data": [
{
"object": "bucket",
"start_time": 1730419200,
"end_time": 1730505600,
"results": [
{
"object": "organization.usage.web_searches.result",
"num_model_requests": 2,
"num_requests": 2,
"project_id": null,
"user_id": null,
"api_key_id": null,
"model": null,
"context_level": null
}
]
}
],
"has_more": false,
"next_page": null
}
Returns Examples
{
"object": "page",
"data": [
{
"object": "bucket",
"start_time": 1730419200,
"end_time": 1730505600,
"results": [
{
"object": "organization.usage.web_searches.result",
"num_model_requests": 2,
"num_requests": 2,
"project_id": null,
"user_id": null,
"api_key_id": null,
"model": null,
"context_level": null
}
]
}
],
"has_more": false,
"next_page": null
}