Skip to content
Primary navigation

Code interpreter sessions

client.Admin.Organization.Usage.CodeInterpreterSessions(ctx, query) (*AdminOrganizationUsageCodeInterpreterSessionsResponse, error)
GET/organization/usage/code_interpreter_sessions

Get code interpreter sessions usage details for the organization.

ParametersExpand Collapse
query AdminOrganizationUsageCodeInterpreterSessionsParams
StartTime param.Field[int64]

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

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

const AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth1m AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth = "1m"
const AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth1h AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth = "1h"
const AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth1d AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth = "1d"
EndTime param.Field[int64]Optional

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

GroupBy param.Field[[]string]Optional

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

const AdminOrganizationUsageCodeInterpreterSessionsParamsGroupByProjectID AdminOrganizationUsageCodeInterpreterSessionsParamsGroupBy = "project_id"
Limit param.Field[int64]Optional

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 param.Field[string]Optional

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

ProjectIDs param.Field[[]string]Optional

Return only usage for these projects.

ReturnsExpand Collapse
type AdminOrganizationUsageCodeInterpreterSessionsResponse struct{…}
Data []AdminOrganizationUsageCodeInterpreterSessionsResponseData
EndTime int64
Object Bucket
Results []AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion
One of the following:
type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult struct{…}

The aggregated completions usage details of the specific time bucket.

InputTokens int64

The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

NumModelRequests int64

The count of requests made to the model.

Object OrganizationUsageCompletionsResult
OutputTokens int64

The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

APIKeyID stringOptional

When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

Batch boolOptional

When group_by=batch, this field tells whether the grouped usage result is batch or not.

InputAudioTokens int64Optional

The aggregated number of audio input tokens used, including cached tokens.

InputCachedTokens int64Optional

The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

Model stringOptional

When group_by=model, this field provides the model name of the grouped usage result.

OutputAudioTokens int64Optional

The aggregated number of audio output tokens used.

ProjectID stringOptional

When group_by=project_id, this field provides the project ID of the grouped usage result.

ServiceTier stringOptional

When group_by=service_tier, this field provides the service tier of the grouped usage result.

UserID stringOptional

When group_by=user_id, this field provides the user ID of the grouped usage result.

type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageEmbeddingsResult struct{…}

The aggregated embeddings usage details of the specific time bucket.

InputTokens int64

The aggregated number of input tokens used.

NumModelRequests int64

The count of requests made to the model.

Object OrganizationUsageEmbeddingsResult
APIKeyID stringOptional

When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

Model stringOptional

When group_by=model, this field provides the model name of the grouped usage result.

ProjectID stringOptional

When group_by=project_id, this field provides the project ID of the grouped usage result.

UserID stringOptional

When group_by=user_id, this field provides the user ID of the grouped usage result.

type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageModerationsResult struct{…}

The aggregated moderations usage details of the specific time bucket.

InputTokens int64

The aggregated number of input tokens used.

NumModelRequests int64

The count of requests made to the model.

Object OrganizationUsageModerationsResult
APIKeyID stringOptional

When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

Model stringOptional

When group_by=model, this field provides the model name of the grouped usage result.

ProjectID stringOptional

When group_by=project_id, this field provides the project ID of the grouped usage result.

UserID stringOptional

When group_by=user_id, this field provides the user ID of the grouped usage result.

type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageImagesResult struct{…}

The aggregated images usage details of the specific time bucket.

Images int64

The number of images processed.

NumModelRequests int64

The count of requests made to the model.

Object OrganizationUsageImagesResult
APIKeyID stringOptional

When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

Model stringOptional

When group_by=model, this field provides the model name of the grouped usage result.

ProjectID stringOptional

When group_by=project_id, this field provides the project ID of the grouped usage result.

Size stringOptional

When group_by=size, this field provides the image size of the grouped usage result.

Source stringOptional

When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

UserID stringOptional

When group_by=user_id, this field provides the user ID of the grouped usage result.

type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioSpeechesResult struct{…}

The aggregated audio speeches usage details of the specific time bucket.

Characters int64

The number of characters processed.

NumModelRequests int64

The count of requests made to the model.

Object OrganizationUsageAudioSpeechesResult
APIKeyID stringOptional

When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

Model stringOptional

When group_by=model, this field provides the model name of the grouped usage result.

ProjectID stringOptional

When group_by=project_id, this field provides the project ID of the grouped usage result.

UserID stringOptional

When group_by=user_id, this field provides the user ID of the grouped usage result.

type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct{…}

The aggregated audio transcriptions usage details of the specific time bucket.

NumModelRequests int64

The count of requests made to the model.

Object OrganizationUsageAudioTranscriptionsResult
Seconds int64

The number of seconds processed.

formatint64
APIKeyID stringOptional

When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

Model stringOptional

When group_by=model, this field provides the model name of the grouped usage result.

ProjectID stringOptional

When group_by=project_id, this field provides the project ID of the grouped usage result.

UserID stringOptional

When group_by=user_id, this field provides the user ID of the grouped usage result.

type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageVectorStoresResult struct{…}

The aggregated vector stores usage details of the specific time bucket.

Object OrganizationUsageVectorStoresResult
UsageBytes int64

The vector stores usage in bytes.

ProjectID stringOptional

When group_by=project_id, this field provides the project ID of the grouped usage result.

type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct{…}

The aggregated code interpreter sessions usage details of the specific time bucket.

NumSessions int64

The number of code interpreter sessions.

Object OrganizationUsageCodeInterpreterSessionsResult
ProjectID stringOptional

When group_by=project_id, this field provides the project ID of the grouped usage result.

type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResult struct{…}

The aggregated costs details of the specific time bucket.

Object OrganizationCostsResult
Amount AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResultAmountOptional

The monetary value in its associated currency.

Currency stringOptional

Lowercase ISO-4217 currency e.g. “usd”

Value float64Optional

The numeric value of the cost.

APIKeyID stringOptional

When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

LineItem stringOptional

When group_by=line_item, this field provides the line item of the grouped costs result.

ProjectID stringOptional

When group_by=project_id, this field provides the project ID of the grouped costs result.

Quantity float64Optional

When group_by=line_item, this field provides the quantity of the grouped costs result.

StartTime int64
HasMore bool
NextPage string
Object Page

Code interpreter sessions

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  response, err := client.Admin.Organization.Usage.CodeInterpreterSessions(context.TODO(), openai.AdminOrganizationUsageCodeInterpreterSessionsParams{
    StartTime: 0,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", 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
}