Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation
Theme

Web search calls

client.admin.organization.usage.webSearchCalls(query, options?): UsageWebSearchCallsResponse { data, has_more, next_page, object }
GET
/organization/usage/web_search_calls

Get web search calls usage details for the organization.

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);
Response example
{
    "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
}
Parameters
query: UsageWebSearchCallsParams { start_time, api_key_ids, bucket_width, 8 more }
start_time: number

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

api_key_ids?: Array<string>

Return only usage for these API keys.

bucket_width?: "1m" | "1h" | "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.

end_time?: number

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

group_by?: Array<"project_id" | "user_id" | "api_key_id" | 3 more>

Group the usage data by the specified fields. Support fields include project_id, user_id, api_key_id, model, context_level, api_source or any combination of them. When grouped by api_source, results use agents_api for attributed Agents API activity and unlabeled for all other activity. Without source grouping, api_source is null.

limit?: number

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
models?: Array<string>

Return only usage for these models.

page?: string

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

project_ids?: Array<string>

Return only usage for these projects.

user_ids?: Array<string>

Return only usage for these users.

Returns
UsageWebSearchCallsResponse { data, has_more, next_page, object }
data: Array<Data>
has_more: boolean
next_page: string | null
object: "page"
Returns Examples
Response example
{
    "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
}