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

Code interpreter sessions

admin.organization.usage.code_interpreter_sessions(UsageCodeInterpreterSessionsParams**kwargs) -> UsageCodeInterpreterSessionsResponse
GET/organization/usage/code_interpreter_sessions

Get code interpreter sessions usage details for the organization.

ParametersExpand Collapse
start_time: int

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

bucket_width: Optional[Literal["1m", "1h", "1d"]]

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

end_time: Optional[int]

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

group_by: Optional[List[Literal["project_id"]]]

Group the usage data by the specified fields. Support fields include project_id.

limit: Optional[int]

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
page: Optional[str]

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

project_ids: Optional[Sequence[str]]

Return only usage for these projects.

ReturnsExpand Collapse
class UsageCodeInterpreterSessionsResponse: …
data: List[Data]
has_more: bool
next_page: Optional[str]
object: Literal["page"]

Code interpreter sessions

import os
from openai import OpenAI

client = OpenAI(
    admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"),  # This is the default and can be omitted
)
response = client.admin.organization.usage.code_interpreter_sessions(
    start_time=0,
)
print(response.data)
{
    "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
}
Returns Examples
{
    "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
}