diff --git a/en/python/resources/admin/index.md b/en/python/resources/admin/index.md index 5c95c06..31b247a 100644 --- a/en/python/resources/admin/index.md +++ b/en/python/resources/admin/index.md @@ -3042,6 +3042,70 @@ Get audio speeches usage details for the organization. When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -3475,6 +3539,70 @@ Get audio transcriptions usage details for the organization. When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -3890,6 +4018,70 @@ Get code interpreter sessions usage details for the organization. When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -4331,6 +4523,70 @@ Get completions usage details for the organization. When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -4764,6 +5020,70 @@ Get embeddings usage details for the organization. When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -5225,35 +5545,99 @@ Get images usage details for the organization. When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `class DataResultOrganizationCostsResult: …` + - `class DataResultOrganizationUsageFileSearchesResult: …` - The aggregated costs details of the specific time bucket. + The aggregated file search calls usage details of the specific time bucket. - - `object: Literal["organization.costs.result"]` + - `num_requests: int` - - `"organization.costs.result"` + The count of file search calls. - - `amount: Optional[DataResultOrganizationCostsResultAmount]` + - `object: Literal["organization.usage.file_searches.result"]` - The monetary value in its associated currency. + - `"organization.usage.file_searches.result"` - - `currency: Optional[str]` + - `api_key_id: Optional[str]` - Lowercase ISO-4217 currency e.g. "usd" + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `value: Optional[float]` + - `project_id: Optional[str]` - The numeric value of the cost. + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `api_key_id: Optional[str]` + - `user_id: Optional[str]` - When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `line_item: Optional[str]` + - `vector_store_id: Optional[str]` - When `group_by=line_item`, this field provides the line item of the grouped costs result. + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. - - `project_id: Optional[str]` + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `class DataResultOrganizationCostsResult: …` + + The aggregated costs details of the specific time bucket. + + - `object: Literal["organization.costs.result"]` + + - `"organization.costs.result"` + + - `amount: Optional[DataResultOrganizationCostsResultAmount]` + + The monetary value in its associated currency. + + - `currency: Optional[str]` + + Lowercase ISO-4217 currency e.g. "usd" + + - `value: Optional[float]` + + The numeric value of the cost. + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. + + - `line_item: Optional[str]` + + When `group_by=line_item`, this field provides the line item of the grouped costs result. + + - `project_id: Optional[str]` When `group_by=project_id`, this field provides the project ID of the grouped costs result. @@ -5658,6 +6042,70 @@ Get moderations usage details for the organization. When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -6073,6 +6521,70 @@ Get vector stores usage details for the organization. When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -6168,13 +6680,13 @@ print(response.data) } ``` -## Costs +## File search calls -`admin.organization.usage.costs(UsageCostsParams**kwargs) -> UsageCostsResponse` +`admin.organization.usage.file_search_calls(UsageFileSearchCallsParams**kwargs) -> UsageFileSearchCallsResponse` -**get** `/organization/costs` +**get** `/organization/usage/file_search_calls` -Get costs details for the organization. +Get file search calls usage details for the organization. ### Parameters @@ -6184,11 +6696,15 @@ Get costs details for the organization. - `api_key_ids: Optional[Sequence[str]]` - Return only costs for these API keys. + Return only usage for these API keys. -- `bucket_width: Optional[Literal["1d"]]` +- `bucket_width: Optional[Literal["1m", "1h", "1d"]]` - Width of each time bucket in response. Currently only `1d` is supported, default to `1d`. + Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`. + + - `"1m"` + + - `"1h"` - `"1d"` @@ -6196,19 +6712,25 @@ Get costs details for the organization. End time (Unix seconds) of the query time range, exclusive. -- `group_by: Optional[List[Literal["project_id", "line_item", "api_key_id"]]]` +- `group_by: Optional[List[Literal["project_id", "user_id", "api_key_id", "vector_store_id"]]]` - Group the costs by the specified fields. Support fields include `project_id`, `line_item`, `api_key_id` and any combination of them. + Group the usage data by the specified fields. Support fields include `project_id`, `user_id`, `api_key_id`, `vector_store_id` or any combination of them. - `"project_id"` - - `"line_item"` + - `"user_id"` - `"api_key_id"` + - `"vector_store_id"` + - `limit: Optional[int]` - A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7. + 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]` @@ -6216,11 +6738,19 @@ Get costs details for the organization. - `project_ids: Optional[Sequence[str]]` - Return only costs for these projects. + Return only usage for these projects. + +- `user_ids: Optional[Sequence[str]]` + + Return only usage for these users. + +- `vector_store_ids: Optional[Sequence[str]]` + + Return only usage for these vector stores. ### Returns -- `class UsageCostsResponse: …` +- `class UsageFileSearchCallsResponse: …` - `data: List[Data]` @@ -6488,6 +7018,70 @@ Get costs details for the organization. When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -6543,7 +7137,7 @@ 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.costs( +response = client.admin.organization.usage.file_search_calls( start_time=0, ) print(response.data) @@ -6583,33 +7177,111 @@ print(response.data) } ``` -## Domain Types +## Web search calls -### Usage Audio Speeches Response +`admin.organization.usage.web_search_calls(UsageWebSearchCallsParams**kwargs) -> UsageWebSearchCallsResponse` -- `class UsageAudioSpeechesResponse: …` +**get** `/organization/usage/web_search_calls` - - `data: List[Data]` +Get web search calls usage details for the organization. - - `end_time: int` +### Parameters - - `object: Literal["bucket"]` +- `start_time: int` - - `"bucket"` + Start time (Unix seconds) of the query time range, inclusive. - - `results: List[DataResult]` +- `api_key_ids: Optional[Sequence[str]]` - - `class DataResultOrganizationUsageCompletionsResult: …` + Return only usage for these API keys. - The aggregated completions usage details of the specific time bucket. +- `bucket_width: Optional[Literal["1m", "1h", "1d"]]` - - `input_tokens: int` + Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`. - The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens. + - `"1m"` - - `num_model_requests: int` + - `"1h"` - The count of requests made to the model. + - `"1d"` + +- `context_levels: Optional[List[Literal["low", "medium", "high"]]]` + + Return only web search usage for these context levels. + + - `"low"` + + - `"medium"` + + - `"high"` + +- `end_time: Optional[int]` + + End time (Unix seconds) of the query time range, exclusive. + +- `group_by: Optional[List[Literal["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. + + - `"project_id"` + + - `"user_id"` + + - `"api_key_id"` + + - `"model"` + + - `"context_level"` + +- `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 + +- `models: Optional[Sequence[str]]` + + Return only usage for these models. + +- `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. + +- `user_ids: Optional[Sequence[str]]` + + Return only usage for these users. + +### Returns + +- `class UsageWebSearchCallsResponse: …` + + - `data: List[Data]` + + - `end_time: int` + + - `object: Literal["bucket"]` + + - `"bucket"` + + - `results: List[DataResult]` + + - `class DataResultOrganizationUsageCompletionsResult: …` + + The aggregated completions usage details of the specific time bucket. + + - `input_tokens: int` + + The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens. + + - `num_model_requests: int` + + The count of requests made to the model. - `object: Literal["organization.usage.completions.result"]` @@ -6855,6 +7527,70 @@ print(response.data) When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -6901,9 +7637,108 @@ print(response.data) - `"page"` -### Usage Audio Transcriptions Response +### Example -- `class UsageAudioTranscriptionsResponse: …` +```python +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.web_search_calls( + start_time=0, +) +print(response.data) +``` + +#### Response + +```json +{ + "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", + "batch": true, + "input_audio_tokens": 0, + "input_cached_tokens": 0, + "model": "model", + "output_audio_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" +} +``` + +## Costs + +`admin.organization.usage.costs(UsageCostsParams**kwargs) -> UsageCostsResponse` + +**get** `/organization/costs` + +Get costs details for the organization. + +### Parameters + +- `start_time: int` + + Start time (Unix seconds) of the query time range, inclusive. + +- `api_key_ids: Optional[Sequence[str]]` + + Return only costs for these API keys. + +- `bucket_width: Optional[Literal["1d"]]` + + Width of each time bucket in response. Currently only `1d` is supported, default to `1d`. + + - `"1d"` + +- `end_time: Optional[int]` + + End time (Unix seconds) of the query time range, exclusive. + +- `group_by: Optional[List[Literal["project_id", "line_item", "api_key_id"]]]` + + Group the costs by the specified fields. Support fields include `project_id`, `line_item`, `api_key_id` and any combination of them. + + - `"project_id"` + + - `"line_item"` + + - `"api_key_id"` + +- `limit: Optional[int]` + + A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7. + +- `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 costs for these projects. + +### Returns + +- `class UsageCostsResponse: …` - `data: List[Data]` @@ -7171,61 +8006,176 @@ print(response.data) When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `class DataResultOrganizationCostsResult: …` + - `class DataResultOrganizationUsageFileSearchesResult: …` - The aggregated costs details of the specific time bucket. + The aggregated file search calls usage details of the specific time bucket. - - `object: Literal["organization.costs.result"]` + - `num_requests: int` - - `"organization.costs.result"` + The count of file search calls. - - `amount: Optional[DataResultOrganizationCostsResultAmount]` + - `object: Literal["organization.usage.file_searches.result"]` - The monetary value in its associated currency. + - `"organization.usage.file_searches.result"` - - `currency: Optional[str]` + - `api_key_id: Optional[str]` - Lowercase ISO-4217 currency e.g. "usd" + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `value: Optional[float]` + - `project_id: Optional[str]` - The numeric value of the cost. + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `api_key_id: Optional[str]` + - `user_id: Optional[str]` - When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `line_item: Optional[str]` + - `vector_store_id: Optional[str]` - When `group_by=line_item`, this field provides the line item of the grouped costs result. + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. - - `project_id: Optional[str]` + - `class DataResultOrganizationUsageWebSearchesResult: …` - When `group_by=project_id`, this field provides the project ID of the grouped costs result. + The aggregated web search calls usage details of the specific time bucket. - - `quantity: Optional[float]` + - `num_model_requests: int` - When `group_by=line_item`, this field provides the quantity of the grouped costs result. + The count of model requests. - - `start_time: int` + - `num_requests: int` - - `has_more: bool` + The count of web search calls. - - `next_page: Optional[str]` + - `object: Literal["organization.usage.web_searches.result"]` - - `object: Literal["page"]` + - `"organization.usage.web_searches.result"` - - `"page"` + - `api_key_id: Optional[str]` -### Usage Code Interpreter Sessions Response + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. -- `class UsageCodeInterpreterSessionsResponse: …` + - `context_level: Optional[str]` - - `data: List[Data]` + When `group_by=context_level`, this field provides the search context size of the grouped usage result. - - `end_time: int` + - `model: Optional[str]` - - `object: Literal["bucket"]` + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `class DataResultOrganizationCostsResult: …` + + The aggregated costs details of the specific time bucket. + + - `object: Literal["organization.costs.result"]` + + - `"organization.costs.result"` + + - `amount: Optional[DataResultOrganizationCostsResultAmount]` + + The monetary value in its associated currency. + + - `currency: Optional[str]` + + Lowercase ISO-4217 currency e.g. "usd" + + - `value: Optional[float]` + + The numeric value of the cost. + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. + + - `line_item: Optional[str]` + + When `group_by=line_item`, this field provides the line item of the grouped costs result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped costs result. + + - `quantity: Optional[float]` + + When `group_by=line_item`, this field provides the quantity of the grouped costs result. + + - `start_time: int` + + - `has_more: bool` + + - `next_page: Optional[str]` + + - `object: Literal["page"]` + + - `"page"` + +### Example + +```python +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.costs( + start_time=0, +) +print(response.data) +``` + +#### Response + +```json +{ + "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", + "batch": true, + "input_audio_tokens": 0, + "input_cached_tokens": 0, + "model": "model", + "output_audio_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" +} +``` + +## Domain Types + +### Usage Audio Speeches Response + +- `class UsageAudioSpeechesResponse: …` + + - `data: List[Data]` + + - `end_time: int` + + - `object: Literal["bucket"]` - `"bucket"` @@ -7487,6 +8437,70 @@ print(response.data) When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -7533,9 +8547,9 @@ print(response.data) - `"page"` -### Usage Completions Response +### Usage Audio Transcriptions Response -- `class UsageCompletionsResponse: …` +- `class UsageAudioTranscriptionsResponse: …` - `data: List[Data]` @@ -7803,6 +8817,70 @@ print(response.data) When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -7849,9 +8927,9 @@ print(response.data) - `"page"` -### Usage Embeddings Response +### Usage Code Interpreter Sessions Response -- `class UsageEmbeddingsResponse: …` +- `class UsageCodeInterpreterSessionsResponse: …` - `data: List[Data]` @@ -8119,61 +9197,125 @@ print(response.data) When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `class DataResultOrganizationCostsResult: …` + - `class DataResultOrganizationUsageFileSearchesResult: …` - The aggregated costs details of the specific time bucket. + The aggregated file search calls usage details of the specific time bucket. - - `object: Literal["organization.costs.result"]` + - `num_requests: int` - - `"organization.costs.result"` + The count of file search calls. - - `amount: Optional[DataResultOrganizationCostsResultAmount]` + - `object: Literal["organization.usage.file_searches.result"]` - The monetary value in its associated currency. + - `"organization.usage.file_searches.result"` - - `currency: Optional[str]` + - `api_key_id: Optional[str]` - Lowercase ISO-4217 currency e.g. "usd" + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `value: Optional[float]` + - `project_id: Optional[str]` - The numeric value of the cost. + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `api_key_id: Optional[str]` + - `user_id: Optional[str]` - When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `line_item: Optional[str]` + - `vector_store_id: Optional[str]` - When `group_by=line_item`, this field provides the line item of the grouped costs result. + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. - - `project_id: Optional[str]` + - `class DataResultOrganizationUsageWebSearchesResult: …` - When `group_by=project_id`, this field provides the project ID of the grouped costs result. + The aggregated web search calls usage details of the specific time bucket. - - `quantity: Optional[float]` + - `num_model_requests: int` - When `group_by=line_item`, this field provides the quantity of the grouped costs result. + The count of model requests. - - `start_time: int` + - `num_requests: int` - - `has_more: bool` + The count of web search calls. - - `next_page: Optional[str]` + - `object: Literal["organization.usage.web_searches.result"]` - - `object: Literal["page"]` + - `"organization.usage.web_searches.result"` - - `"page"` + - `api_key_id: Optional[str]` -### Usage Images Response + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. -- `class UsageImagesResponse: …` + - `context_level: Optional[str]` - - `data: List[Data]` + When `group_by=context_level`, this field provides the search context size of the grouped usage result. - - `end_time: int` + - `model: Optional[str]` - - `object: Literal["bucket"]` + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `class DataResultOrganizationCostsResult: …` + + The aggregated costs details of the specific time bucket. + + - `object: Literal["organization.costs.result"]` + + - `"organization.costs.result"` + + - `amount: Optional[DataResultOrganizationCostsResultAmount]` + + The monetary value in its associated currency. + + - `currency: Optional[str]` + + Lowercase ISO-4217 currency e.g. "usd" + + - `value: Optional[float]` + + The numeric value of the cost. + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. + + - `line_item: Optional[str]` + + When `group_by=line_item`, this field provides the line item of the grouped costs result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped costs result. + + - `quantity: Optional[float]` + + When `group_by=line_item`, this field provides the quantity of the grouped costs result. + + - `start_time: int` + + - `has_more: bool` + + - `next_page: Optional[str]` + + - `object: Literal["page"]` + + - `"page"` + +### Usage Completions Response + +- `class UsageCompletionsResponse: …` + + - `data: List[Data]` + + - `end_time: int` + + - `object: Literal["bucket"]` - `"bucket"` @@ -8435,6 +9577,70 @@ print(response.data) When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -8481,9 +9687,9 @@ print(response.data) - `"page"` -### Usage Moderations Response +### Usage Embeddings Response -- `class UsageModerationsResponse: …` +- `class UsageEmbeddingsResponse: …` - `data: List[Data]` @@ -8751,6 +9957,70 @@ print(response.data) When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -8797,9 +10067,9 @@ print(response.data) - `"page"` -### Usage Vector Stores Response +### Usage Images Response -- `class UsageVectorStoresResponse: …` +- `class UsageImagesResponse: …` - `data: List[Data]` @@ -9067,6 +10337,70 @@ print(response.data) When `group_by=project_id`, this field provides the project ID of the grouped usage result. + - `class DataResultOrganizationUsageFileSearchesResult: …` + + The aggregated file search calls usage details of the specific time bucket. + + - `num_requests: int` + + The count of file search calls. + + - `object: Literal["organization.usage.file_searches.result"]` + + - `"organization.usage.file_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + + - `vector_store_id: Optional[str]` + + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. + + - `class DataResultOrganizationUsageWebSearchesResult: …` + + The aggregated web search calls usage details of the specific time bucket. + + - `num_model_requests: int` + + The count of model requests. + + - `num_requests: int` + + The count of web search calls. + + - `object: Literal["organization.usage.web_searches.result"]` + + - `"organization.usage.web_searches.result"` + + - `api_key_id: Optional[str]` + + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. + + - `context_level: Optional[str]` + + When `group_by=context_level`, this field provides the search context size of the grouped usage result. + + - `model: Optional[str]` + + When `group_by=model`, this field provides the model name of the grouped usage result. + + - `project_id: Optional[str]` + + When `group_by=project_id`, this field provides the project ID of the grouped usage result. + + - `user_id: Optional[str]` + + When `group_by=user_id`, this field provides the user ID of the grouped usage result. + - `class DataResultOrganizationCostsResult: …` The aggregated costs details of the specific time bucket. @@ -9113,9 +10447,9 @@ print(response.data) - `"page"` -### Usage Costs Response +### Usage Moderations Response -- `class UsageCostsResponse: …` +- `class UsageModerationsResponse: …` - `data: List[Data]` @@ -9383,2154 +10717,1721 @@ print(response.data) When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `class DataResultOrganizationCostsResult: …` + - `class DataResultOrganizationUsageFileSearchesResult: …` - The aggregated costs details of the specific time bucket. + The aggregated file search calls usage details of the specific time bucket. - - `object: Literal["organization.costs.result"]` + - `num_requests: int` - - `"organization.costs.result"` + The count of file search calls. - - `amount: Optional[DataResultOrganizationCostsResultAmount]` + - `object: Literal["organization.usage.file_searches.result"]` - The monetary value in its associated currency. + - `"organization.usage.file_searches.result"` - - `currency: Optional[str]` + - `api_key_id: Optional[str]` - Lowercase ISO-4217 currency e.g. "usd" + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `value: Optional[float]` + - `project_id: Optional[str]` - The numeric value of the cost. + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `api_key_id: Optional[str]` + - `user_id: Optional[str]` - When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `line_item: Optional[str]` + - `vector_store_id: Optional[str]` - When `group_by=line_item`, this field provides the line item of the grouped costs result. + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. - - `project_id: Optional[str]` + - `class DataResultOrganizationUsageWebSearchesResult: …` - When `group_by=project_id`, this field provides the project ID of the grouped costs result. + The aggregated web search calls usage details of the specific time bucket. - - `quantity: Optional[float]` + - `num_model_requests: int` - When `group_by=line_item`, this field provides the quantity of the grouped costs result. + The count of model requests. - - `start_time: int` + - `num_requests: int` - - `has_more: bool` + The count of web search calls. - - `next_page: Optional[str]` + - `object: Literal["organization.usage.web_searches.result"]` - - `object: Literal["page"]` + - `"organization.usage.web_searches.result"` - - `"page"` + - `api_key_id: Optional[str]` -# Invites + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. -## List invites + - `context_level: Optional[str]` -`admin.organization.invites.list(InviteListParams**kwargs) -> SyncConversationCursorPage[Invite]` + When `group_by=context_level`, this field provides the search context size of the grouped usage result. -**get** `/organization/invites` + - `model: Optional[str]` -Returns a list of invites in the organization. + When `group_by=model`, this field provides the model name of the grouped usage result. -### Parameters + - `project_id: Optional[str]` -- `after: Optional[str]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + - `user_id: Optional[str]` -- `limit: Optional[int]` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + - `class DataResultOrganizationCostsResult: …` -### Returns + The aggregated costs details of the specific time bucket. -- `class Invite: …` + - `object: Literal["organization.costs.result"]` - Represents an individual `invite` to the organization. + - `"organization.costs.result"` - - `id: str` + - `amount: Optional[DataResultOrganizationCostsResultAmount]` - The identifier, which can be referenced in API endpoints + The monetary value in its associated currency. - - `created_at: int` + - `currency: Optional[str]` - The Unix timestamp (in seconds) of when the invite was sent. + Lowercase ISO-4217 currency e.g. "usd" - - `email: str` + - `value: Optional[float]` - The email address of the individual to whom the invite was sent + The numeric value of the cost. - - `object: Literal["organization.invite"]` + - `api_key_id: Optional[str]` - The object type, which is always `organization.invite` + When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. - - `"organization.invite"` + - `line_item: Optional[str]` - - `projects: List[Project]` + When `group_by=line_item`, this field provides the line item of the grouped costs result. - The projects that were granted membership upon acceptance of the invite. + - `project_id: Optional[str]` - - `id: str` + When `group_by=project_id`, this field provides the project ID of the grouped costs result. - Project's public ID + - `quantity: Optional[float]` - - `role: Literal["member", "owner"]` + When `group_by=line_item`, this field provides the quantity of the grouped costs result. - Project membership role + - `start_time: int` - - `"member"` + - `has_more: bool` - - `"owner"` + - `next_page: Optional[str]` - - `role: Literal["owner", "reader"]` + - `object: Literal["page"]` - `owner` or `reader` + - `"page"` - - `"owner"` +### Usage Vector Stores Response - - `"reader"` +- `class UsageVectorStoresResponse: …` - - `status: Literal["accepted", "expired", "pending"]` + - `data: List[Data]` - `accepted`,`expired`, or `pending` + - `end_time: int` - - `"accepted"` + - `object: Literal["bucket"]` - - `"expired"` + - `"bucket"` - - `"pending"` + - `results: List[DataResult]` - - `accepted_at: Optional[int]` + - `class DataResultOrganizationUsageCompletionsResult: …` - The Unix timestamp (in seconds) of when the invite was accepted. + The aggregated completions usage details of the specific time bucket. - - `expires_at: Optional[int]` + - `input_tokens: int` - The Unix timestamp (in seconds) of when the invite expires. + The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens. -### Example + - `num_model_requests: int` -```python -import os -from openai import OpenAI + The count of requests made to the model. -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -page = client.admin.organization.invites.list() -page = page.data[0] -print(page.id) -``` + - `object: Literal["organization.usage.completions.result"]` -#### Response + - `"organization.usage.completions.result"` -```json -{ - "data": [ - { - "id": "id", - "created_at": 0, - "email": "email", - "object": "organization.invite", - "projects": [ - { - "id": "id", - "role": "member" - } - ], - "role": "owner", - "status": "accepted", - "accepted_at": 0, - "expires_at": 0 - } - ], - "has_more": true, - "object": "list", - "first_id": "first_id", - "last_id": "last_id" -} -``` + - `output_tokens: int` -## Create invite + The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens. -`admin.organization.invites.create(InviteCreateParams**kwargs) -> Invite` + - `api_key_id: Optional[str]` -**post** `/organization/invites` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. -Create an invite for a user to the organization. The invite must be accepted by the user before they have access to the organization. + - `batch: Optional[bool]` -### Parameters + When `group_by=batch`, this field tells whether the grouped usage result is batch or not. -- `email: str` + - `input_audio_tokens: Optional[int]` - Send an email to this address + The aggregated number of audio input tokens used, including cached tokens. -- `role: Literal["reader", "owner"]` + - `input_cached_tokens: Optional[int]` - `owner` or `reader` + 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. - - `"reader"` + - `model: Optional[str]` - - `"owner"` + When `group_by=model`, this field provides the model name of the grouped usage result. -- `projects: Optional[Iterable[Project]]` + - `output_audio_tokens: Optional[int]` - An array of projects to which membership is granted at the same time the org invite is accepted. If omitted, the user will be invited to the default project for compatibility with legacy behavior. + The aggregated number of audio output tokens used. - - `id: str` + - `project_id: Optional[str]` - Project's public ID + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `role: Literal["member", "owner"]` + - `service_tier: Optional[str]` - Project membership role + When `group_by=service_tier`, this field provides the service tier of the grouped usage result. - - `"member"` + - `user_id: Optional[str]` - - `"owner"` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. -### Returns + - `class DataResultOrganizationUsageEmbeddingsResult: …` -- `class Invite: …` + The aggregated embeddings usage details of the specific time bucket. - Represents an individual `invite` to the organization. + - `input_tokens: int` - - `id: str` + The aggregated number of input tokens used. - The identifier, which can be referenced in API endpoints + - `num_model_requests: int` - - `created_at: int` + The count of requests made to the model. - The Unix timestamp (in seconds) of when the invite was sent. + - `object: Literal["organization.usage.embeddings.result"]` - - `email: str` + - `"organization.usage.embeddings.result"` - The email address of the individual to whom the invite was sent + - `api_key_id: Optional[str]` - - `object: Literal["organization.invite"]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - The object type, which is always `organization.invite` + - `model: Optional[str]` - - `"organization.invite"` + When `group_by=model`, this field provides the model name of the grouped usage result. - - `projects: List[Project]` + - `project_id: Optional[str]` - The projects that were granted membership upon acceptance of the invite. + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `id: str` + - `user_id: Optional[str]` - Project's public ID + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `role: Literal["member", "owner"]` + - `class DataResultOrganizationUsageModerationsResult: …` - Project membership role + The aggregated moderations usage details of the specific time bucket. - - `"member"` + - `input_tokens: int` - - `"owner"` + The aggregated number of input tokens used. - - `role: Literal["owner", "reader"]` + - `num_model_requests: int` - `owner` or `reader` + The count of requests made to the model. - - `"owner"` + - `object: Literal["organization.usage.moderations.result"]` - - `"reader"` + - `"organization.usage.moderations.result"` - - `status: Literal["accepted", "expired", "pending"]` + - `api_key_id: Optional[str]` - `accepted`,`expired`, or `pending` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `"accepted"` + - `model: Optional[str]` - - `"expired"` + When `group_by=model`, this field provides the model name of the grouped usage result. - - `"pending"` + - `project_id: Optional[str]` - - `accepted_at: Optional[int]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - The Unix timestamp (in seconds) of when the invite was accepted. + - `user_id: Optional[str]` - - `expires_at: Optional[int]` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - The Unix timestamp (in seconds) of when the invite expires. + - `class DataResultOrganizationUsageImagesResult: …` -### Example + The aggregated images usage details of the specific time bucket. -```python -import os -from openai import OpenAI + - `images: int` -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -invite = client.admin.organization.invites.create( - email="email", - role="reader", -) -print(invite.id) -``` + The number of images processed. -#### Response + - `num_model_requests: int` -```json -{ - "id": "id", - "created_at": 0, - "email": "email", - "object": "organization.invite", - "projects": [ - { - "id": "id", - "role": "member" - } - ], - "role": "owner", - "status": "accepted", - "accepted_at": 0, - "expires_at": 0 -} -``` + The count of requests made to the model. -## Retrieve invite + - `object: Literal["organization.usage.images.result"]` -`admin.organization.invites.retrieve(strinvite_id) -> Invite` + - `"organization.usage.images.result"` -**get** `/organization/invites/{invite_id}` + - `api_key_id: Optional[str]` -Retrieves an invite. + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. -### Parameters + - `model: Optional[str]` -- `invite_id: str` + When `group_by=model`, this field provides the model name of the grouped usage result. -### Returns + - `project_id: Optional[str]` -- `class Invite: …` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - Represents an individual `invite` to the organization. + - `size: Optional[str]` - - `id: str` + When `group_by=size`, this field provides the image size of the grouped usage result. - The identifier, which can be referenced in API endpoints + - `source: Optional[str]` - - `created_at: int` + When `group_by=source`, this field provides the source of the grouped usage result, possible values are `image.generation`, `image.edit`, `image.variation`. - The Unix timestamp (in seconds) of when the invite was sent. + - `user_id: Optional[str]` - - `email: str` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - The email address of the individual to whom the invite was sent + - `class DataResultOrganizationUsageAudioSpeechesResult: …` - - `object: Literal["organization.invite"]` + The aggregated audio speeches usage details of the specific time bucket. - The object type, which is always `organization.invite` + - `characters: int` - - `"organization.invite"` + The number of characters processed. - - `projects: List[Project]` + - `num_model_requests: int` - The projects that were granted membership upon acceptance of the invite. + The count of requests made to the model. - - `id: str` + - `object: Literal["organization.usage.audio_speeches.result"]` - Project's public ID + - `"organization.usage.audio_speeches.result"` - - `role: Literal["member", "owner"]` + - `api_key_id: Optional[str]` - Project membership role + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `"member"` + - `model: Optional[str]` - - `"owner"` + When `group_by=model`, this field provides the model name of the grouped usage result. - - `role: Literal["owner", "reader"]` + - `project_id: Optional[str]` - `owner` or `reader` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `"owner"` + - `user_id: Optional[str]` - - `"reader"` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `status: Literal["accepted", "expired", "pending"]` + - `class DataResultOrganizationUsageAudioTranscriptionsResult: …` - `accepted`,`expired`, or `pending` + The aggregated audio transcriptions usage details of the specific time bucket. - - `"accepted"` + - `num_model_requests: int` - - `"expired"` + The count of requests made to the model. - - `"pending"` + - `object: Literal["organization.usage.audio_transcriptions.result"]` - - `accepted_at: Optional[int]` + - `"organization.usage.audio_transcriptions.result"` - The Unix timestamp (in seconds) of when the invite was accepted. + - `seconds: int` - - `expires_at: Optional[int]` + The number of seconds processed. - The Unix timestamp (in seconds) of when the invite expires. + - `api_key_id: Optional[str]` -### Example + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. -```python -import os -from openai import OpenAI + - `model: Optional[str]` -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -invite = client.admin.organization.invites.retrieve( - "invite_id", -) -print(invite.id) -``` + When `group_by=model`, this field provides the model name of the grouped usage result. -#### Response + - `project_id: Optional[str]` -```json -{ - "id": "id", - "created_at": 0, - "email": "email", - "object": "organization.invite", - "projects": [ - { - "id": "id", - "role": "member" - } - ], - "role": "owner", - "status": "accepted", - "accepted_at": 0, - "expires_at": 0 -} -``` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. -## Delete invite + - `user_id: Optional[str]` -`admin.organization.invites.delete(strinvite_id) -> InviteDeleteResponse` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. -**delete** `/organization/invites/{invite_id}` + - `class DataResultOrganizationUsageVectorStoresResult: …` -Delete an invite. If the invite has already been accepted, it cannot be deleted. + The aggregated vector stores usage details of the specific time bucket. -### Parameters + - `object: Literal["organization.usage.vector_stores.result"]` -- `invite_id: str` + - `"organization.usage.vector_stores.result"` -### Returns + - `usage_bytes: int` -- `class InviteDeleteResponse: …` + The vector stores usage in bytes. - - `id: str` + - `project_id: Optional[str]` - - `deleted: bool` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `object: Literal["organization.invite.deleted"]` + - `class DataResultOrganizationUsageCodeInterpreterSessionsResult: …` - The object type, which is always `organization.invite.deleted` + The aggregated code interpreter sessions usage details of the specific time bucket. - - `"organization.invite.deleted"` + - `num_sessions: int` -### Example + The number of code interpreter sessions. -```python -import os -from openai import OpenAI + - `object: Literal["organization.usage.code_interpreter_sessions.result"]` -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -invite = client.admin.organization.invites.delete( - "invite_id", -) -print(invite.id) -``` + - `"organization.usage.code_interpreter_sessions.result"` -#### Response + - `project_id: Optional[str]` -```json -{ - "id": "id", - "deleted": true, - "object": "organization.invite.deleted" -} -``` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. -## Domain Types + - `class DataResultOrganizationUsageFileSearchesResult: …` -### Invite + The aggregated file search calls usage details of the specific time bucket. -- `class Invite: …` + - `num_requests: int` - Represents an individual `invite` to the organization. + The count of file search calls. - - `id: str` + - `object: Literal["organization.usage.file_searches.result"]` - The identifier, which can be referenced in API endpoints + - `"organization.usage.file_searches.result"` - - `created_at: int` + - `api_key_id: Optional[str]` - The Unix timestamp (in seconds) of when the invite was sent. + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `email: str` + - `project_id: Optional[str]` - The email address of the individual to whom the invite was sent + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `object: Literal["organization.invite"]` + - `user_id: Optional[str]` - The object type, which is always `organization.invite` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `"organization.invite"` + - `vector_store_id: Optional[str]` - - `projects: List[Project]` + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. - The projects that were granted membership upon acceptance of the invite. + - `class DataResultOrganizationUsageWebSearchesResult: …` - - `id: str` + The aggregated web search calls usage details of the specific time bucket. - Project's public ID + - `num_model_requests: int` - - `role: Literal["member", "owner"]` + The count of model requests. - Project membership role + - `num_requests: int` - - `"member"` + The count of web search calls. - - `"owner"` + - `object: Literal["organization.usage.web_searches.result"]` - - `role: Literal["owner", "reader"]` + - `"organization.usage.web_searches.result"` - `owner` or `reader` + - `api_key_id: Optional[str]` - - `"owner"` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `"reader"` + - `context_level: Optional[str]` - - `status: Literal["accepted", "expired", "pending"]` + When `group_by=context_level`, this field provides the search context size of the grouped usage result. - `accepted`,`expired`, or `pending` + - `model: Optional[str]` - - `"accepted"` + When `group_by=model`, this field provides the model name of the grouped usage result. - - `"expired"` + - `project_id: Optional[str]` - - `"pending"` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `accepted_at: Optional[int]` + - `user_id: Optional[str]` - The Unix timestamp (in seconds) of when the invite was accepted. + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `expires_at: Optional[int]` + - `class DataResultOrganizationCostsResult: …` - The Unix timestamp (in seconds) of when the invite expires. + The aggregated costs details of the specific time bucket. -### Invite Delete Response + - `object: Literal["organization.costs.result"]` -- `class InviteDeleteResponse: …` + - `"organization.costs.result"` - - `id: str` + - `amount: Optional[DataResultOrganizationCostsResultAmount]` - - `deleted: bool` + The monetary value in its associated currency. - - `object: Literal["organization.invite.deleted"]` + - `currency: Optional[str]` - The object type, which is always `organization.invite.deleted` + Lowercase ISO-4217 currency e.g. "usd" - - `"organization.invite.deleted"` + - `value: Optional[float]` -# Users + The numeric value of the cost. -## List users + - `api_key_id: Optional[str]` -`admin.organization.users.list(UserListParams**kwargs) -> SyncConversationCursorPage[OrganizationUser]` + When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. -**get** `/organization/users` + - `line_item: Optional[str]` -Lists all of the users in the organization. + When `group_by=line_item`, this field provides the line item of the grouped costs result. -### Parameters + - `project_id: Optional[str]` -- `after: Optional[str]` + When `group_by=project_id`, this field provides the project ID of the grouped costs result. - A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + - `quantity: Optional[float]` -- `emails: Optional[Sequence[str]]` + When `group_by=line_item`, this field provides the quantity of the grouped costs result. - Filter by the email address of users. + - `start_time: int` -- `limit: Optional[int]` + - `has_more: bool` - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + - `next_page: Optional[str]` -### Returns + - `object: Literal["page"]` -- `class OrganizationUser: …` + - `"page"` - Represents an individual `user` within an organization. +### Usage File Search Calls Response - - `id: str` +- `class UsageFileSearchCallsResponse: …` - The identifier, which can be referenced in API endpoints + - `data: List[Data]` - - `added_at: int` + - `end_time: int` - The Unix timestamp (in seconds) of when the user was added. + - `object: Literal["bucket"]` - - `object: Literal["organization.user"]` + - `"bucket"` - The object type, which is always `organization.user` + - `results: List[DataResult]` - - `"organization.user"` + - `class DataResultOrganizationUsageCompletionsResult: …` - - `api_key_last_used_at: Optional[int]` + The aggregated completions usage details of the specific time bucket. - The Unix timestamp (in seconds) of the user's last API key usage. + - `input_tokens: int` - - `created: Optional[int]` + The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens. - The Unix timestamp (in seconds) of when the user was created. + - `num_model_requests: int` - - `developer_persona: Optional[str]` + The count of requests made to the model. - The developer persona metadata for the user. + - `object: Literal["organization.usage.completions.result"]` - - `email: Optional[str]` + - `"organization.usage.completions.result"` - The email address of the user + - `output_tokens: int` - - `is_default: Optional[bool]` + The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens. - Whether this is the organization's default user. + - `api_key_id: Optional[str]` - - `is_scale_tier_authorized_purchaser: Optional[bool]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - Whether the user is an authorized purchaser for Scale Tier. + - `batch: Optional[bool]` - - `is_scim_managed: Optional[bool]` + When `group_by=batch`, this field tells whether the grouped usage result is batch or not. - Whether the user is managed through SCIM. + - `input_audio_tokens: Optional[int]` - - `is_service_account: Optional[bool]` + The aggregated number of audio input tokens used, including cached tokens. - Whether the user is a service account. + - `input_cached_tokens: Optional[int]` - - `name: Optional[str]` + 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. - The name of the user + - `model: Optional[str]` - - `projects: Optional[Projects]` + When `group_by=model`, this field provides the model name of the grouped usage result. - Projects associated with the user, if included. + - `output_audio_tokens: Optional[int]` - - `data: List[ProjectsData]` + The aggregated number of audio output tokens used. - - `id: Optional[str]` + - `project_id: Optional[str]` - - `name: Optional[str]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `role: Optional[str]` + - `service_tier: Optional[str]` - - `object: Literal["list"]` + When `group_by=service_tier`, this field provides the service tier of the grouped usage result. - - `"list"` + - `user_id: Optional[str]` - - `role: Optional[str]` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - `owner` or `reader` + - `class DataResultOrganizationUsageEmbeddingsResult: …` - - `technical_level: Optional[str]` + The aggregated embeddings usage details of the specific time bucket. - The technical level metadata for the user. + - `input_tokens: int` - - `user: Optional[User]` + The aggregated number of input tokens used. - Nested user details. + - `num_model_requests: int` - - `id: str` + The count of requests made to the model. - - `object: Literal["user"]` + - `object: Literal["organization.usage.embeddings.result"]` - - `"user"` + - `"organization.usage.embeddings.result"` - - `banned: Optional[bool]` + - `api_key_id: Optional[str]` - - `banned_at: Optional[int]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `email: Optional[str]` + - `model: Optional[str]` - - `enabled: Optional[bool]` + When `group_by=model`, this field provides the model name of the grouped usage result. - - `name: Optional[str]` + - `project_id: Optional[str]` - - `picture: Optional[str]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. -### Example + - `user_id: Optional[str]` -```python -import os -from openai import OpenAI + When `group_by=user_id`, this field provides the user ID of the grouped usage result. -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -page = client.admin.organization.users.list() -page = page.data[0] -print(page.id) -``` + - `class DataResultOrganizationUsageModerationsResult: …` -#### Response + The aggregated moderations usage details of the specific time bucket. -```json -{ - "data": [ - { - "id": "id", - "added_at": 0, - "object": "organization.user", - "api_key_last_used_at": 0, - "created": 0, - "developer_persona": "developer_persona", - "email": "email", - "is_default": true, - "is_scale_tier_authorized_purchaser": true, - "is_scim_managed": true, - "is_service_account": true, - "name": "name", - "projects": { - "data": [ - { - "id": "id", - "name": "name", - "role": "role" - } - ], - "object": "list" - }, - "role": "role", - "technical_level": "technical_level", - "user": { - "id": "id", - "object": "user", - "banned": true, - "banned_at": 0, - "email": "email", - "enabled": true, - "name": "name", - "picture": "picture" - } - } - ], - "has_more": true, - "object": "list", - "first_id": "first_id", - "last_id": "last_id" -} -``` + - `input_tokens: int` -## Retrieve user + The aggregated number of input tokens used. -`admin.organization.users.retrieve(struser_id) -> OrganizationUser` + - `num_model_requests: int` -**get** `/organization/users/{user_id}` + The count of requests made to the model. -Retrieves a user by their identifier. + - `object: Literal["organization.usage.moderations.result"]` -### Parameters + - `"organization.usage.moderations.result"` -- `user_id: str` + - `api_key_id: Optional[str]` -### Returns + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. -- `class OrganizationUser: …` + - `model: Optional[str]` - Represents an individual `user` within an organization. + When `group_by=model`, this field provides the model name of the grouped usage result. - - `id: str` + - `project_id: Optional[str]` - The identifier, which can be referenced in API endpoints + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `added_at: int` + - `user_id: Optional[str]` - The Unix timestamp (in seconds) of when the user was added. + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `object: Literal["organization.user"]` + - `class DataResultOrganizationUsageImagesResult: …` - The object type, which is always `organization.user` + The aggregated images usage details of the specific time bucket. - - `"organization.user"` + - `images: int` - - `api_key_last_used_at: Optional[int]` + The number of images processed. - The Unix timestamp (in seconds) of the user's last API key usage. + - `num_model_requests: int` - - `created: Optional[int]` + The count of requests made to the model. - The Unix timestamp (in seconds) of when the user was created. + - `object: Literal["organization.usage.images.result"]` - - `developer_persona: Optional[str]` + - `"organization.usage.images.result"` - The developer persona metadata for the user. + - `api_key_id: Optional[str]` - - `email: Optional[str]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - The email address of the user + - `model: Optional[str]` - - `is_default: Optional[bool]` + When `group_by=model`, this field provides the model name of the grouped usage result. - Whether this is the organization's default user. + - `project_id: Optional[str]` - - `is_scale_tier_authorized_purchaser: Optional[bool]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - Whether the user is an authorized purchaser for Scale Tier. + - `size: Optional[str]` - - `is_scim_managed: Optional[bool]` + When `group_by=size`, this field provides the image size of the grouped usage result. - Whether the user is managed through SCIM. + - `source: Optional[str]` - - `is_service_account: Optional[bool]` + When `group_by=source`, this field provides the source of the grouped usage result, possible values are `image.generation`, `image.edit`, `image.variation`. - Whether the user is a service account. + - `user_id: Optional[str]` - - `name: Optional[str]` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - The name of the user + - `class DataResultOrganizationUsageAudioSpeechesResult: …` - - `projects: Optional[Projects]` + The aggregated audio speeches usage details of the specific time bucket. - Projects associated with the user, if included. + - `characters: int` - - `data: List[ProjectsData]` + The number of characters processed. - - `id: Optional[str]` + - `num_model_requests: int` - - `name: Optional[str]` + The count of requests made to the model. - - `role: Optional[str]` + - `object: Literal["organization.usage.audio_speeches.result"]` - - `object: Literal["list"]` + - `"organization.usage.audio_speeches.result"` - - `"list"` + - `api_key_id: Optional[str]` - - `role: Optional[str]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - `owner` or `reader` + - `model: Optional[str]` - - `technical_level: Optional[str]` + When `group_by=model`, this field provides the model name of the grouped usage result. - The technical level metadata for the user. + - `project_id: Optional[str]` - - `user: Optional[User]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - Nested user details. + - `user_id: Optional[str]` - - `id: str` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `object: Literal["user"]` + - `class DataResultOrganizationUsageAudioTranscriptionsResult: …` - - `"user"` + The aggregated audio transcriptions usage details of the specific time bucket. - - `banned: Optional[bool]` + - `num_model_requests: int` - - `banned_at: Optional[int]` + The count of requests made to the model. - - `email: Optional[str]` + - `object: Literal["organization.usage.audio_transcriptions.result"]` - - `enabled: Optional[bool]` + - `"organization.usage.audio_transcriptions.result"` - - `name: Optional[str]` + - `seconds: int` - - `picture: Optional[str]` + The number of seconds processed. -### Example + - `api_key_id: Optional[str]` -```python -import os -from openai import OpenAI + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -organization_user = client.admin.organization.users.retrieve( - "user_id", -) -print(organization_user.id) -``` + - `model: Optional[str]` -#### Response + When `group_by=model`, this field provides the model name of the grouped usage result. -```json -{ - "id": "id", - "added_at": 0, - "object": "organization.user", - "api_key_last_used_at": 0, - "created": 0, - "developer_persona": "developer_persona", - "email": "email", - "is_default": true, - "is_scale_tier_authorized_purchaser": true, - "is_scim_managed": true, - "is_service_account": true, - "name": "name", - "projects": { - "data": [ - { - "id": "id", - "name": "name", - "role": "role" - } - ], - "object": "list" - }, - "role": "role", - "technical_level": "technical_level", - "user": { - "id": "id", - "object": "user", - "banned": true, - "banned_at": 0, - "email": "email", - "enabled": true, - "name": "name", - "picture": "picture" - } -} -``` + - `project_id: Optional[str]` -## Modify user + When `group_by=project_id`, this field provides the project ID of the grouped usage result. -`admin.organization.users.update(struser_id, UserUpdateParams**kwargs) -> OrganizationUser` + - `user_id: Optional[str]` -**post** `/organization/users/{user_id}` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. -Modifies a user's role in the organization. + - `class DataResultOrganizationUsageVectorStoresResult: …` -### Parameters + The aggregated vector stores usage details of the specific time bucket. -- `user_id: str` + - `object: Literal["organization.usage.vector_stores.result"]` -- `developer_persona: Optional[str]` + - `"organization.usage.vector_stores.result"` - Developer persona metadata. + - `usage_bytes: int` -- `role: Optional[str]` + The vector stores usage in bytes. - `owner` or `reader` + - `project_id: Optional[str]` -- `role_id: Optional[str]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - Role ID to assign to the user. + - `class DataResultOrganizationUsageCodeInterpreterSessionsResult: …` -- `technical_level: Optional[str]` + The aggregated code interpreter sessions usage details of the specific time bucket. - Technical level metadata. + - `num_sessions: int` -### Returns + The number of code interpreter sessions. -- `class OrganizationUser: …` + - `object: Literal["organization.usage.code_interpreter_sessions.result"]` - Represents an individual `user` within an organization. + - `"organization.usage.code_interpreter_sessions.result"` - - `id: str` + - `project_id: Optional[str]` - The identifier, which can be referenced in API endpoints + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `added_at: int` + - `class DataResultOrganizationUsageFileSearchesResult: …` - The Unix timestamp (in seconds) of when the user was added. + The aggregated file search calls usage details of the specific time bucket. - - `object: Literal["organization.user"]` + - `num_requests: int` - The object type, which is always `organization.user` + The count of file search calls. - - `"organization.user"` + - `object: Literal["organization.usage.file_searches.result"]` - - `api_key_last_used_at: Optional[int]` + - `"organization.usage.file_searches.result"` - The Unix timestamp (in seconds) of the user's last API key usage. + - `api_key_id: Optional[str]` - - `created: Optional[int]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - The Unix timestamp (in seconds) of when the user was created. + - `project_id: Optional[str]` - - `developer_persona: Optional[str]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - The developer persona metadata for the user. + - `user_id: Optional[str]` - - `email: Optional[str]` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - The email address of the user + - `vector_store_id: Optional[str]` - - `is_default: Optional[bool]` + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. - Whether this is the organization's default user. + - `class DataResultOrganizationUsageWebSearchesResult: …` - - `is_scale_tier_authorized_purchaser: Optional[bool]` + The aggregated web search calls usage details of the specific time bucket. - Whether the user is an authorized purchaser for Scale Tier. + - `num_model_requests: int` - - `is_scim_managed: Optional[bool]` + The count of model requests. - Whether the user is managed through SCIM. + - `num_requests: int` - - `is_service_account: Optional[bool]` + The count of web search calls. - Whether the user is a service account. + - `object: Literal["organization.usage.web_searches.result"]` - - `name: Optional[str]` + - `"organization.usage.web_searches.result"` - The name of the user + - `api_key_id: Optional[str]` - - `projects: Optional[Projects]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - Projects associated with the user, if included. + - `context_level: Optional[str]` - - `data: List[ProjectsData]` + When `group_by=context_level`, this field provides the search context size of the grouped usage result. - - `id: Optional[str]` + - `model: Optional[str]` - - `name: Optional[str]` + When `group_by=model`, this field provides the model name of the grouped usage result. - - `role: Optional[str]` + - `project_id: Optional[str]` - - `object: Literal["list"]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `"list"` + - `user_id: Optional[str]` - - `role: Optional[str]` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - `owner` or `reader` + - `class DataResultOrganizationCostsResult: …` - - `technical_level: Optional[str]` + The aggregated costs details of the specific time bucket. - The technical level metadata for the user. + - `object: Literal["organization.costs.result"]` - - `user: Optional[User]` + - `"organization.costs.result"` - Nested user details. + - `amount: Optional[DataResultOrganizationCostsResultAmount]` - - `id: str` + The monetary value in its associated currency. - - `object: Literal["user"]` + - `currency: Optional[str]` - - `"user"` + Lowercase ISO-4217 currency e.g. "usd" - - `banned: Optional[bool]` + - `value: Optional[float]` - - `banned_at: Optional[int]` + The numeric value of the cost. - - `email: Optional[str]` + - `api_key_id: Optional[str]` - - `enabled: Optional[bool]` + When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. - - `name: Optional[str]` + - `line_item: Optional[str]` - - `picture: Optional[str]` + When `group_by=line_item`, this field provides the line item of the grouped costs result. -### Example + - `project_id: Optional[str]` -```python -import os -from openai import OpenAI + When `group_by=project_id`, this field provides the project ID of the grouped costs result. -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -organization_user = client.admin.organization.users.update( - user_id="user_id", -) -print(organization_user.id) -``` + - `quantity: Optional[float]` -#### Response + When `group_by=line_item`, this field provides the quantity of the grouped costs result. -```json -{ - "id": "id", - "added_at": 0, - "object": "organization.user", - "api_key_last_used_at": 0, - "created": 0, - "developer_persona": "developer_persona", - "email": "email", - "is_default": true, - "is_scale_tier_authorized_purchaser": true, - "is_scim_managed": true, - "is_service_account": true, - "name": "name", - "projects": { - "data": [ - { - "id": "id", - "name": "name", - "role": "role" - } - ], - "object": "list" - }, - "role": "role", - "technical_level": "technical_level", - "user": { - "id": "id", - "object": "user", - "banned": true, - "banned_at": 0, - "email": "email", - "enabled": true, - "name": "name", - "picture": "picture" - } -} -``` + - `start_time: int` -## Delete user + - `has_more: bool` -`admin.organization.users.delete(struser_id) -> UserDeleteResponse` + - `next_page: Optional[str]` -**delete** `/organization/users/{user_id}` + - `object: Literal["page"]` -Deletes a user from the organization. + - `"page"` -### Parameters +### Usage Web Search Calls Response -- `user_id: str` +- `class UsageWebSearchCallsResponse: …` -### Returns + - `data: List[Data]` -- `class UserDeleteResponse: …` + - `end_time: int` - - `id: str` + - `object: Literal["bucket"]` - - `deleted: bool` + - `"bucket"` - - `object: Literal["organization.user.deleted"]` + - `results: List[DataResult]` - - `"organization.user.deleted"` + - `class DataResultOrganizationUsageCompletionsResult: …` -### Example + The aggregated completions usage details of the specific time bucket. -```python -import os -from openai import OpenAI + - `input_tokens: int` -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -user = client.admin.organization.users.delete( - "user_id", -) -print(user.id) -``` + The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens. -#### Response + - `num_model_requests: int` -```json -{ - "id": "id", - "deleted": true, - "object": "organization.user.deleted" -} -``` + The count of requests made to the model. -## Domain Types + - `object: Literal["organization.usage.completions.result"]` -### Organization User + - `"organization.usage.completions.result"` -- `class OrganizationUser: …` + - `output_tokens: int` - Represents an individual `user` within an organization. + The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens. - - `id: str` + - `api_key_id: Optional[str]` - The identifier, which can be referenced in API endpoints + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `added_at: int` + - `batch: Optional[bool]` - The Unix timestamp (in seconds) of when the user was added. + When `group_by=batch`, this field tells whether the grouped usage result is batch or not. - - `object: Literal["organization.user"]` + - `input_audio_tokens: Optional[int]` - The object type, which is always `organization.user` + The aggregated number of audio input tokens used, including cached tokens. - - `"organization.user"` + - `input_cached_tokens: Optional[int]` - - `api_key_last_used_at: Optional[int]` + 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. - The Unix timestamp (in seconds) of the user's last API key usage. + - `model: Optional[str]` - - `created: Optional[int]` + When `group_by=model`, this field provides the model name of the grouped usage result. - The Unix timestamp (in seconds) of when the user was created. + - `output_audio_tokens: Optional[int]` - - `developer_persona: Optional[str]` + The aggregated number of audio output tokens used. - The developer persona metadata for the user. + - `project_id: Optional[str]` - - `email: Optional[str]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - The email address of the user + - `service_tier: Optional[str]` - - `is_default: Optional[bool]` + When `group_by=service_tier`, this field provides the service tier of the grouped usage result. - Whether this is the organization's default user. + - `user_id: Optional[str]` - - `is_scale_tier_authorized_purchaser: Optional[bool]` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - Whether the user is an authorized purchaser for Scale Tier. + - `class DataResultOrganizationUsageEmbeddingsResult: …` - - `is_scim_managed: Optional[bool]` + The aggregated embeddings usage details of the specific time bucket. - Whether the user is managed through SCIM. + - `input_tokens: int` - - `is_service_account: Optional[bool]` + The aggregated number of input tokens used. - Whether the user is a service account. + - `num_model_requests: int` - - `name: Optional[str]` + The count of requests made to the model. - The name of the user + - `object: Literal["organization.usage.embeddings.result"]` - - `projects: Optional[Projects]` + - `"organization.usage.embeddings.result"` - Projects associated with the user, if included. + - `api_key_id: Optional[str]` - - `data: List[ProjectsData]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `id: Optional[str]` + - `model: Optional[str]` - - `name: Optional[str]` + When `group_by=model`, this field provides the model name of the grouped usage result. - - `role: Optional[str]` + - `project_id: Optional[str]` - - `object: Literal["list"]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `"list"` + - `user_id: Optional[str]` - - `role: Optional[str]` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - `owner` or `reader` + - `class DataResultOrganizationUsageModerationsResult: …` - - `technical_level: Optional[str]` + The aggregated moderations usage details of the specific time bucket. - The technical level metadata for the user. + - `input_tokens: int` - - `user: Optional[User]` + The aggregated number of input tokens used. - Nested user details. + - `num_model_requests: int` - - `id: str` + The count of requests made to the model. - - `object: Literal["user"]` + - `object: Literal["organization.usage.moderations.result"]` - - `"user"` + - `"organization.usage.moderations.result"` - - `banned: Optional[bool]` + - `api_key_id: Optional[str]` - - `banned_at: Optional[int]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `email: Optional[str]` + - `model: Optional[str]` - - `enabled: Optional[bool]` + When `group_by=model`, this field provides the model name of the grouped usage result. - - `name: Optional[str]` + - `project_id: Optional[str]` - - `picture: Optional[str]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. -### User Delete Response + - `user_id: Optional[str]` -- `class UserDeleteResponse: …` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `id: str` + - `class DataResultOrganizationUsageImagesResult: …` - - `deleted: bool` + The aggregated images usage details of the specific time bucket. - - `object: Literal["organization.user.deleted"]` + - `images: int` - - `"organization.user.deleted"` + The number of images processed. -# Roles + - `num_model_requests: int` -## List user organization role assignments + The count of requests made to the model. -`admin.organization.users.roles.list(struser_id, RoleListParams**kwargs) -> SyncNextCursorPage[RoleListResponse]` + - `object: Literal["organization.usage.images.result"]` -**get** `/organization/users/{user_id}/roles` + - `"organization.usage.images.result"` -Lists the organization roles assigned to a user within the organization. + - `api_key_id: Optional[str]` -### Parameters + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. -- `user_id: str` + - `model: Optional[str]` -- `after: Optional[str]` + When `group_by=model`, this field provides the model name of the grouped usage result. - Cursor for pagination. Provide the value from the previous response's `next` field to continue listing organization roles. + - `project_id: Optional[str]` -- `limit: Optional[int]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - A limit on the number of organization role assignments to return. + - `size: Optional[str]` -- `order: Optional[Literal["asc", "desc"]]` + When `group_by=size`, this field provides the image size of the grouped usage result. - Sort order for the returned organization roles. + - `source: Optional[str]` - - `"asc"` + When `group_by=source`, this field provides the source of the grouped usage result, possible values are `image.generation`, `image.edit`, `image.variation`. - - `"desc"` + - `user_id: Optional[str]` -### Returns + When `group_by=user_id`, this field provides the user ID of the grouped usage result. -- `class RoleListResponse: …` + - `class DataResultOrganizationUsageAudioSpeechesResult: …` - Detailed information about a role assignment entry returned when listing assignments. + The aggregated audio speeches usage details of the specific time bucket. - - `id: str` + - `characters: int` - Identifier for the role. + The number of characters processed. - - `created_at: Optional[int]` + - `num_model_requests: int` - When the role was created. + The count of requests made to the model. - - `created_by: Optional[str]` + - `object: Literal["organization.usage.audio_speeches.result"]` - Identifier of the actor who created the role. + - `"organization.usage.audio_speeches.result"` - - `created_by_user_obj: Optional[Dict[str, object]]` + - `api_key_id: Optional[str]` - User details for the actor that created the role, when available. + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `description: Optional[str]` + - `model: Optional[str]` - Description of the role. + When `group_by=model`, this field provides the model name of the grouped usage result. - - `metadata: Optional[Dict[str, object]]` + - `project_id: Optional[str]` - Arbitrary metadata stored on the role. + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `name: str` + - `user_id: Optional[str]` - Name of the role. + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `permissions: List[str]` + - `class DataResultOrganizationUsageAudioTranscriptionsResult: …` - Permissions associated with the role. + The aggregated audio transcriptions usage details of the specific time bucket. - - `predefined_role: bool` + - `num_model_requests: int` - Whether the role is predefined by OpenAI. + The count of requests made to the model. - - `resource_type: str` + - `object: Literal["organization.usage.audio_transcriptions.result"]` - Resource type the role applies to. + - `"organization.usage.audio_transcriptions.result"` - - `updated_at: Optional[int]` + - `seconds: int` - When the role was last updated. + The number of seconds processed. -### Example + - `api_key_id: Optional[str]` -```python -import os -from openai import OpenAI + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -page = client.admin.organization.users.roles.list( - user_id="user_id", -) -page = page.data[0] -print(page.id) -``` + - `model: Optional[str]` -#### Response + When `group_by=model`, this field provides the model name of the grouped usage result. -```json -{ - "data": [ - { - "id": "id", - "created_at": 0, - "created_by": "created_by", - "created_by_user_obj": { - "foo": "bar" - }, - "description": "description", - "metadata": { - "foo": "bar" - }, - "name": "name", - "permissions": [ - "string" - ], - "predefined_role": true, - "resource_type": "resource_type", - "updated_at": 0 - } - ], - "has_more": true, - "next": "next", - "object": "list" -} -``` + - `project_id: Optional[str]` -## Assign organization role to user + When `group_by=project_id`, this field provides the project ID of the grouped usage result. -`admin.organization.users.roles.create(struser_id, RoleCreateParams**kwargs) -> RoleCreateResponse` + - `user_id: Optional[str]` -**post** `/organization/users/{user_id}/roles` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. -Assigns an organization role to a user within the organization. + - `class DataResultOrganizationUsageVectorStoresResult: …` -### Parameters + The aggregated vector stores usage details of the specific time bucket. -- `user_id: str` + - `object: Literal["organization.usage.vector_stores.result"]` -- `role_id: str` + - `"organization.usage.vector_stores.result"` - Identifier of the role to assign. + - `usage_bytes: int` -### Returns + The vector stores usage in bytes. -- `class RoleCreateResponse: …` + - `project_id: Optional[str]` - Role assignment linking a user to a role. + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `object: Literal["user.role"]` + - `class DataResultOrganizationUsageCodeInterpreterSessionsResult: …` - Always `user.role`. + The aggregated code interpreter sessions usage details of the specific time bucket. - - `"user.role"` + - `num_sessions: int` - - `role: Role` + The number of code interpreter sessions. - Details about a role that can be assigned through the public Roles API. + - `object: Literal["organization.usage.code_interpreter_sessions.result"]` - - `id: str` + - `"organization.usage.code_interpreter_sessions.result"` - Identifier for the role. + - `project_id: Optional[str]` - - `description: Optional[str]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - Optional description of the role. + - `class DataResultOrganizationUsageFileSearchesResult: …` - - `name: str` + The aggregated file search calls usage details of the specific time bucket. - Unique name for the role. + - `num_requests: int` - - `object: Literal["role"]` + The count of file search calls. - Always `role`. + - `object: Literal["organization.usage.file_searches.result"]` - - `"role"` + - `"organization.usage.file_searches.result"` - - `permissions: List[str]` + - `api_key_id: Optional[str]` - Permissions granted by the role. + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `predefined_role: bool` + - `project_id: Optional[str]` - Whether the role is predefined and managed by OpenAI. + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `resource_type: str` + - `user_id: Optional[str]` - Resource type the role is bound to (for example `api.organization` or `api.project`). + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `user: OrganizationUser` + - `vector_store_id: Optional[str]` - Represents an individual `user` within an organization. + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. - - `id: str` + - `class DataResultOrganizationUsageWebSearchesResult: …` - The identifier, which can be referenced in API endpoints + The aggregated web search calls usage details of the specific time bucket. - - `added_at: int` + - `num_model_requests: int` - The Unix timestamp (in seconds) of when the user was added. + The count of model requests. - - `object: Literal["organization.user"]` + - `num_requests: int` - The object type, which is always `organization.user` + The count of web search calls. - - `"organization.user"` + - `object: Literal["organization.usage.web_searches.result"]` - - `api_key_last_used_at: Optional[int]` + - `"organization.usage.web_searches.result"` - The Unix timestamp (in seconds) of the user's last API key usage. + - `api_key_id: Optional[str]` - - `created: Optional[int]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - The Unix timestamp (in seconds) of when the user was created. + - `context_level: Optional[str]` - - `developer_persona: Optional[str]` + When `group_by=context_level`, this field provides the search context size of the grouped usage result. - The developer persona metadata for the user. + - `model: Optional[str]` - - `email: Optional[str]` + When `group_by=model`, this field provides the model name of the grouped usage result. - The email address of the user + - `project_id: Optional[str]` - - `is_default: Optional[bool]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - Whether this is the organization's default user. + - `user_id: Optional[str]` - - `is_scale_tier_authorized_purchaser: Optional[bool]` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - Whether the user is an authorized purchaser for Scale Tier. + - `class DataResultOrganizationCostsResult: …` - - `is_scim_managed: Optional[bool]` + The aggregated costs details of the specific time bucket. - Whether the user is managed through SCIM. + - `object: Literal["organization.costs.result"]` - - `is_service_account: Optional[bool]` + - `"organization.costs.result"` - Whether the user is a service account. + - `amount: Optional[DataResultOrganizationCostsResultAmount]` - - `name: Optional[str]` + The monetary value in its associated currency. - The name of the user + - `currency: Optional[str]` - - `projects: Optional[Projects]` + Lowercase ISO-4217 currency e.g. "usd" - Projects associated with the user, if included. + - `value: Optional[float]` - - `data: List[ProjectsData]` + The numeric value of the cost. - - `id: Optional[str]` + - `api_key_id: Optional[str]` - - `name: Optional[str]` + When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. - - `role: Optional[str]` + - `line_item: Optional[str]` - - `object: Literal["list"]` + When `group_by=line_item`, this field provides the line item of the grouped costs result. - - `"list"` + - `project_id: Optional[str]` - - `role: Optional[str]` + When `group_by=project_id`, this field provides the project ID of the grouped costs result. - `owner` or `reader` + - `quantity: Optional[float]` - - `technical_level: Optional[str]` + When `group_by=line_item`, this field provides the quantity of the grouped costs result. - The technical level metadata for the user. + - `start_time: int` - - `user: Optional[User]` + - `has_more: bool` - Nested user details. + - `next_page: Optional[str]` - - `id: str` + - `object: Literal["page"]` - - `object: Literal["user"]` + - `"page"` - - `"user"` +### Usage Costs Response - - `banned: Optional[bool]` +- `class UsageCostsResponse: …` - - `banned_at: Optional[int]` + - `data: List[Data]` - - `email: Optional[str]` + - `end_time: int` - - `enabled: Optional[bool]` + - `object: Literal["bucket"]` - - `name: Optional[str]` + - `"bucket"` - - `picture: Optional[str]` + - `results: List[DataResult]` -### Example + - `class DataResultOrganizationUsageCompletionsResult: …` -```python -import os -from openai import OpenAI + The aggregated completions usage details of the specific time bucket. -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -role = client.admin.organization.users.roles.create( - user_id="user_id", - role_id="role_id", -) -print(role.object) -``` + - `input_tokens: int` -#### Response + The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens. -```json -{ - "object": "user.role", - "role": { - "id": "id", - "description": "description", - "name": "name", - "object": "role", - "permissions": [ - "string" - ], - "predefined_role": true, - "resource_type": "resource_type" - }, - "user": { - "id": "id", - "added_at": 0, - "object": "organization.user", - "api_key_last_used_at": 0, - "created": 0, - "developer_persona": "developer_persona", - "email": "email", - "is_default": true, - "is_scale_tier_authorized_purchaser": true, - "is_scim_managed": true, - "is_service_account": true, - "name": "name", - "projects": { - "data": [ - { - "id": "id", - "name": "name", - "role": "role" - } - ], - "object": "list" - }, - "role": "role", - "technical_level": "technical_level", - "user": { - "id": "id", - "object": "user", - "banned": true, - "banned_at": 0, - "email": "email", - "enabled": true, - "name": "name", - "picture": "picture" - } - } -} -``` + - `num_model_requests: int` -## Unassign organization role from user + The count of requests made to the model. -`admin.organization.users.roles.delete(strrole_id, RoleDeleteParams**kwargs) -> RoleDeleteResponse` + - `object: Literal["organization.usage.completions.result"]` -**delete** `/organization/users/{user_id}/roles/{role_id}` + - `"organization.usage.completions.result"` -Unassigns an organization role from a user within the organization. + - `output_tokens: int` -### Parameters + The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens. -- `user_id: str` + - `api_key_id: Optional[str]` -- `role_id: str` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. -### Returns + - `batch: Optional[bool]` -- `class RoleDeleteResponse: …` + When `group_by=batch`, this field tells whether the grouped usage result is batch or not. - Confirmation payload returned after unassigning a role. + - `input_audio_tokens: Optional[int]` - - `deleted: bool` + The aggregated number of audio input tokens used, including cached tokens. - Whether the assignment was removed. + - `input_cached_tokens: Optional[int]` - - `object: str` + 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. - Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. + - `model: Optional[str]` -### Example + When `group_by=model`, this field provides the model name of the grouped usage result. -```python -import os -from openai import OpenAI + - `output_audio_tokens: Optional[int]` -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -role = client.admin.organization.users.roles.delete( - role_id="role_id", - user_id="user_id", -) -print(role.deleted) -``` + The aggregated number of audio output tokens used. -#### Response + - `project_id: Optional[str]` -```json -{ - "deleted": true, - "object": "object" -} -``` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. -## Domain Types + - `service_tier: Optional[str]` -### Role List Response + When `group_by=service_tier`, this field provides the service tier of the grouped usage result. -- `class RoleListResponse: …` + - `user_id: Optional[str]` - Detailed information about a role assignment entry returned when listing assignments. + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `id: str` + - `class DataResultOrganizationUsageEmbeddingsResult: …` - Identifier for the role. + The aggregated embeddings usage details of the specific time bucket. - - `created_at: Optional[int]` + - `input_tokens: int` - When the role was created. + The aggregated number of input tokens used. - - `created_by: Optional[str]` + - `num_model_requests: int` - Identifier of the actor who created the role. + The count of requests made to the model. - - `created_by_user_obj: Optional[Dict[str, object]]` + - `object: Literal["organization.usage.embeddings.result"]` - User details for the actor that created the role, when available. + - `"organization.usage.embeddings.result"` - - `description: Optional[str]` + - `api_key_id: Optional[str]` - Description of the role. + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `metadata: Optional[Dict[str, object]]` + - `model: Optional[str]` - Arbitrary metadata stored on the role. + When `group_by=model`, this field provides the model name of the grouped usage result. - - `name: str` + - `project_id: Optional[str]` - Name of the role. + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `permissions: List[str]` + - `user_id: Optional[str]` - Permissions associated with the role. + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `predefined_role: bool` + - `class DataResultOrganizationUsageModerationsResult: …` - Whether the role is predefined by OpenAI. + The aggregated moderations usage details of the specific time bucket. - - `resource_type: str` + - `input_tokens: int` - Resource type the role applies to. + The aggregated number of input tokens used. - - `updated_at: Optional[int]` + - `num_model_requests: int` - When the role was last updated. + The count of requests made to the model. -### Role Create Response + - `object: Literal["organization.usage.moderations.result"]` -- `class RoleCreateResponse: …` + - `"organization.usage.moderations.result"` - Role assignment linking a user to a role. + - `api_key_id: Optional[str]` - - `object: Literal["user.role"]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - Always `user.role`. + - `model: Optional[str]` - - `"user.role"` + When `group_by=model`, this field provides the model name of the grouped usage result. - - `role: Role` + - `project_id: Optional[str]` - Details about a role that can be assigned through the public Roles API. + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `id: str` + - `user_id: Optional[str]` - Identifier for the role. + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `description: Optional[str]` + - `class DataResultOrganizationUsageImagesResult: …` - Optional description of the role. + The aggregated images usage details of the specific time bucket. - - `name: str` + - `images: int` - Unique name for the role. + The number of images processed. - - `object: Literal["role"]` + - `num_model_requests: int` - Always `role`. + The count of requests made to the model. - - `"role"` + - `object: Literal["organization.usage.images.result"]` - - `permissions: List[str]` + - `"organization.usage.images.result"` - Permissions granted by the role. + - `api_key_id: Optional[str]` - - `predefined_role: bool` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - Whether the role is predefined and managed by OpenAI. + - `model: Optional[str]` - - `resource_type: str` + When `group_by=model`, this field provides the model name of the grouped usage result. - Resource type the role is bound to (for example `api.organization` or `api.project`). + - `project_id: Optional[str]` - - `user: OrganizationUser` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - Represents an individual `user` within an organization. + - `size: Optional[str]` - - `id: str` + When `group_by=size`, this field provides the image size of the grouped usage result. - The identifier, which can be referenced in API endpoints + - `source: Optional[str]` - - `added_at: int` + When `group_by=source`, this field provides the source of the grouped usage result, possible values are `image.generation`, `image.edit`, `image.variation`. - The Unix timestamp (in seconds) of when the user was added. + - `user_id: Optional[str]` - - `object: Literal["organization.user"]` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - The object type, which is always `organization.user` + - `class DataResultOrganizationUsageAudioSpeechesResult: …` - - `"organization.user"` + The aggregated audio speeches usage details of the specific time bucket. - - `api_key_last_used_at: Optional[int]` + - `characters: int` - The Unix timestamp (in seconds) of the user's last API key usage. + The number of characters processed. - - `created: Optional[int]` + - `num_model_requests: int` - The Unix timestamp (in seconds) of when the user was created. + The count of requests made to the model. - - `developer_persona: Optional[str]` + - `object: Literal["organization.usage.audio_speeches.result"]` - The developer persona metadata for the user. + - `"organization.usage.audio_speeches.result"` - - `email: Optional[str]` + - `api_key_id: Optional[str]` - The email address of the user + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `is_default: Optional[bool]` + - `model: Optional[str]` - Whether this is the organization's default user. + When `group_by=model`, this field provides the model name of the grouped usage result. - - `is_scale_tier_authorized_purchaser: Optional[bool]` + - `project_id: Optional[str]` - Whether the user is an authorized purchaser for Scale Tier. + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `is_scim_managed: Optional[bool]` + - `user_id: Optional[str]` - Whether the user is managed through SCIM. + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `is_service_account: Optional[bool]` + - `class DataResultOrganizationUsageAudioTranscriptionsResult: …` - Whether the user is a service account. + The aggregated audio transcriptions usage details of the specific time bucket. - - `name: Optional[str]` + - `num_model_requests: int` - The name of the user + The count of requests made to the model. - - `projects: Optional[Projects]` + - `object: Literal["organization.usage.audio_transcriptions.result"]` - Projects associated with the user, if included. + - `"organization.usage.audio_transcriptions.result"` - - `data: List[ProjectsData]` + - `seconds: int` - - `id: Optional[str]` + The number of seconds processed. - - `name: Optional[str]` + - `api_key_id: Optional[str]` - - `role: Optional[str]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `object: Literal["list"]` + - `model: Optional[str]` - - `"list"` + When `group_by=model`, this field provides the model name of the grouped usage result. - - `role: Optional[str]` + - `project_id: Optional[str]` - `owner` or `reader` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `technical_level: Optional[str]` + - `user_id: Optional[str]` - The technical level metadata for the user. + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `user: Optional[User]` + - `class DataResultOrganizationUsageVectorStoresResult: …` - Nested user details. + The aggregated vector stores usage details of the specific time bucket. - - `id: str` + - `object: Literal["organization.usage.vector_stores.result"]` - - `object: Literal["user"]` + - `"organization.usage.vector_stores.result"` - - `"user"` + - `usage_bytes: int` - - `banned: Optional[bool]` + The vector stores usage in bytes. - - `banned_at: Optional[int]` + - `project_id: Optional[str]` - - `email: Optional[str]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `enabled: Optional[bool]` + - `class DataResultOrganizationUsageCodeInterpreterSessionsResult: …` - - `name: Optional[str]` + The aggregated code interpreter sessions usage details of the specific time bucket. - - `picture: Optional[str]` + - `num_sessions: int` -### Role Delete Response + The number of code interpreter sessions. -- `class RoleDeleteResponse: …` + - `object: Literal["organization.usage.code_interpreter_sessions.result"]` - Confirmation payload returned after unassigning a role. + - `"organization.usage.code_interpreter_sessions.result"` - - `deleted: bool` + - `project_id: Optional[str]` - Whether the assignment was removed. + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - - `object: str` + - `class DataResultOrganizationUsageFileSearchesResult: …` - Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. + The aggregated file search calls usage details of the specific time bucket. -# Groups + - `num_requests: int` -## List groups + The count of file search calls. -`admin.organization.groups.list(GroupListParams**kwargs) -> SyncNextCursorPage[Group]` + - `object: Literal["organization.usage.file_searches.result"]` -**get** `/organization/groups` + - `"organization.usage.file_searches.result"` -Lists all groups in the organization. + - `api_key_id: Optional[str]` -### Parameters - -- `after: Optional[str]` - - A cursor for use in pagination. `after` is a group ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with group_abc, your subsequent call can include `after=group_abc` in order to fetch the next page of the list. - -- `limit: Optional[int]` + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - A limit on the number of groups to be returned. Limit can range between 0 and 1000, and the default is 100. + - `project_id: Optional[str]` -- `order: Optional[Literal["asc", "desc"]]` + When `group_by=project_id`, this field provides the project ID of the grouped usage result. - Specifies the sort order of the returned groups. + - `user_id: Optional[str]` - - `"asc"` + When `group_by=user_id`, this field provides the user ID of the grouped usage result. - - `"desc"` + - `vector_store_id: Optional[str]` -### Returns + When `group_by=vector_store_id`, this field provides the vector store ID of the grouped usage result. -- `class Group: …` + - `class DataResultOrganizationUsageWebSearchesResult: …` - Details about an organization group. + The aggregated web search calls usage details of the specific time bucket. - - `id: str` + - `num_model_requests: int` - Identifier for the group. + The count of model requests. - - `created_at: int` + - `num_requests: int` - Unix timestamp (in seconds) when the group was created. + The count of web search calls. - - `group_type: str` + - `object: Literal["organization.usage.web_searches.result"]` - The type of the group. + - `"organization.usage.web_searches.result"` - - `is_scim_managed: bool` + - `api_key_id: Optional[str]` - Whether the group is managed through SCIM and controlled by your identity provider. + When `group_by=api_key_id`, this field provides the API key ID of the grouped usage result. - - `name: str` + - `context_level: Optional[str]` - Display name of the group. + When `group_by=context_level`, this field provides the search context size of the grouped usage result. -### Example + - `model: Optional[str]` -```python -import os -from openai import OpenAI + When `group_by=model`, this field provides the model name of the grouped usage result. -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -page = client.admin.organization.groups.list() -page = page.data[0] -print(page.id) -``` + - `project_id: Optional[str]` -#### Response + When `group_by=project_id`, this field provides the project ID of the grouped usage result. -```json -{ - "data": [ - { - "id": "id", - "created_at": 0, - "group_type": "group_type", - "is_scim_managed": true, - "name": "name" - } - ], - "has_more": true, - "next": "next", - "object": "list" -} -``` + - `user_id: Optional[str]` -## Create group + When `group_by=user_id`, this field provides the user ID of the grouped usage result. -`admin.organization.groups.create(GroupCreateParams**kwargs) -> Group` + - `class DataResultOrganizationCostsResult: …` -**post** `/organization/groups` + The aggregated costs details of the specific time bucket. -Creates a new group in the organization. + - `object: Literal["organization.costs.result"]` -### Parameters + - `"organization.costs.result"` -- `name: str` + - `amount: Optional[DataResultOrganizationCostsResultAmount]` - Human readable name for the group. + The monetary value in its associated currency. -### Returns + - `currency: Optional[str]` -- `class Group: …` + Lowercase ISO-4217 currency e.g. "usd" - Details about an organization group. + - `value: Optional[float]` - - `id: str` + The numeric value of the cost. - Identifier for the group. + - `api_key_id: Optional[str]` - - `created_at: int` + When `group_by=api_key_id`, this field provides the API Key ID of the grouped costs result. - Unix timestamp (in seconds) when the group was created. + - `line_item: Optional[str]` - - `group_type: str` + When `group_by=line_item`, this field provides the line item of the grouped costs result. - The type of the group. + - `project_id: Optional[str]` - - `is_scim_managed: bool` + When `group_by=project_id`, this field provides the project ID of the grouped costs result. - Whether the group is managed through SCIM and controlled by your identity provider. + - `quantity: Optional[float]` - - `name: str` + When `group_by=line_item`, this field provides the quantity of the grouped costs result. - Display name of the group. + - `start_time: int` -### Example + - `has_more: bool` -```python -import os -from openai import OpenAI + - `next_page: Optional[str]` -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -group = client.admin.organization.groups.create( - name="x", -) -print(group.id) -``` + - `object: Literal["page"]` -#### Response + - `"page"` -```json -{ - "id": "id", - "created_at": 0, - "group_type": "group_type", - "is_scim_managed": true, - "name": "name" -} -``` +# Invites -## Update group +## List invites -`admin.organization.groups.update(strgroup_id, GroupUpdateParams**kwargs) -> GroupUpdateResponse` +`admin.organization.invites.list(InviteListParams**kwargs) -> SyncConversationCursorPage[Invite]` -**post** `/organization/groups/{group_id}` +**get** `/organization/invites` -Updates a group's information. +Returns a list of invites in the organization. ### Parameters -- `group_id: str` +- `after: Optional[str]` -- `name: str` + A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - New display name for the group. +- `limit: Optional[int]` + + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. ### Returns -- `class GroupUpdateResponse: …` +- `class Invite: …` - Response returned after updating a group. + Represents an individual `invite` to the organization. - `id: str` - Identifier for the group. + The identifier, which can be referenced in API endpoints - `created_at: int` - Unix timestamp (in seconds) when the group was created. + The Unix timestamp (in seconds) of when the invite was sent. - - `is_scim_managed: bool` + - `email: str` - Whether the group is managed through SCIM and controlled by your identity provider. + The email address of the individual to whom the invite was sent - - `name: str` + - `object: Literal["organization.invite"]` - Updated display name for the group. + The object type, which is always `organization.invite` -### Example + - `"organization.invite"` -```python -import os -from openai import OpenAI + - `projects: List[Project]` -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -group = client.admin.organization.groups.update( - group_id="group_id", - name="x", -) -print(group.id) -``` + The projects that were granted membership upon acceptance of the invite. -#### Response + - `id: str` -```json -{ - "id": "id", - "created_at": 0, - "is_scim_managed": true, - "name": "name" -} -``` + Project's public ID -## Delete group + - `role: Literal["member", "owner"]` -`admin.organization.groups.delete(strgroup_id) -> GroupDeleteResponse` + Project membership role -**delete** `/organization/groups/{group_id}` + - `"member"` -Deletes a group from the organization. + - `"owner"` -### Parameters + - `role: Literal["owner", "reader"]` -- `group_id: str` + `owner` or `reader` -### Returns + - `"owner"` -- `class GroupDeleteResponse: …` + - `"reader"` - Confirmation payload returned after deleting a group. + - `status: Literal["accepted", "expired", "pending"]` - - `id: str` + `accepted`,`expired`, or `pending` - Identifier of the deleted group. + - `"accepted"` - - `deleted: bool` + - `"expired"` - Whether the group was deleted. + - `"pending"` - - `object: Literal["group.deleted"]` + - `accepted_at: Optional[int]` - Always `group.deleted`. + The Unix timestamp (in seconds) of when the invite was accepted. - - `"group.deleted"` + - `expires_at: Optional[int]` + + The Unix timestamp (in seconds) of when the invite expires. ### Example @@ -11541,139 +12442,143 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -group = client.admin.organization.groups.delete( - "group_id", -) -print(group.id) +page = client.admin.organization.invites.list() +page = page.data[0] +print(page.id) ``` #### Response ```json { + "data": [ + { "id": "id", - "deleted": true, - "object": "group.deleted" + "created_at": 0, + "email": "email", + "object": "organization.invite", + "projects": [ + { + "id": "id", + "role": "member" + } + ], + "role": "owner", + "status": "accepted", + "accepted_at": 0, + "expires_at": 0 + } + ], + "has_more": true, + "object": "list", + "first_id": "first_id", + "last_id": "last_id" } ``` -## Domain Types - -### Group - -- `class Group: …` - - Details about an organization group. - - - `id: str` +## Create invite - Identifier for the group. +`admin.organization.invites.create(InviteCreateParams**kwargs) -> Invite` - - `created_at: int` +**post** `/organization/invites` - Unix timestamp (in seconds) when the group was created. +Create an invite for a user to the organization. The invite must be accepted by the user before they have access to the organization. - - `group_type: str` +### Parameters - The type of the group. +- `email: str` - - `is_scim_managed: bool` + Send an email to this address - Whether the group is managed through SCIM and controlled by your identity provider. +- `role: Literal["reader", "owner"]` - - `name: str` + `owner` or `reader` - Display name of the group. + - `"reader"` -### Group Update Response + - `"owner"` -- `class GroupUpdateResponse: …` +- `projects: Optional[Iterable[Project]]` - Response returned after updating a group. + An array of projects to which membership is granted at the same time the org invite is accepted. If omitted, the user will be invited to the default project for compatibility with legacy behavior. If empty list is passed, the user will not be invited to any projects, including the default one. - `id: str` - Identifier for the group. - - - `created_at: int` - - Unix timestamp (in seconds) when the group was created. + Project's public ID - - `is_scim_managed: bool` + - `role: Literal["member", "owner"]` - Whether the group is managed through SCIM and controlled by your identity provider. + Project membership role - - `name: str` + - `"member"` - Updated display name for the group. + - `"owner"` -### Group Delete Response +### Returns -- `class GroupDeleteResponse: …` +- `class Invite: …` - Confirmation payload returned after deleting a group. + Represents an individual `invite` to the organization. - `id: str` - Identifier of the deleted group. - - - `deleted: bool` + The identifier, which can be referenced in API endpoints - Whether the group was deleted. + - `created_at: int` - - `object: Literal["group.deleted"]` + The Unix timestamp (in seconds) of when the invite was sent. - Always `group.deleted`. + - `email: str` - - `"group.deleted"` + The email address of the individual to whom the invite was sent -# Users + - `object: Literal["organization.invite"]` -## List group users + The object type, which is always `organization.invite` -`admin.organization.groups.users.list(strgroup_id, UserListParams**kwargs) -> SyncNextCursorPage[OrganizationGroupUser]` + - `"organization.invite"` -**get** `/organization/groups/{group_id}/users` + - `projects: List[Project]` -Lists the users assigned to a group. + The projects that were granted membership upon acceptance of the invite. -### Parameters + - `id: str` -- `group_id: str` + Project's public ID -- `after: Optional[str]` + - `role: Literal["member", "owner"]` - A cursor for use in pagination. Provide the ID of the last user from the previous list response to retrieve the next page. + Project membership role -- `limit: Optional[int]` + - `"member"` - A limit on the number of users to be returned. Limit can range between 0 and 1000, and the default is 100. + - `"owner"` -- `order: Optional[Literal["asc", "desc"]]` + - `role: Literal["owner", "reader"]` - Specifies the sort order of users in the list. + `owner` or `reader` - - `"asc"` + - `"owner"` - - `"desc"` + - `"reader"` -### Returns + - `status: Literal["accepted", "expired", "pending"]` -- `class OrganizationGroupUser: …` + `accepted`,`expired`, or `pending` - Represents an individual user returned when inspecting group membership. + - `"accepted"` - - `id: str` + - `"expired"` - The identifier, which can be referenced in API endpoints + - `"pending"` - - `email: Optional[str]` + - `accepted_at: Optional[int]` - The email address of the user. + The Unix timestamp (in seconds) of when the invite was accepted. - - `name: str` + - `expires_at: Optional[int]` - The name of the user. + The Unix timestamp (in seconds) of when the invite expires. ### Example @@ -11684,121 +12589,111 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -page = client.admin.organization.groups.users.list( - group_id="group_id", +invite = client.admin.organization.invites.create( + email="email", + role="reader", ) -page = page.data[0] -print(page.id) +print(invite.id) ``` #### Response ```json { - "data": [ - { "id": "id", + "created_at": 0, "email": "email", - "name": "name" + "object": "organization.invite", + "projects": [ + { + "id": "id", + "role": "member" } ], - "has_more": true, - "next": "next", - "object": "list" + "role": "owner", + "status": "accepted", + "accepted_at": 0, + "expires_at": 0 } ``` -## Add group user +## Retrieve invite -`admin.organization.groups.users.create(strgroup_id, UserCreateParams**kwargs) -> UserCreateResponse` +`admin.organization.invites.retrieve(strinvite_id) -> Invite` -**post** `/organization/groups/{group_id}/users` +**get** `/organization/invites/{invite_id}` -Adds a user to a group. +Retrieves an invite. ### Parameters -- `group_id: str` +- `invite_id: str` -- `user_id: str` +### Returns - Identifier of the user to add to the group. +- `class Invite: …` -### Returns + Represents an individual `invite` to the organization. -- `class UserCreateResponse: …` + - `id: str` - Confirmation payload returned after adding a user to a group. + The identifier, which can be referenced in API endpoints - - `group_id: str` + - `created_at: int` - Identifier of the group the user was added to. + The Unix timestamp (in seconds) of when the invite was sent. - - `object: Literal["group.user"]` + - `email: str` - Always `group.user`. + The email address of the individual to whom the invite was sent - - `"group.user"` + - `object: Literal["organization.invite"]` - - `user_id: str` + The object type, which is always `organization.invite` - Identifier of the user that was added. + - `"organization.invite"` -### Example + - `projects: List[Project]` -```python -import os -from openai import OpenAI + The projects that were granted membership upon acceptance of the invite. -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -user = client.admin.organization.groups.users.create( - group_id="group_id", - user_id="user_id", -) -print(user.group_id) -``` + - `id: str` -#### Response + Project's public ID -```json -{ - "group_id": "group_id", - "object": "group.user", - "user_id": "user_id" -} -``` + - `role: Literal["member", "owner"]` -## Remove group user + Project membership role -`admin.organization.groups.users.delete(struser_id, UserDeleteParams**kwargs) -> UserDeleteResponse` + - `"member"` -**delete** `/organization/groups/{group_id}/users/{user_id}` + - `"owner"` -Removes a user from a group. + - `role: Literal["owner", "reader"]` -### Parameters + `owner` or `reader` -- `group_id: str` + - `"owner"` -- `user_id: str` + - `"reader"` -### Returns + - `status: Literal["accepted", "expired", "pending"]` -- `class UserDeleteResponse: …` + `accepted`,`expired`, or `pending` - Confirmation payload returned after removing a user from a group. + - `"accepted"` - - `deleted: bool` + - `"expired"` - Whether the group membership was removed. + - `"pending"` - - `object: Literal["group.user.deleted"]` + - `accepted_at: Optional[int]` - Always `group.user.deleted`. + The Unix timestamp (in seconds) of when the invite was accepted. - - `"group.user.deleted"` + - `expires_at: Optional[int]` + + The Unix timestamp (in seconds) of when the invite expires. ### Example @@ -11809,292 +12704,291 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -user = client.admin.organization.groups.users.delete( - user_id="user_id", - group_id="group_id", +invite = client.admin.organization.invites.retrieve( + "invite_id", ) -print(user.deleted) +print(invite.id) ``` #### Response ```json { - "deleted": true, - "object": "group.user.deleted" + "id": "id", + "created_at": 0, + "email": "email", + "object": "organization.invite", + "projects": [ + { + "id": "id", + "role": "member" + } + ], + "role": "owner", + "status": "accepted", + "accepted_at": 0, + "expires_at": 0 } ``` -## Domain Types +## Delete invite -### Organization Group User +`admin.organization.invites.delete(strinvite_id) -> InviteDeleteResponse` -- `class OrganizationGroupUser: …` +**delete** `/organization/invites/{invite_id}` - Represents an individual user returned when inspecting group membership. +Delete an invite. If the invite has already been accepted, it cannot be deleted. - - `id: str` +### Parameters - The identifier, which can be referenced in API endpoints +- `invite_id: str` - - `email: Optional[str]` +### Returns - The email address of the user. +- `class InviteDeleteResponse: …` - - `name: str` + - `id: str` - The name of the user. + - `deleted: bool` -### User Create Response + - `object: Literal["organization.invite.deleted"]` -- `class UserCreateResponse: …` + The object type, which is always `organization.invite.deleted` - Confirmation payload returned after adding a user to a group. + - `"organization.invite.deleted"` - - `group_id: str` +### Example - Identifier of the group the user was added to. +```python +import os +from openai import OpenAI - - `object: Literal["group.user"]` +client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted +) +invite = client.admin.organization.invites.delete( + "invite_id", +) +print(invite.id) +``` - Always `group.user`. +#### Response - - `"group.user"` +```json +{ + "id": "id", + "deleted": true, + "object": "organization.invite.deleted" +} +``` - - `user_id: str` +## Domain Types - Identifier of the user that was added. +### Invite -### User Delete Response +- `class Invite: …` -- `class UserDeleteResponse: …` + Represents an individual `invite` to the organization. - Confirmation payload returned after removing a user from a group. + - `id: str` - - `deleted: bool` + The identifier, which can be referenced in API endpoints - Whether the group membership was removed. + - `created_at: int` - - `object: Literal["group.user.deleted"]` + The Unix timestamp (in seconds) of when the invite was sent. - Always `group.user.deleted`. + - `email: str` - - `"group.user.deleted"` + The email address of the individual to whom the invite was sent -# Roles + - `object: Literal["organization.invite"]` -## List group organization role assignments + The object type, which is always `organization.invite` -`admin.organization.groups.roles.list(strgroup_id, RoleListParams**kwargs) -> SyncNextCursorPage[RoleListResponse]` + - `"organization.invite"` -**get** `/organization/groups/{group_id}/roles` + - `projects: List[Project]` -Lists the organization roles assigned to a group within the organization. + The projects that were granted membership upon acceptance of the invite. -### Parameters + - `id: str` -- `group_id: str` + Project's public ID -- `after: Optional[str]` + - `role: Literal["member", "owner"]` - Cursor for pagination. Provide the value from the previous response's `next` field to continue listing organization roles. + Project membership role -- `limit: Optional[int]` + - `"member"` - A limit on the number of organization role assignments to return. + - `"owner"` -- `order: Optional[Literal["asc", "desc"]]` + - `role: Literal["owner", "reader"]` - Sort order for the returned organization roles. + `owner` or `reader` - - `"asc"` + - `"owner"` - - `"desc"` + - `"reader"` -### Returns + - `status: Literal["accepted", "expired", "pending"]` -- `class RoleListResponse: …` + `accepted`,`expired`, or `pending` - Detailed information about a role assignment entry returned when listing assignments. + - `"accepted"` - - `id: str` + - `"expired"` - Identifier for the role. + - `"pending"` - - `created_at: Optional[int]` + - `accepted_at: Optional[int]` - When the role was created. + The Unix timestamp (in seconds) of when the invite was accepted. - - `created_by: Optional[str]` + - `expires_at: Optional[int]` - Identifier of the actor who created the role. + The Unix timestamp (in seconds) of when the invite expires. - - `created_by_user_obj: Optional[Dict[str, object]]` +### Invite Delete Response - User details for the actor that created the role, when available. +- `class InviteDeleteResponse: …` - - `description: Optional[str]` + - `id: str` - Description of the role. + - `deleted: bool` - - `metadata: Optional[Dict[str, object]]` + - `object: Literal["organization.invite.deleted"]` - Arbitrary metadata stored on the role. + The object type, which is always `organization.invite.deleted` - - `name: str` + - `"organization.invite.deleted"` - Name of the role. +# Users - - `permissions: List[str]` +## List users - Permissions associated with the role. +`admin.organization.users.list(UserListParams**kwargs) -> SyncConversationCursorPage[OrganizationUser]` - - `predefined_role: bool` +**get** `/organization/users` - Whether the role is predefined by OpenAI. +Lists all of the users in the organization. - - `resource_type: str` +### Parameters - Resource type the role applies to. +- `after: Optional[str]` - - `updated_at: Optional[int]` + A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - When the role was last updated. +- `emails: Optional[Sequence[str]]` -### Example + Filter by the email address of users. -```python -import os -from openai import OpenAI +- `limit: Optional[int]` -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -page = client.admin.organization.groups.roles.list( - group_id="group_id", -) -page = page.data[0] -print(page.id) -``` + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. -#### Response +### Returns -```json -{ - "data": [ - { - "id": "id", - "created_at": 0, - "created_by": "created_by", - "created_by_user_obj": { - "foo": "bar" - }, - "description": "description", - "metadata": { - "foo": "bar" - }, - "name": "name", - "permissions": [ - "string" - ], - "predefined_role": true, - "resource_type": "resource_type", - "updated_at": 0 - } - ], - "has_more": true, - "next": "next", - "object": "list" -} -``` +- `class OrganizationUser: …` -## Assign organization role to group + Represents an individual `user` within an organization. -`admin.organization.groups.roles.create(strgroup_id, RoleCreateParams**kwargs) -> RoleCreateResponse` + - `id: str` -**post** `/organization/groups/{group_id}/roles` + The identifier, which can be referenced in API endpoints -Assigns an organization role to a group within the organization. + - `added_at: int` -### Parameters + The Unix timestamp (in seconds) of when the user was added. -- `group_id: str` + - `object: Literal["organization.user"]` -- `role_id: str` + The object type, which is always `organization.user` - Identifier of the role to assign. + - `"organization.user"` -### Returns + - `api_key_last_used_at: Optional[int]` -- `class RoleCreateResponse: …` + The Unix timestamp (in seconds) of the user's last API key usage. - Role assignment linking a group to a role. + - `created: Optional[int]` - - `group: Group` + The Unix timestamp (in seconds) of when the user was created. - Summary information about a group returned in role assignment responses. + - `developer_persona: Optional[str]` - - `id: str` + The developer persona metadata for the user. - Identifier for the group. + - `email: Optional[str]` - - `created_at: int` + The email address of the user - Unix timestamp (in seconds) when the group was created. + - `is_default: Optional[bool]` - - `name: str` + Whether this is the organization's default user. - Display name of the group. + - `is_scale_tier_authorized_purchaser: Optional[bool]` - - `object: Literal["group"]` + Whether the user is an authorized purchaser for Scale Tier. - Always `group`. + - `is_scim_managed: Optional[bool]` - - `"group"` + Whether the user is managed through SCIM. - - `scim_managed: bool` + - `is_service_account: Optional[bool]` - Whether the group is managed through SCIM. + Whether the user is a service account. - - `object: Literal["group.role"]` + - `name: Optional[str]` - Always `group.role`. + The name of the user - - `"group.role"` + - `projects: Optional[Projects]` - - `role: Role` + Projects associated with the user, if included. - Details about a role that can be assigned through the public Roles API. + - `data: List[ProjectsData]` - - `id: str` + - `id: Optional[str]` - Identifier for the role. + - `name: Optional[str]` - - `description: Optional[str]` + - `role: Optional[str]` - Optional description of the role. + - `object: Literal["list"]` - - `name: str` + - `"list"` - Unique name for the role. + - `role: Optional[str]` - - `object: Literal["role"]` + `owner` or `reader` - Always `role`. + - `technical_level: Optional[str]` - - `"role"` + The technical level metadata for the user. - - `permissions: List[str]` + - `user: Optional[User]` - Permissions granted by the role. + Nested user details. - - `predefined_role: bool` + - `id: str` - Whether the role is predefined and managed by OpenAI. + - `object: Literal["user"]` - - `resource_type: str` + - `"user"` - Resource type the role is bound to (for example `api.organization` or `api.project`). + - `banned: Optional[bool]` + + - `banned_at: Optional[int]` + + - `email: Optional[str]` + + - `enabled: Optional[bool]` + + - `name: Optional[str]` + + - `picture: Optional[str]` ### Example @@ -12105,199 +12999,2223 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -role = client.admin.organization.groups.roles.create( - group_id="group_id", - role_id="role_id", -) -print(role.group) +page = client.admin.organization.users.list() +page = page.data[0] +print(page.id) ``` #### Response ```json { - "group": { + "data": [ + { "id": "id", - "created_at": 0, + "added_at": 0, + "object": "organization.user", + "api_key_last_used_at": 0, + "created": 0, + "developer_persona": "developer_persona", + "email": "email", + "is_default": true, + "is_scale_tier_authorized_purchaser": true, + "is_scim_managed": true, + "is_service_account": true, "name": "name", - "object": "group", - "scim_managed": true - }, - "object": "group.role", - "role": { + "projects": { + "data": [ + { "id": "id", - "description": "description", "name": "name", - "object": "role", - "permissions": [ - "string" + "role": "role" + } ], - "predefined_role": true, - "resource_type": "resource_type" + "object": "list" + }, + "role": "role", + "technical_level": "technical_level", + "user": { + "id": "id", + "object": "user", + "banned": true, + "banned_at": 0, + "email": "email", + "enabled": true, + "name": "name", + "picture": "picture" } + } + ], + "has_more": true, + "object": "list", + "first_id": "first_id", + "last_id": "last_id" } ``` -## Unassign organization role from group +## Retrieve user -`admin.organization.groups.roles.delete(strrole_id, RoleDeleteParams**kwargs) -> RoleDeleteResponse` +`admin.organization.users.retrieve(struser_id) -> OrganizationUser` -**delete** `/organization/groups/{group_id}/roles/{role_id}` +**get** `/organization/users/{user_id}` -Unassigns an organization role from a group within the organization. +Retrieves a user by their identifier. ### Parameters -- `group_id: str` - -- `role_id: str` +- `user_id: str` ### Returns -- `class RoleDeleteResponse: …` - - Confirmation payload returned after unassigning a role. +- `class OrganizationUser: …` - - `deleted: bool` + Represents an individual `user` within an organization. - Whether the assignment was removed. + - `id: str` - - `object: str` + The identifier, which can be referenced in API endpoints - Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. + - `added_at: int` -### Example + The Unix timestamp (in seconds) of when the user was added. -```python -import os -from openai import OpenAI + - `object: Literal["organization.user"]` -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -role = client.admin.organization.groups.roles.delete( - role_id="role_id", - group_id="group_id", -) -print(role.deleted) -``` + The object type, which is always `organization.user` -#### Response + - `"organization.user"` -```json -{ - "deleted": true, - "object": "object" -} -``` + - `api_key_last_used_at: Optional[int]` -## Domain Types + The Unix timestamp (in seconds) of the user's last API key usage. -### Role List Response + - `created: Optional[int]` -- `class RoleListResponse: …` + The Unix timestamp (in seconds) of when the user was created. - Detailed information about a role assignment entry returned when listing assignments. + - `developer_persona: Optional[str]` - - `id: str` + The developer persona metadata for the user. - Identifier for the role. + - `email: Optional[str]` - - `created_at: Optional[int]` + The email address of the user - When the role was created. + - `is_default: Optional[bool]` - - `created_by: Optional[str]` + Whether this is the organization's default user. - Identifier of the actor who created the role. + - `is_scale_tier_authorized_purchaser: Optional[bool]` - - `created_by_user_obj: Optional[Dict[str, object]]` + Whether the user is an authorized purchaser for Scale Tier. - User details for the actor that created the role, when available. + - `is_scim_managed: Optional[bool]` - - `description: Optional[str]` + Whether the user is managed through SCIM. - Description of the role. + - `is_service_account: Optional[bool]` - - `metadata: Optional[Dict[str, object]]` + Whether the user is a service account. - Arbitrary metadata stored on the role. + - `name: Optional[str]` - - `name: str` + The name of the user - Name of the role. + - `projects: Optional[Projects]` - - `permissions: List[str]` + Projects associated with the user, if included. - Permissions associated with the role. + - `data: List[ProjectsData]` - - `predefined_role: bool` + - `id: Optional[str]` - Whether the role is predefined by OpenAI. + - `name: Optional[str]` - - `resource_type: str` + - `role: Optional[str]` - Resource type the role applies to. + - `object: Literal["list"]` - - `updated_at: Optional[int]` + - `"list"` - When the role was last updated. + - `role: Optional[str]` -### Role Create Response + `owner` or `reader` -- `class RoleCreateResponse: …` + - `technical_level: Optional[str]` - Role assignment linking a group to a role. + The technical level metadata for the user. - - `group: Group` + - `user: Optional[User]` - Summary information about a group returned in role assignment responses. + Nested user details. - `id: str` - Identifier for the group. - - - `created_at: int` - - Unix timestamp (in seconds) when the group was created. - - - `name: str` - - Display name of the group. - - - `object: Literal["group"]` - - Always `group`. - - - `"group"` - - - `scim_managed: bool` - - Whether the group is managed through SCIM. - - - `object: Literal["group.role"]` + - `object: Literal["user"]` - Always `group.role`. + - `"user"` - - `"group.role"` + - `banned: Optional[bool]` - - `role: Role` + - `banned_at: Optional[int]` - Details about a role that can be assigned through the public Roles API. + - `email: Optional[str]` - - `id: str` + - `enabled: Optional[bool]` - Identifier for the role. + - `name: Optional[str]` - - `description: Optional[str]` + - `picture: Optional[str]` - Optional description of the role. +### Example - - `name: str` +```python +import os +from openai import OpenAI - Unique name for the role. +client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted +) +organization_user = client.admin.organization.users.retrieve( + "user_id", +) +print(organization_user.id) +``` - - `object: Literal["role"]` +#### Response + +```json +{ + "id": "id", + "added_at": 0, + "object": "organization.user", + "api_key_last_used_at": 0, + "created": 0, + "developer_persona": "developer_persona", + "email": "email", + "is_default": true, + "is_scale_tier_authorized_purchaser": true, + "is_scim_managed": true, + "is_service_account": true, + "name": "name", + "projects": { + "data": [ + { + "id": "id", + "name": "name", + "role": "role" + } + ], + "object": "list" + }, + "role": "role", + "technical_level": "technical_level", + "user": { + "id": "id", + "object": "user", + "banned": true, + "banned_at": 0, + "email": "email", + "enabled": true, + "name": "name", + "picture": "picture" + } +} +``` + +## Modify user + +`admin.organization.users.update(struser_id, UserUpdateParams**kwargs) -> OrganizationUser` + +**post** `/organization/users/{user_id}` + +Modifies a user's role in the organization. + +### Parameters + +- `user_id: str` + +- `developer_persona: Optional[str]` + + Developer persona metadata. + +- `role: Optional[str]` + + `owner` or `reader` + +- `role_id: Optional[str]` + + Role ID to assign to the user. + +- `technical_level: Optional[str]` + + Technical level metadata. + +### Returns + +- `class OrganizationUser: …` + + Represents an individual `user` within an organization. + + - `id: str` + + The identifier, which can be referenced in API endpoints + + - `added_at: int` + + The Unix timestamp (in seconds) of when the user was added. + + - `object: Literal["organization.user"]` + + The object type, which is always `organization.user` + + - `"organization.user"` + + - `api_key_last_used_at: Optional[int]` + + The Unix timestamp (in seconds) of the user's last API key usage. + + - `created: Optional[int]` + + The Unix timestamp (in seconds) of when the user was created. + + - `developer_persona: Optional[str]` + + The developer persona metadata for the user. + + - `email: Optional[str]` + + The email address of the user + + - `is_default: Optional[bool]` + + Whether this is the organization's default user. + + - `is_scale_tier_authorized_purchaser: Optional[bool]` + + Whether the user is an authorized purchaser for Scale Tier. + + - `is_scim_managed: Optional[bool]` + + Whether the user is managed through SCIM. + + - `is_service_account: Optional[bool]` + + Whether the user is a service account. + + - `name: Optional[str]` + + The name of the user + + - `projects: Optional[Projects]` + + Projects associated with the user, if included. + + - `data: List[ProjectsData]` + + - `id: Optional[str]` + + - `name: Optional[str]` + + - `role: Optional[str]` + + - `object: Literal["list"]` + + - `"list"` + + - `role: Optional[str]` + + `owner` or `reader` + + - `technical_level: Optional[str]` + + The technical level metadata for the user. + + - `user: Optional[User]` + + Nested user details. + + - `id: str` + + - `object: Literal["user"]` + + - `"user"` + + - `banned: Optional[bool]` + + - `banned_at: Optional[int]` + + - `email: Optional[str]` + + - `enabled: Optional[bool]` + + - `name: Optional[str]` + + - `picture: Optional[str]` + +### Example + +```python +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 +) +organization_user = client.admin.organization.users.update( + user_id="user_id", +) +print(organization_user.id) +``` + +#### Response + +```json +{ + "id": "id", + "added_at": 0, + "object": "organization.user", + "api_key_last_used_at": 0, + "created": 0, + "developer_persona": "developer_persona", + "email": "email", + "is_default": true, + "is_scale_tier_authorized_purchaser": true, + "is_scim_managed": true, + "is_service_account": true, + "name": "name", + "projects": { + "data": [ + { + "id": "id", + "name": "name", + "role": "role" + } + ], + "object": "list" + }, + "role": "role", + "technical_level": "technical_level", + "user": { + "id": "id", + "object": "user", + "banned": true, + "banned_at": 0, + "email": "email", + "enabled": true, + "name": "name", + "picture": "picture" + } +} +``` + +## Delete user + +`admin.organization.users.delete(struser_id) -> UserDeleteResponse` + +**delete** `/organization/users/{user_id}` + +Deletes a user from the organization. + +### Parameters + +- `user_id: str` + +### Returns + +- `class UserDeleteResponse: …` + + - `id: str` + + - `deleted: bool` + + - `object: Literal["organization.user.deleted"]` + + - `"organization.user.deleted"` + +### Example + +```python +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 +) +user = client.admin.organization.users.delete( + "user_id", +) +print(user.id) +``` + +#### Response + +```json +{ + "id": "id", + "deleted": true, + "object": "organization.user.deleted" +} +``` + +## Domain Types + +### Organization User + +- `class OrganizationUser: …` + + Represents an individual `user` within an organization. + + - `id: str` + + The identifier, which can be referenced in API endpoints + + - `added_at: int` + + The Unix timestamp (in seconds) of when the user was added. + + - `object: Literal["organization.user"]` + + The object type, which is always `organization.user` + + - `"organization.user"` + + - `api_key_last_used_at: Optional[int]` + + The Unix timestamp (in seconds) of the user's last API key usage. + + - `created: Optional[int]` + + The Unix timestamp (in seconds) of when the user was created. + + - `developer_persona: Optional[str]` + + The developer persona metadata for the user. + + - `email: Optional[str]` + + The email address of the user + + - `is_default: Optional[bool]` + + Whether this is the organization's default user. + + - `is_scale_tier_authorized_purchaser: Optional[bool]` + + Whether the user is an authorized purchaser for Scale Tier. + + - `is_scim_managed: Optional[bool]` + + Whether the user is managed through SCIM. + + - `is_service_account: Optional[bool]` + + Whether the user is a service account. + + - `name: Optional[str]` + + The name of the user + + - `projects: Optional[Projects]` + + Projects associated with the user, if included. + + - `data: List[ProjectsData]` + + - `id: Optional[str]` + + - `name: Optional[str]` + + - `role: Optional[str]` + + - `object: Literal["list"]` + + - `"list"` + + - `role: Optional[str]` + + `owner` or `reader` + + - `technical_level: Optional[str]` + + The technical level metadata for the user. + + - `user: Optional[User]` + + Nested user details. + + - `id: str` + + - `object: Literal["user"]` + + - `"user"` + + - `banned: Optional[bool]` + + - `banned_at: Optional[int]` + + - `email: Optional[str]` + + - `enabled: Optional[bool]` + + - `name: Optional[str]` + + - `picture: Optional[str]` + +### User Delete Response + +- `class UserDeleteResponse: …` + + - `id: str` + + - `deleted: bool` + + - `object: Literal["organization.user.deleted"]` + + - `"organization.user.deleted"` + +# Roles + +## List user organization role assignments + +`admin.organization.users.roles.list(struser_id, RoleListParams**kwargs) -> SyncNextCursorPage[RoleListResponse]` + +**get** `/organization/users/{user_id}/roles` + +Lists the organization roles assigned to a user within the organization. + +### Parameters + +- `user_id: str` + +- `after: Optional[str]` + + Cursor for pagination. Provide the value from the previous response's `next` field to continue listing organization roles. + +- `limit: Optional[int]` + + A limit on the number of organization role assignments to return. + +- `order: Optional[Literal["asc", "desc"]]` + + Sort order for the returned organization roles. + + - `"asc"` + + - `"desc"` + +### Returns + +- `class RoleListResponse: …` + + Detailed information about a role assignment entry returned when listing assignments. + + - `id: str` + + Identifier for the role. + + - `created_at: Optional[int]` + + When the role was created. + + - `created_by: Optional[str]` + + Identifier of the actor who created the role. + + - `created_by_user_obj: Optional[Dict[str, object]]` + + User details for the actor that created the role, when available. + + - `description: Optional[str]` + + Description of the role. + + - `metadata: Optional[Dict[str, object]]` + + Arbitrary metadata stored on the role. + + - `name: str` + + Name of the role. + + - `permissions: List[str]` + + Permissions associated with the role. + + - `predefined_role: bool` + + Whether the role is predefined by OpenAI. + + - `resource_type: str` + + Resource type the role applies to. + + - `updated_at: Optional[int]` + + When the role was last updated. + +### Example + +```python +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 +) +page = client.admin.organization.users.roles.list( + user_id="user_id", +) +page = page.data[0] +print(page.id) +``` + +#### Response + +```json +{ + "data": [ + { + "id": "id", + "created_at": 0, + "created_by": "created_by", + "created_by_user_obj": { + "foo": "bar" + }, + "description": "description", + "metadata": { + "foo": "bar" + }, + "name": "name", + "permissions": [ + "string" + ], + "predefined_role": true, + "resource_type": "resource_type", + "updated_at": 0 + } + ], + "has_more": true, + "next": "next", + "object": "list" +} +``` + +## Assign organization role to user + +`admin.organization.users.roles.create(struser_id, RoleCreateParams**kwargs) -> RoleCreateResponse` + +**post** `/organization/users/{user_id}/roles` + +Assigns an organization role to a user within the organization. + +### Parameters + +- `user_id: str` + +- `role_id: str` + + Identifier of the role to assign. + +### Returns + +- `class RoleCreateResponse: …` + + Role assignment linking a user to a role. + + - `object: Literal["user.role"]` + + Always `user.role`. + + - `"user.role"` + + - `role: Role` + + Details about a role that can be assigned through the public Roles API. + + - `id: str` + + Identifier for the role. + + - `description: Optional[str]` + + Optional description of the role. + + - `name: str` + + Unique name for the role. + + - `object: Literal["role"]` + + Always `role`. + + - `"role"` + + - `permissions: List[str]` + + Permissions granted by the role. + + - `predefined_role: bool` + + Whether the role is predefined and managed by OpenAI. + + - `resource_type: str` + + Resource type the role is bound to (for example `api.organization` or `api.project`). + + - `user: OrganizationUser` + + Represents an individual `user` within an organization. + + - `id: str` + + The identifier, which can be referenced in API endpoints + + - `added_at: int` + + The Unix timestamp (in seconds) of when the user was added. + + - `object: Literal["organization.user"]` + + The object type, which is always `organization.user` + + - `"organization.user"` + + - `api_key_last_used_at: Optional[int]` + + The Unix timestamp (in seconds) of the user's last API key usage. + + - `created: Optional[int]` + + The Unix timestamp (in seconds) of when the user was created. + + - `developer_persona: Optional[str]` + + The developer persona metadata for the user. + + - `email: Optional[str]` + + The email address of the user + + - `is_default: Optional[bool]` + + Whether this is the organization's default user. + + - `is_scale_tier_authorized_purchaser: Optional[bool]` + + Whether the user is an authorized purchaser for Scale Tier. + + - `is_scim_managed: Optional[bool]` + + Whether the user is managed through SCIM. + + - `is_service_account: Optional[bool]` + + Whether the user is a service account. + + - `name: Optional[str]` + + The name of the user + + - `projects: Optional[Projects]` + + Projects associated with the user, if included. + + - `data: List[ProjectsData]` + + - `id: Optional[str]` + + - `name: Optional[str]` + + - `role: Optional[str]` + + - `object: Literal["list"]` + + - `"list"` + + - `role: Optional[str]` + + `owner` or `reader` + + - `technical_level: Optional[str]` + + The technical level metadata for the user. + + - `user: Optional[User]` + + Nested user details. + + - `id: str` + + - `object: Literal["user"]` + + - `"user"` + + - `banned: Optional[bool]` + + - `banned_at: Optional[int]` + + - `email: Optional[str]` + + - `enabled: Optional[bool]` + + - `name: Optional[str]` + + - `picture: Optional[str]` + +### Example + +```python +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 +) +role = client.admin.organization.users.roles.create( + user_id="user_id", + role_id="role_id", +) +print(role.object) +``` + +#### Response + +```json +{ + "object": "user.role", + "role": { + "id": "id", + "description": "description", + "name": "name", + "object": "role", + "permissions": [ + "string" + ], + "predefined_role": true, + "resource_type": "resource_type" + }, + "user": { + "id": "id", + "added_at": 0, + "object": "organization.user", + "api_key_last_used_at": 0, + "created": 0, + "developer_persona": "developer_persona", + "email": "email", + "is_default": true, + "is_scale_tier_authorized_purchaser": true, + "is_scim_managed": true, + "is_service_account": true, + "name": "name", + "projects": { + "data": [ + { + "id": "id", + "name": "name", + "role": "role" + } + ], + "object": "list" + }, + "role": "role", + "technical_level": "technical_level", + "user": { + "id": "id", + "object": "user", + "banned": true, + "banned_at": 0, + "email": "email", + "enabled": true, + "name": "name", + "picture": "picture" + } + } +} +``` + +## Unassign organization role from user + +`admin.organization.users.roles.delete(strrole_id, RoleDeleteParams**kwargs) -> RoleDeleteResponse` + +**delete** `/organization/users/{user_id}/roles/{role_id}` + +Unassigns an organization role from a user within the organization. + +### Parameters + +- `user_id: str` + +- `role_id: str` + +### Returns + +- `class RoleDeleteResponse: …` + + Confirmation payload returned after unassigning a role. + + - `deleted: bool` + + Whether the assignment was removed. + + - `object: str` + + Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. + +### Example + +```python +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 +) +role = client.admin.organization.users.roles.delete( + role_id="role_id", + user_id="user_id", +) +print(role.deleted) +``` + +#### Response + +```json +{ + "deleted": true, + "object": "object" +} +``` + +## Domain Types + +### Role List Response + +- `class RoleListResponse: …` + + Detailed information about a role assignment entry returned when listing assignments. + + - `id: str` + + Identifier for the role. + + - `created_at: Optional[int]` + + When the role was created. + + - `created_by: Optional[str]` + + Identifier of the actor who created the role. + + - `created_by_user_obj: Optional[Dict[str, object]]` + + User details for the actor that created the role, when available. + + - `description: Optional[str]` + + Description of the role. + + - `metadata: Optional[Dict[str, object]]` + + Arbitrary metadata stored on the role. + + - `name: str` + + Name of the role. + + - `permissions: List[str]` + + Permissions associated with the role. + + - `predefined_role: bool` + + Whether the role is predefined by OpenAI. + + - `resource_type: str` + + Resource type the role applies to. + + - `updated_at: Optional[int]` + + When the role was last updated. + +### Role Create Response + +- `class RoleCreateResponse: …` + + Role assignment linking a user to a role. + + - `object: Literal["user.role"]` + + Always `user.role`. + + - `"user.role"` + + - `role: Role` + + Details about a role that can be assigned through the public Roles API. + + - `id: str` + + Identifier for the role. + + - `description: Optional[str]` + + Optional description of the role. + + - `name: str` + + Unique name for the role. + + - `object: Literal["role"]` + + Always `role`. + + - `"role"` + + - `permissions: List[str]` + + Permissions granted by the role. + + - `predefined_role: bool` + + Whether the role is predefined and managed by OpenAI. + + - `resource_type: str` + + Resource type the role is bound to (for example `api.organization` or `api.project`). + + - `user: OrganizationUser` + + Represents an individual `user` within an organization. + + - `id: str` + + The identifier, which can be referenced in API endpoints + + - `added_at: int` + + The Unix timestamp (in seconds) of when the user was added. + + - `object: Literal["organization.user"]` + + The object type, which is always `organization.user` + + - `"organization.user"` + + - `api_key_last_used_at: Optional[int]` + + The Unix timestamp (in seconds) of the user's last API key usage. + + - `created: Optional[int]` + + The Unix timestamp (in seconds) of when the user was created. + + - `developer_persona: Optional[str]` + + The developer persona metadata for the user. + + - `email: Optional[str]` + + The email address of the user + + - `is_default: Optional[bool]` + + Whether this is the organization's default user. + + - `is_scale_tier_authorized_purchaser: Optional[bool]` + + Whether the user is an authorized purchaser for Scale Tier. + + - `is_scim_managed: Optional[bool]` + + Whether the user is managed through SCIM. + + - `is_service_account: Optional[bool]` + + Whether the user is a service account. + + - `name: Optional[str]` + + The name of the user + + - `projects: Optional[Projects]` + + Projects associated with the user, if included. + + - `data: List[ProjectsData]` + + - `id: Optional[str]` + + - `name: Optional[str]` + + - `role: Optional[str]` + + - `object: Literal["list"]` + + - `"list"` + + - `role: Optional[str]` + + `owner` or `reader` + + - `technical_level: Optional[str]` + + The technical level metadata for the user. + + - `user: Optional[User]` + + Nested user details. + + - `id: str` + + - `object: Literal["user"]` + + - `"user"` + + - `banned: Optional[bool]` + + - `banned_at: Optional[int]` + + - `email: Optional[str]` + + - `enabled: Optional[bool]` + + - `name: Optional[str]` + + - `picture: Optional[str]` + +### Role Delete Response + +- `class RoleDeleteResponse: …` + + Confirmation payload returned after unassigning a role. + + - `deleted: bool` + + Whether the assignment was removed. + + - `object: str` + + Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. + +# Groups + +## List groups + +`admin.organization.groups.list(GroupListParams**kwargs) -> SyncNextCursorPage[Group]` + +**get** `/organization/groups` + +Lists all groups in the organization. + +### Parameters + +- `after: Optional[str]` + + A cursor for use in pagination. `after` is a group ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with group_abc, your subsequent call can include `after=group_abc` in order to fetch the next page of the list. + +- `limit: Optional[int]` + + A limit on the number of groups to be returned. Limit can range between 0 and 1000, and the default is 100. + +- `order: Optional[Literal["asc", "desc"]]` + + Specifies the sort order of the returned groups. + + - `"asc"` + + - `"desc"` + +### Returns + +- `class Group: …` + + Details about an organization group. + + - `id: str` + + Identifier for the group. + + - `created_at: int` + + Unix timestamp (in seconds) when the group was created. + + - `group_type: str` + + The type of the group. + + - `is_scim_managed: bool` + + Whether the group is managed through SCIM and controlled by your identity provider. + + - `name: str` + + Display name of the group. + +### Example + +```python +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 +) +page = client.admin.organization.groups.list() +page = page.data[0] +print(page.id) +``` + +#### Response + +```json +{ + "data": [ + { + "id": "id", + "created_at": 0, + "group_type": "group_type", + "is_scim_managed": true, + "name": "name" + } + ], + "has_more": true, + "next": "next", + "object": "list" +} +``` + +## Create group + +`admin.organization.groups.create(GroupCreateParams**kwargs) -> Group` + +**post** `/organization/groups` + +Creates a new group in the organization. + +### Parameters + +- `name: str` + + Human readable name for the group. + +### Returns + +- `class Group: …` + + Details about an organization group. + + - `id: str` + + Identifier for the group. + + - `created_at: int` + + Unix timestamp (in seconds) when the group was created. + + - `group_type: str` + + The type of the group. + + - `is_scim_managed: bool` + + Whether the group is managed through SCIM and controlled by your identity provider. + + - `name: str` + + Display name of the group. + +### Example + +```python +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 +) +group = client.admin.organization.groups.create( + name="x", +) +print(group.id) +``` + +#### Response + +```json +{ + "id": "id", + "created_at": 0, + "group_type": "group_type", + "is_scim_managed": true, + "name": "name" +} +``` + +## Update group + +`admin.organization.groups.update(strgroup_id, GroupUpdateParams**kwargs) -> GroupUpdateResponse` + +**post** `/organization/groups/{group_id}` + +Updates a group's information. + +### Parameters + +- `group_id: str` + +- `name: str` + + New display name for the group. + +### Returns + +- `class GroupUpdateResponse: …` + + Response returned after updating a group. + + - `id: str` + + Identifier for the group. + + - `created_at: int` + + Unix timestamp (in seconds) when the group was created. + + - `is_scim_managed: bool` + + Whether the group is managed through SCIM and controlled by your identity provider. + + - `name: str` + + Updated display name for the group. + +### Example + +```python +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 +) +group = client.admin.organization.groups.update( + group_id="group_id", + name="x", +) +print(group.id) +``` + +#### Response + +```json +{ + "id": "id", + "created_at": 0, + "is_scim_managed": true, + "name": "name" +} +``` + +## Delete group + +`admin.organization.groups.delete(strgroup_id) -> GroupDeleteResponse` + +**delete** `/organization/groups/{group_id}` + +Deletes a group from the organization. + +### Parameters + +- `group_id: str` + +### Returns + +- `class GroupDeleteResponse: …` + + Confirmation payload returned after deleting a group. + + - `id: str` + + Identifier of the deleted group. + + - `deleted: bool` + + Whether the group was deleted. + + - `object: Literal["group.deleted"]` + + Always `group.deleted`. + + - `"group.deleted"` + +### Example + +```python +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 +) +group = client.admin.organization.groups.delete( + "group_id", +) +print(group.id) +``` + +#### Response + +```json +{ + "id": "id", + "deleted": true, + "object": "group.deleted" +} +``` + +## Domain Types + +### Group + +- `class Group: …` + + Details about an organization group. + + - `id: str` + + Identifier for the group. + + - `created_at: int` + + Unix timestamp (in seconds) when the group was created. + + - `group_type: str` + + The type of the group. + + - `is_scim_managed: bool` + + Whether the group is managed through SCIM and controlled by your identity provider. + + - `name: str` + + Display name of the group. + +### Group Update Response + +- `class GroupUpdateResponse: …` + + Response returned after updating a group. + + - `id: str` + + Identifier for the group. + + - `created_at: int` + + Unix timestamp (in seconds) when the group was created. + + - `is_scim_managed: bool` + + Whether the group is managed through SCIM and controlled by your identity provider. + + - `name: str` + + Updated display name for the group. + +### Group Delete Response + +- `class GroupDeleteResponse: …` + + Confirmation payload returned after deleting a group. + + - `id: str` + + Identifier of the deleted group. + + - `deleted: bool` + + Whether the group was deleted. + + - `object: Literal["group.deleted"]` + + Always `group.deleted`. + + - `"group.deleted"` + +# Users + +## List group users + +`admin.organization.groups.users.list(strgroup_id, UserListParams**kwargs) -> SyncNextCursorPage[OrganizationGroupUser]` + +**get** `/organization/groups/{group_id}/users` + +Lists the users assigned to a group. + +### Parameters + +- `group_id: str` + +- `after: Optional[str]` + + A cursor for use in pagination. Provide the ID of the last user from the previous list response to retrieve the next page. + +- `limit: Optional[int]` + + A limit on the number of users to be returned. Limit can range between 0 and 1000, and the default is 100. + +- `order: Optional[Literal["asc", "desc"]]` + + Specifies the sort order of users in the list. + + - `"asc"` + + - `"desc"` + +### Returns + +- `class OrganizationGroupUser: …` + + Represents an individual user returned when inspecting group membership. + + - `id: str` + + The identifier, which can be referenced in API endpoints + + - `email: Optional[str]` + + The email address of the user. + + - `name: str` + + The name of the user. + +### Example + +```python +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 +) +page = client.admin.organization.groups.users.list( + group_id="group_id", +) +page = page.data[0] +print(page.id) +``` + +#### Response + +```json +{ + "data": [ + { + "id": "id", + "email": "email", + "name": "name" + } + ], + "has_more": true, + "next": "next", + "object": "list" +} +``` + +## Add group user + +`admin.organization.groups.users.create(strgroup_id, UserCreateParams**kwargs) -> UserCreateResponse` + +**post** `/organization/groups/{group_id}/users` + +Adds a user to a group. + +### Parameters + +- `group_id: str` + +- `user_id: str` + + Identifier of the user to add to the group. + +### Returns + +- `class UserCreateResponse: …` + + Confirmation payload returned after adding a user to a group. + + - `group_id: str` + + Identifier of the group the user was added to. + + - `object: Literal["group.user"]` + + Always `group.user`. + + - `"group.user"` + + - `user_id: str` + + Identifier of the user that was added. + +### Example + +```python +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 +) +user = client.admin.organization.groups.users.create( + group_id="group_id", + user_id="user_id", +) +print(user.group_id) +``` + +#### Response + +```json +{ + "group_id": "group_id", + "object": "group.user", + "user_id": "user_id" +} +``` + +## Remove group user + +`admin.organization.groups.users.delete(struser_id, UserDeleteParams**kwargs) -> UserDeleteResponse` + +**delete** `/organization/groups/{group_id}/users/{user_id}` + +Removes a user from a group. + +### Parameters + +- `group_id: str` + +- `user_id: str` + +### Returns + +- `class UserDeleteResponse: …` + + Confirmation payload returned after removing a user from a group. + + - `deleted: bool` + + Whether the group membership was removed. + + - `object: Literal["group.user.deleted"]` + + Always `group.user.deleted`. + + - `"group.user.deleted"` + +### Example + +```python +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 +) +user = client.admin.organization.groups.users.delete( + user_id="user_id", + group_id="group_id", +) +print(user.deleted) +``` + +#### Response + +```json +{ + "deleted": true, + "object": "group.user.deleted" +} +``` + +## Domain Types + +### Organization Group User + +- `class OrganizationGroupUser: …` + + Represents an individual user returned when inspecting group membership. + + - `id: str` + + The identifier, which can be referenced in API endpoints + + - `email: Optional[str]` + + The email address of the user. + + - `name: str` + + The name of the user. + +### User Create Response + +- `class UserCreateResponse: …` + + Confirmation payload returned after adding a user to a group. + + - `group_id: str` + + Identifier of the group the user was added to. + + - `object: Literal["group.user"]` + + Always `group.user`. + + - `"group.user"` + + - `user_id: str` + + Identifier of the user that was added. + +### User Delete Response + +- `class UserDeleteResponse: …` + + Confirmation payload returned after removing a user from a group. + + - `deleted: bool` + + Whether the group membership was removed. + + - `object: Literal["group.user.deleted"]` + + Always `group.user.deleted`. + + - `"group.user.deleted"` + +# Roles + +## List group organization role assignments + +`admin.organization.groups.roles.list(strgroup_id, RoleListParams**kwargs) -> SyncNextCursorPage[RoleListResponse]` + +**get** `/organization/groups/{group_id}/roles` + +Lists the organization roles assigned to a group within the organization. + +### Parameters + +- `group_id: str` + +- `after: Optional[str]` + + Cursor for pagination. Provide the value from the previous response's `next` field to continue listing organization roles. + +- `limit: Optional[int]` + + A limit on the number of organization role assignments to return. + +- `order: Optional[Literal["asc", "desc"]]` + + Sort order for the returned organization roles. + + - `"asc"` + + - `"desc"` + +### Returns + +- `class RoleListResponse: …` + + Detailed information about a role assignment entry returned when listing assignments. + + - `id: str` + + Identifier for the role. + + - `created_at: Optional[int]` + + When the role was created. + + - `created_by: Optional[str]` + + Identifier of the actor who created the role. + + - `created_by_user_obj: Optional[Dict[str, object]]` + + User details for the actor that created the role, when available. + + - `description: Optional[str]` + + Description of the role. + + - `metadata: Optional[Dict[str, object]]` + + Arbitrary metadata stored on the role. + + - `name: str` + + Name of the role. + + - `permissions: List[str]` + + Permissions associated with the role. + + - `predefined_role: bool` + + Whether the role is predefined by OpenAI. + + - `resource_type: str` + + Resource type the role applies to. + + - `updated_at: Optional[int]` + + When the role was last updated. + +### Example + +```python +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 +) +page = client.admin.organization.groups.roles.list( + group_id="group_id", +) +page = page.data[0] +print(page.id) +``` + +#### Response + +```json +{ + "data": [ + { + "id": "id", + "created_at": 0, + "created_by": "created_by", + "created_by_user_obj": { + "foo": "bar" + }, + "description": "description", + "metadata": { + "foo": "bar" + }, + "name": "name", + "permissions": [ + "string" + ], + "predefined_role": true, + "resource_type": "resource_type", + "updated_at": 0 + } + ], + "has_more": true, + "next": "next", + "object": "list" +} +``` + +## Assign organization role to group + +`admin.organization.groups.roles.create(strgroup_id, RoleCreateParams**kwargs) -> RoleCreateResponse` + +**post** `/organization/groups/{group_id}/roles` + +Assigns an organization role to a group within the organization. + +### Parameters + +- `group_id: str` + +- `role_id: str` + + Identifier of the role to assign. + +### Returns + +- `class RoleCreateResponse: …` + + Role assignment linking a group to a role. + + - `group: Group` + + Summary information about a group returned in role assignment responses. + + - `id: str` + + Identifier for the group. + + - `created_at: int` + + Unix timestamp (in seconds) when the group was created. + + - `name: str` + + Display name of the group. + + - `object: Literal["group"]` + + Always `group`. + + - `"group"` + + - `scim_managed: bool` + + Whether the group is managed through SCIM. + + - `object: Literal["group.role"]` + + Always `group.role`. + + - `"group.role"` + + - `role: Role` + + Details about a role that can be assigned through the public Roles API. + + - `id: str` + + Identifier for the role. + + - `description: Optional[str]` + + Optional description of the role. + + - `name: str` + + Unique name for the role. + + - `object: Literal["role"]` + + Always `role`. + + - `"role"` + + - `permissions: List[str]` + + Permissions granted by the role. + + - `predefined_role: bool` + + Whether the role is predefined and managed by OpenAI. + + - `resource_type: str` + + Resource type the role is bound to (for example `api.organization` or `api.project`). + +### Example + +```python +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 +) +role = client.admin.organization.groups.roles.create( + group_id="group_id", + role_id="role_id", +) +print(role.group) +``` + +#### Response + +```json +{ + "group": { + "id": "id", + "created_at": 0, + "name": "name", + "object": "group", + "scim_managed": true + }, + "object": "group.role", + "role": { + "id": "id", + "description": "description", + "name": "name", + "object": "role", + "permissions": [ + "string" + ], + "predefined_role": true, + "resource_type": "resource_type" + } +} +``` + +## Unassign organization role from group + +`admin.organization.groups.roles.delete(strrole_id, RoleDeleteParams**kwargs) -> RoleDeleteResponse` + +**delete** `/organization/groups/{group_id}/roles/{role_id}` + +Unassigns an organization role from a group within the organization. + +### Parameters + +- `group_id: str` + +- `role_id: str` + +### Returns + +- `class RoleDeleteResponse: …` + + Confirmation payload returned after unassigning a role. + + - `deleted: bool` + + Whether the assignment was removed. + + - `object: str` + + Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. + +### Example + +```python +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 +) +role = client.admin.organization.groups.roles.delete( + role_id="role_id", + group_id="group_id", +) +print(role.deleted) +``` + +#### Response + +```json +{ + "deleted": true, + "object": "object" +} +``` + +## Domain Types + +### Role List Response + +- `class RoleListResponse: …` + + Detailed information about a role assignment entry returned when listing assignments. + + - `id: str` + + Identifier for the role. + + - `created_at: Optional[int]` + + When the role was created. + + - `created_by: Optional[str]` + + Identifier of the actor who created the role. + + - `created_by_user_obj: Optional[Dict[str, object]]` + + User details for the actor that created the role, when available. + + - `description: Optional[str]` + + Description of the role. + + - `metadata: Optional[Dict[str, object]]` + + Arbitrary metadata stored on the role. + + - `name: str` + + Name of the role. + + - `permissions: List[str]` + + Permissions associated with the role. + + - `predefined_role: bool` + + Whether the role is predefined by OpenAI. + + - `resource_type: str` + + Resource type the role applies to. + + - `updated_at: Optional[int]` + + When the role was last updated. + +### Role Create Response + +- `class RoleCreateResponse: …` + + Role assignment linking a group to a role. + + - `group: Group` + + Summary information about a group returned in role assignment responses. + + - `id: str` + + Identifier for the group. + + - `created_at: int` + + Unix timestamp (in seconds) when the group was created. + + - `name: str` + + Display name of the group. + + - `object: Literal["group"]` + + Always `group`. + + - `"group"` + + - `scim_managed: bool` + + Whether the group is managed through SCIM. + + - `object: Literal["group.role"]` + + Always `group.role`. + + - `"group.role"` + + - `role: Role` + + Details about a role that can be assigned through the public Roles API. + + - `id: str` + + Identifier for the role. + + - `description: Optional[str]` + + Optional description of the role. + + - `name: str` + + Unique name for the role. + + - `object: Literal["role"]` Always `role`. @@ -14014,19 +16932,266 @@ print(project.id) **get** `/organization/projects/{project_id}/users` -Returns a list of users in the project. +Returns a list of users in the project. + +### Parameters + +- `project_id: str` + +- `after: Optional[str]` + + A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + +- `limit: Optional[int]` + + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + +### Returns + +- `class ProjectUser: …` + + Represents an individual user in a project. + + - `id: str` + + The identifier, which can be referenced in API endpoints + + - `added_at: int` + + The Unix timestamp (in seconds) of when the project was added. + + - `object: Literal["organization.project.user"]` + + The object type, which is always `organization.project.user` + + - `"organization.project.user"` + + - `role: str` + + `owner` or `member` + + - `email: Optional[str]` + + The email address of the user + + - `name: Optional[str]` + + The name of the user + +### Example + +```python +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 +) +page = client.admin.organization.projects.users.list( + project_id="project_id", +) +page = page.data[0] +print(page.id) +``` + +#### Response + +```json +{ + "data": [ + { + "id": "id", + "added_at": 0, + "object": "organization.project.user", + "role": "role", + "email": "email", + "name": "name" + } + ], + "has_more": true, + "object": "object", + "first_id": "first_id", + "last_id": "last_id" +} +``` + +## Create project user + +`admin.organization.projects.users.create(strproject_id, UserCreateParams**kwargs) -> ProjectUser` + +**post** `/organization/projects/{project_id}/users` + +Adds a user to the project. Users must already be members of the organization to be added to a project. + +### Parameters + +- `project_id: str` + +- `role: str` + + `owner` or `member` + +- `email: Optional[str]` + + Email of the user to add. + +- `user_id: Optional[str]` + + The ID of the user. + +### Returns + +- `class ProjectUser: …` + + Represents an individual user in a project. + + - `id: str` + + The identifier, which can be referenced in API endpoints + + - `added_at: int` + + The Unix timestamp (in seconds) of when the project was added. + + - `object: Literal["organization.project.user"]` + + The object type, which is always `organization.project.user` + + - `"organization.project.user"` + + - `role: str` + + `owner` or `member` + + - `email: Optional[str]` + + The email address of the user + + - `name: Optional[str]` + + The name of the user + +### Example + +```python +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 +) +project_user = client.admin.organization.projects.users.create( + project_id="project_id", + role="role", +) +print(project_user.id) +``` + +#### Response + +```json +{ + "id": "id", + "added_at": 0, + "object": "organization.project.user", + "role": "role", + "email": "email", + "name": "name" +} +``` + +## Retrieve project user + +`admin.organization.projects.users.retrieve(struser_id, UserRetrieveParams**kwargs) -> ProjectUser` + +**get** `/organization/projects/{project_id}/users/{user_id}` + +Retrieves a user in the project. + +### Parameters + +- `project_id: str` + +- `user_id: str` + +### Returns + +- `class ProjectUser: …` + + Represents an individual user in a project. + + - `id: str` + + The identifier, which can be referenced in API endpoints + + - `added_at: int` + + The Unix timestamp (in seconds) of when the project was added. + + - `object: Literal["organization.project.user"]` + + The object type, which is always `organization.project.user` + + - `"organization.project.user"` + + - `role: str` + + `owner` or `member` + + - `email: Optional[str]` + + The email address of the user + + - `name: Optional[str]` + + The name of the user + +### Example + +```python +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 +) +project_user = client.admin.organization.projects.users.retrieve( + user_id="user_id", + project_id="project_id", +) +print(project_user.id) +``` + +#### Response + +```json +{ + "id": "id", + "added_at": 0, + "object": "organization.project.user", + "role": "role", + "email": "email", + "name": "name" +} +``` + +## Modify project user + +`admin.organization.projects.users.update(struser_id, UserUpdateParams**kwargs) -> ProjectUser` + +**post** `/organization/projects/{project_id}/users/{user_id}` + +Modifies a user's role in the project. ### Parameters - `project_id: str` -- `after: Optional[str]` - - A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. +- `user_id: str` -- `limit: Optional[int]` +- `role: Optional[str]` - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + `owner` or `member` ### Returns @@ -14069,59 +17234,84 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -page = client.admin.organization.projects.users.list( +project_user = client.admin.organization.projects.users.update( + user_id="user_id", project_id="project_id", ) -page = page.data[0] -print(page.id) +print(project_user.id) ``` #### Response ```json { - "data": [ - { "id": "id", "added_at": 0, "object": "organization.project.user", "role": "role", "email": "email", "name": "name" - } - ], - "has_more": true, - "object": "object", - "first_id": "first_id", - "last_id": "last_id" } ``` -## Create project user +## Delete project user -`admin.organization.projects.users.create(strproject_id, UserCreateParams**kwargs) -> ProjectUser` +`admin.organization.projects.users.delete(struser_id, UserDeleteParams**kwargs) -> UserDeleteResponse` -**post** `/organization/projects/{project_id}/users` +**delete** `/organization/projects/{project_id}/users/{user_id}` -Adds a user to the project. Users must already be members of the organization to be added to a project. +Deletes a user from the project. + +Returns confirmation of project user deletion, or an error if the project is +archived (archived projects have no users). ### Parameters - `project_id: str` -- `role: str` +- `user_id: str` - `owner` or `member` +### Returns -- `email: Optional[str]` +- `class UserDeleteResponse: …` - Email of the user to add. + - `id: str` -- `user_id: Optional[str]` + - `deleted: bool` - The ID of the user. + - `object: Literal["organization.project.user.deleted"]` -### Returns + - `"organization.project.user.deleted"` + +### Example + +```python +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 +) +user = client.admin.organization.projects.users.delete( + user_id="user_id", + project_id="project_id", +) +print(user.id) +``` + +#### Response + +```json +{ + "id": "id", + "deleted": true, + "object": "organization.project.user.deleted" +} +``` + +## Domain Types + +### Project User - `class ProjectUser: …` @@ -14153,42 +17343,27 @@ Adds a user to the project. Users must already be members of the organization to The name of the user -### Example +### User Delete Response -```python -import os -from openai import OpenAI +- `class UserDeleteResponse: …` -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -project_user = client.admin.organization.projects.users.create( - project_id="project_id", - role="role", -) -print(project_user.id) -``` + - `id: str` -#### Response + - `deleted: bool` -```json -{ - "id": "id", - "added_at": 0, - "object": "organization.project.user", - "role": "role", - "email": "email", - "name": "name" -} -``` + - `object: Literal["organization.project.user.deleted"]` -## Retrieve project user + - `"organization.project.user.deleted"` -`admin.organization.projects.users.retrieve(struser_id, UserRetrieveParams**kwargs) -> ProjectUser` +# Roles -**get** `/organization/projects/{project_id}/users/{user_id}` +## List project user role assignments -Retrieves a user in the project. +`admin.organization.projects.users.roles.list(struser_id, RoleListParams**kwargs) -> SyncNextCursorPage[RoleListResponse]` + +**get** `/projects/{project_id}/users/{user_id}/roles` + +Lists the project roles assigned to a user within a project. ### Parameters @@ -14196,37 +17371,71 @@ Retrieves a user in the project. - `user_id: str` +- `after: Optional[str]` + + Cursor for pagination. Provide the value from the previous response's `next` field to continue listing project roles. + +- `limit: Optional[int]` + + A limit on the number of project role assignments to return. + +- `order: Optional[Literal["asc", "desc"]]` + + Sort order for the returned project roles. + + - `"asc"` + + - `"desc"` + ### Returns -- `class ProjectUser: …` +- `class RoleListResponse: …` - Represents an individual user in a project. + Detailed information about a role assignment entry returned when listing assignments. - `id: str` - The identifier, which can be referenced in API endpoints + Identifier for the role. - - `added_at: int` + - `created_at: Optional[int]` - The Unix timestamp (in seconds) of when the project was added. + When the role was created. - - `object: Literal["organization.project.user"]` + - `created_by: Optional[str]` - The object type, which is always `organization.project.user` + Identifier of the actor who created the role. - - `"organization.project.user"` + - `created_by_user_obj: Optional[Dict[str, object]]` - - `role: str` + User details for the actor that created the role, when available. - `owner` or `member` + - `description: Optional[str]` - - `email: Optional[str]` + Description of the role. - The email address of the user + - `metadata: Optional[Dict[str, object]]` - - `name: Optional[str]` + Arbitrary metadata stored on the role. - The name of the user + - `name: str` + + Name of the role. + + - `permissions: List[str]` + + Permissions associated with the role. + + - `predefined_role: bool` + + Whether the role is predefined by OpenAI. + + - `resource_type: str` + + Resource type the role applies to. + + - `updated_at: Optional[int]` + + When the role was last updated. ### Example @@ -14237,49 +17446,112 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -project_user = client.admin.organization.projects.users.retrieve( +page = client.admin.organization.projects.users.roles.list( user_id="user_id", project_id="project_id", ) -print(project_user.id) +page = page.data[0] +print(page.id) +``` + +#### Response + +```json +{ + "data": [ + { + "id": "id", + "created_at": 0, + "created_by": "created_by", + "created_by_user_obj": { + "foo": "bar" + }, + "description": "description", + "metadata": { + "foo": "bar" + }, + "name": "name", + "permissions": [ + "string" + ], + "predefined_role": true, + "resource_type": "resource_type", + "updated_at": 0 + } + ], + "has_more": true, + "next": "next", + "object": "list" +} ``` -#### Response +## Assign project role to user + +`admin.organization.projects.users.roles.create(struser_id, RoleCreateParams**kwargs) -> RoleCreateResponse` + +**post** `/projects/{project_id}/users/{user_id}/roles` + +Assigns a project role to a user within a project. + +### Parameters + +- `project_id: str` + +- `user_id: str` + +- `role_id: str` + + Identifier of the role to assign. + +### Returns + +- `class RoleCreateResponse: …` + + Role assignment linking a user to a role. + + - `object: Literal["user.role"]` + + Always `user.role`. + + - `"user.role"` + + - `role: Role` + + Details about a role that can be assigned through the public Roles API. + + - `id: str` + + Identifier for the role. + + - `description: Optional[str]` -```json -{ - "id": "id", - "added_at": 0, - "object": "organization.project.user", - "role": "role", - "email": "email", - "name": "name" -} -``` + Optional description of the role. -## Modify project user + - `name: str` -`admin.organization.projects.users.update(struser_id, UserUpdateParams**kwargs) -> ProjectUser` + Unique name for the role. -**post** `/organization/projects/{project_id}/users/{user_id}` + - `object: Literal["role"]` -Modifies a user's role in the project. + Always `role`. -### Parameters + - `"role"` -- `project_id: str` + - `permissions: List[str]` -- `user_id: str` + Permissions granted by the role. -- `role: Optional[str]` + - `predefined_role: bool` - `owner` or `member` + Whether the role is predefined and managed by OpenAI. -### Returns + - `resource_type: str` -- `class ProjectUser: …` + Resource type the role is bound to (for example `api.organization` or `api.project`). - Represents an individual user in a project. + - `user: OrganizationUser` + + Represents an individual `user` within an organization. - `id: str` @@ -14287,83 +17559,95 @@ Modifies a user's role in the project. - `added_at: int` - The Unix timestamp (in seconds) of when the project was added. + The Unix timestamp (in seconds) of when the user was added. - - `object: Literal["organization.project.user"]` + - `object: Literal["organization.user"]` - The object type, which is always `organization.project.user` + The object type, which is always `organization.user` - - `"organization.project.user"` + - `"organization.user"` - - `role: str` + - `api_key_last_used_at: Optional[int]` - `owner` or `member` + The Unix timestamp (in seconds) of the user's last API key usage. + + - `created: Optional[int]` + + The Unix timestamp (in seconds) of when the user was created. + + - `developer_persona: Optional[str]` + + The developer persona metadata for the user. - `email: Optional[str]` The email address of the user + - `is_default: Optional[bool]` + + Whether this is the organization's default user. + + - `is_scale_tier_authorized_purchaser: Optional[bool]` + + Whether the user is an authorized purchaser for Scale Tier. + + - `is_scim_managed: Optional[bool]` + + Whether the user is managed through SCIM. + + - `is_service_account: Optional[bool]` + + Whether the user is a service account. + - `name: Optional[str]` The name of the user -### Example - -```python -import os -from openai import OpenAI + - `projects: Optional[Projects]` -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -project_user = client.admin.organization.projects.users.update( - user_id="user_id", - project_id="project_id", -) -print(project_user.id) -``` + Projects associated with the user, if included. -#### Response + - `data: List[ProjectsData]` -```json -{ - "id": "id", - "added_at": 0, - "object": "organization.project.user", - "role": "role", - "email": "email", - "name": "name" -} -``` + - `id: Optional[str]` -## Delete project user + - `name: Optional[str]` -`admin.organization.projects.users.delete(struser_id, UserDeleteParams**kwargs) -> UserDeleteResponse` + - `role: Optional[str]` -**delete** `/organization/projects/{project_id}/users/{user_id}` + - `object: Literal["list"]` -Deletes a user from the project. + - `"list"` -Returns confirmation of project user deletion, or an error if the project is -archived (archived projects have no users). + - `role: Optional[str]` -### Parameters + `owner` or `reader` -- `project_id: str` + - `technical_level: Optional[str]` -- `user_id: str` + The technical level metadata for the user. -### Returns + - `user: Optional[User]` -- `class UserDeleteResponse: …` + Nested user details. - `id: str` - - `deleted: bool` + - `object: Literal["user"]` - - `object: Literal["organization.project.user.deleted"]` + - `"user"` - - `"organization.project.user.deleted"` + - `banned: Optional[bool]` + + - `banned_at: Optional[int]` + + - `email: Optional[str]` + + - `enabled: Optional[bool]` + + - `name: Optional[str]` + + - `picture: Optional[str]` ### Example @@ -14374,102 +17658,128 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -user = client.admin.organization.projects.users.delete( +role = client.admin.organization.projects.users.roles.create( user_id="user_id", project_id="project_id", + role_id="role_id", ) -print(user.id) +print(role.object) ``` #### Response ```json { + "object": "user.role", + "role": { "id": "id", - "deleted": true, - "object": "organization.project.user.deleted" + "description": "description", + "name": "name", + "object": "role", + "permissions": [ + "string" + ], + "predefined_role": true, + "resource_type": "resource_type" + }, + "user": { + "id": "id", + "added_at": 0, + "object": "organization.user", + "api_key_last_used_at": 0, + "created": 0, + "developer_persona": "developer_persona", + "email": "email", + "is_default": true, + "is_scale_tier_authorized_purchaser": true, + "is_scim_managed": true, + "is_service_account": true, + "name": "name", + "projects": { + "data": [ + { + "id": "id", + "name": "name", + "role": "role" + } + ], + "object": "list" + }, + "role": "role", + "technical_level": "technical_level", + "user": { + "id": "id", + "object": "user", + "banned": true, + "banned_at": 0, + "email": "email", + "enabled": true, + "name": "name", + "picture": "picture" + } + } } ``` -## Domain Types - -### Project User - -- `class ProjectUser: …` - - Represents an individual user in a project. - - - `id: str` - - The identifier, which can be referenced in API endpoints - - - `added_at: int` - - The Unix timestamp (in seconds) of when the project was added. - - - `object: Literal["organization.project.user"]` - - The object type, which is always `organization.project.user` +## Unassign project role from user - - `"organization.project.user"` +`admin.organization.projects.users.roles.delete(strrole_id, RoleDeleteParams**kwargs) -> RoleDeleteResponse` - - `role: str` +**delete** `/projects/{project_id}/users/{user_id}/roles/{role_id}` - `owner` or `member` +Unassigns a project role from a user within a project. - - `email: Optional[str]` +### Parameters - The email address of the user +- `project_id: str` - - `name: Optional[str]` +- `user_id: str` - The name of the user +- `role_id: str` -### User Delete Response +### Returns -- `class UserDeleteResponse: …` +- `class RoleDeleteResponse: …` - - `id: str` + Confirmation payload returned after unassigning a role. - `deleted: bool` - - `object: Literal["organization.project.user.deleted"]` - - - `"organization.project.user.deleted"` - -# Roles - -## List project user role assignments - -`admin.organization.projects.users.roles.list(struser_id, RoleListParams**kwargs) -> SyncNextCursorPage[RoleListResponse]` - -**get** `/projects/{project_id}/users/{user_id}/roles` - -Lists the project roles assigned to a user within a project. - -### Parameters - -- `project_id: str` - -- `user_id: str` + Whether the assignment was removed. -- `after: Optional[str]` + - `object: str` - Cursor for pagination. Provide the value from the previous response's `next` field to continue listing project roles. + Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. -- `limit: Optional[int]` +### Example - A limit on the number of project role assignments to return. +```python +import os +from openai import OpenAI -- `order: Optional[Literal["asc", "desc"]]` +client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted +) +role = client.admin.organization.projects.users.roles.delete( + role_id="role_id", + project_id="project_id", + user_id="user_id", +) +print(role.deleted) +``` - Sort order for the returned project roles. +#### Response - - `"asc"` +```json +{ + "deleted": true, + "object": "object" +} +``` - - `"desc"` +## Domain Types -### Returns +### Role List Response - `class RoleListResponse: …` @@ -14519,73 +17829,7 @@ Lists the project roles assigned to a user within a project. When the role was last updated. -### Example - -```python -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 -) -page = client.admin.organization.projects.users.roles.list( - user_id="user_id", - project_id="project_id", -) -page = page.data[0] -print(page.id) -``` - -#### Response - -```json -{ - "data": [ - { - "id": "id", - "created_at": 0, - "created_by": "created_by", - "created_by_user_obj": { - "foo": "bar" - }, - "description": "description", - "metadata": { - "foo": "bar" - }, - "name": "name", - "permissions": [ - "string" - ], - "predefined_role": true, - "resource_type": "resource_type", - "updated_at": 0 - } - ], - "has_more": true, - "next": "next", - "object": "list" -} -``` - -## Assign project role to user - -`admin.organization.projects.users.roles.create(struser_id, RoleCreateParams**kwargs) -> RoleCreateResponse` - -**post** `/projects/{project_id}/users/{user_id}/roles` - -Assigns a project role to a user within a project. - -### Parameters - -- `project_id: str` - -- `user_id: str` - -- `role_id: str` - - Identifier of the role to assign. - -### Returns +### Role Create Response - `class RoleCreateResponse: …` @@ -14717,19 +17961,175 @@ Assigns a project role to a user within a project. - `object: Literal["user"]` - - `"user"` + - `"user"` + + - `banned: Optional[bool]` + + - `banned_at: Optional[int]` + + - `email: Optional[str]` + + - `enabled: Optional[bool]` + + - `name: Optional[str]` + + - `picture: Optional[str]` + +### Role Delete Response + +- `class RoleDeleteResponse: …` + + Confirmation payload returned after unassigning a role. + + - `deleted: bool` + + Whether the assignment was removed. + + - `object: str` + + Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. + +# Service Accounts + +## List project service accounts + +`admin.organization.projects.service_accounts.list(strproject_id, ServiceAccountListParams**kwargs) -> SyncConversationCursorPage[ProjectServiceAccount]` + +**get** `/organization/projects/{project_id}/service_accounts` + +Returns a list of service accounts in the project. + +### Parameters + +- `project_id: str` + +- `after: Optional[str]` + + A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + +- `limit: Optional[int]` + + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + +### Returns + +- `class ProjectServiceAccount: …` + + Represents an individual service account in a project. + + - `id: str` + + The identifier, which can be referenced in API endpoints + + - `created_at: int` + + The Unix timestamp (in seconds) of when the service account was created + + - `name: str` + + The name of the service account + + - `object: Literal["organization.project.service_account"]` + + The object type, which is always `organization.project.service_account` + + - `"organization.project.service_account"` + + - `role: Literal["owner", "member"]` + + `owner` or `member` + + - `"owner"` + + - `"member"` + +### Example + +```python +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 +) +page = client.admin.organization.projects.service_accounts.list( + project_id="project_id", +) +page = page.data[0] +print(page.id) +``` + +#### Response + +```json +{ + "data": [ + { + "id": "id", + "created_at": 0, + "name": "name", + "object": "organization.project.service_account", + "role": "owner" + } + ], + "has_more": true, + "object": "list", + "first_id": "first_id", + "last_id": "last_id" +} +``` + +## Create project service account + +`admin.organization.projects.service_accounts.create(strproject_id, ServiceAccountCreateParams**kwargs) -> ServiceAccountCreateResponse` + +**post** `/organization/projects/{project_id}/service_accounts` + +Creates a new service account in the project. This also returns an unredacted API key for the service account. + +### Parameters + +- `project_id: str` + +- `name: str` + + The name of the service account being created. + +### Returns + +- `class ServiceAccountCreateResponse: …` + + - `id: str` + + - `api_key: Optional[APIKey]` + + - `id: str` + + - `created_at: int` + + - `name: str` + + - `object: Literal["organization.project.service_account.api_key"]` + + The object type, which is always `organization.project.service_account.api_key` + + - `"organization.project.service_account.api_key"` + + - `value: str` + + - `created_at: int` - - `banned: Optional[bool]` + - `name: str` - - `banned_at: Optional[int]` + - `object: Literal["organization.project.service_account"]` - - `email: Optional[str]` + - `"organization.project.service_account"` - - `enabled: Optional[bool]` + - `role: Literal["member"]` - - `name: Optional[str]` + Service accounts can only have one role of type `member` - - `picture: Optional[str]` + - `"member"` ### Example @@ -14740,98 +18140,77 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -role = client.admin.organization.projects.users.roles.create( - user_id="user_id", +service_account = client.admin.organization.projects.service_accounts.create( project_id="project_id", - role_id="role_id", + name="name", ) -print(role.object) +print(service_account.id) ``` #### Response ```json { - "object": "user.role", - "role": { - "id": "id", - "description": "description", - "name": "name", - "object": "role", - "permissions": [ - "string" - ], - "predefined_role": true, - "resource_type": "resource_type" - }, - "user": { "id": "id", - "added_at": 0, - "object": "organization.user", - "api_key_last_used_at": 0, - "created": 0, - "developer_persona": "developer_persona", - "email": "email", - "is_default": true, - "is_scale_tier_authorized_purchaser": true, - "is_scim_managed": true, - "is_service_account": true, - "name": "name", - "projects": { - "data": [ - { + "api_key": { "id": "id", + "created_at": 0, "name": "name", - "role": "role" - } - ], - "object": "list" + "object": "organization.project.service_account.api_key", + "value": "value" }, - "role": "role", - "technical_level": "technical_level", - "user": { - "id": "id", - "object": "user", - "banned": true, - "banned_at": 0, - "email": "email", - "enabled": true, + "created_at": 0, "name": "name", - "picture": "picture" - } - } + "object": "organization.project.service_account", + "role": "member" } ``` -## Unassign project role from user +## Retrieve project service account -`admin.organization.projects.users.roles.delete(strrole_id, RoleDeleteParams**kwargs) -> RoleDeleteResponse` +`admin.organization.projects.service_accounts.retrieve(strservice_account_id, ServiceAccountRetrieveParams**kwargs) -> ProjectServiceAccount` -**delete** `/projects/{project_id}/users/{user_id}/roles/{role_id}` +**get** `/organization/projects/{project_id}/service_accounts/{service_account_id}` -Unassigns a project role from a user within a project. +Retrieves a service account in the project. ### Parameters - `project_id: str` -- `user_id: str` - -- `role_id: str` +- `service_account_id: str` ### Returns -- `class RoleDeleteResponse: …` +- `class ProjectServiceAccount: …` - Confirmation payload returned after unassigning a role. + Represents an individual service account in a project. - - `deleted: bool` + - `id: str` - Whether the assignment was removed. + The identifier, which can be referenced in API endpoints - - `object: str` + - `created_at: int` - Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. + The Unix timestamp (in seconds) of when the service account was created + + - `name: str` + + The name of the service account + + - `object: Literal["organization.project.service_account"]` + + The object type, which is always `organization.project.service_account` + + - `"organization.project.service_account"` + + - `role: Literal["owner", "member"]` + + `owner` or `member` + + - `"owner"` + + - `"member"` ### Example @@ -14842,262 +18221,245 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -role = client.admin.organization.projects.users.roles.delete( - role_id="role_id", +project_service_account = client.admin.organization.projects.service_accounts.retrieve( + service_account_id="service_account_id", project_id="project_id", - user_id="user_id", ) -print(role.deleted) +print(project_service_account.id) ``` #### Response ```json { - "deleted": true, - "object": "object" + "id": "id", + "created_at": 0, + "name": "name", + "object": "organization.project.service_account", + "role": "owner" } ``` -## Domain Types - -### Role List Response - -- `class RoleListResponse: …` - - Detailed information about a role assignment entry returned when listing assignments. - - - `id: str` - - Identifier for the role. - - - `created_at: Optional[int]` - - When the role was created. - - - `created_by: Optional[str]` - - Identifier of the actor who created the role. - - - `created_by_user_obj: Optional[Dict[str, object]]` - - User details for the actor that created the role, when available. +## Delete project service account - - `description: Optional[str]` +`admin.organization.projects.service_accounts.delete(strservice_account_id, ServiceAccountDeleteParams**kwargs) -> ServiceAccountDeleteResponse` - Description of the role. +**delete** `/organization/projects/{project_id}/service_accounts/{service_account_id}` - - `metadata: Optional[Dict[str, object]]` +Deletes a service account from the project. - Arbitrary metadata stored on the role. +Returns confirmation of service account deletion, or an error if the project +is archived (archived projects have no service accounts). - - `name: str` +### Parameters - Name of the role. +- `project_id: str` - - `permissions: List[str]` +- `service_account_id: str` - Permissions associated with the role. +### Returns - - `predefined_role: bool` +- `class ServiceAccountDeleteResponse: …` - Whether the role is predefined by OpenAI. + - `id: str` - - `resource_type: str` + - `deleted: bool` - Resource type the role applies to. + - `object: Literal["organization.project.service_account.deleted"]` - - `updated_at: Optional[int]` + - `"organization.project.service_account.deleted"` - When the role was last updated. +### Example -### Role Create Response +```python +import os +from openai import OpenAI -- `class RoleCreateResponse: …` +client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted +) +service_account = client.admin.organization.projects.service_accounts.delete( + service_account_id="service_account_id", + project_id="project_id", +) +print(service_account.id) +``` - Role assignment linking a user to a role. +#### Response - - `object: Literal["user.role"]` +```json +{ + "id": "id", + "deleted": true, + "object": "organization.project.service_account.deleted" +} +``` - Always `user.role`. +## Domain Types - - `"user.role"` +### Project Service Account - - `role: Role` +- `class ProjectServiceAccount: …` - Details about a role that can be assigned through the public Roles API. + Represents an individual service account in a project. - `id: str` - Identifier for the role. + The identifier, which can be referenced in API endpoints - - `description: Optional[str]` + - `created_at: int` - Optional description of the role. + The Unix timestamp (in seconds) of when the service account was created - `name: str` - Unique name for the role. - - - `object: Literal["role"]` - - Always `role`. + The name of the service account - - `"role"` + - `object: Literal["organization.project.service_account"]` - - `permissions: List[str]` + The object type, which is always `organization.project.service_account` - Permissions granted by the role. + - `"organization.project.service_account"` - - `predefined_role: bool` + - `role: Literal["owner", "member"]` - Whether the role is predefined and managed by OpenAI. + `owner` or `member` - - `resource_type: str` + - `"owner"` - Resource type the role is bound to (for example `api.organization` or `api.project`). + - `"member"` - - `user: OrganizationUser` +### Service Account Create Response - Represents an individual `user` within an organization. +- `class ServiceAccountCreateResponse: …` - `id: str` - The identifier, which can be referenced in API endpoints - - - `added_at: int` - - The Unix timestamp (in seconds) of when the user was added. - - - `object: Literal["organization.user"]` - - The object type, which is always `organization.user` - - - `"organization.user"` + - `api_key: Optional[APIKey]` - - `api_key_last_used_at: Optional[int]` + - `id: str` - The Unix timestamp (in seconds) of the user's last API key usage. + - `created_at: int` - - `created: Optional[int]` + - `name: str` - The Unix timestamp (in seconds) of when the user was created. + - `object: Literal["organization.project.service_account.api_key"]` - - `developer_persona: Optional[str]` + The object type, which is always `organization.project.service_account.api_key` - The developer persona metadata for the user. + - `"organization.project.service_account.api_key"` - - `email: Optional[str]` + - `value: str` - The email address of the user + - `created_at: int` - - `is_default: Optional[bool]` + - `name: str` - Whether this is the organization's default user. + - `object: Literal["organization.project.service_account"]` - - `is_scale_tier_authorized_purchaser: Optional[bool]` + - `"organization.project.service_account"` - Whether the user is an authorized purchaser for Scale Tier. + - `role: Literal["member"]` - - `is_scim_managed: Optional[bool]` + Service accounts can only have one role of type `member` - Whether the user is managed through SCIM. + - `"member"` - - `is_service_account: Optional[bool]` +### Service Account Delete Response - Whether the user is a service account. +- `class ServiceAccountDeleteResponse: …` - - `name: Optional[str]` + - `id: str` - The name of the user + - `deleted: bool` - - `projects: Optional[Projects]` + - `object: Literal["organization.project.service_account.deleted"]` - Projects associated with the user, if included. + - `"organization.project.service_account.deleted"` - - `data: List[ProjectsData]` +# API Keys - - `id: Optional[str]` +## List project API keys - - `name: Optional[str]` +`admin.organization.projects.api_keys.list(strproject_id, APIKeyListParams**kwargs) -> SyncConversationCursorPage[ProjectAPIKey]` - - `role: Optional[str]` +**get** `/organization/projects/{project_id}/api_keys` - - `object: Literal["list"]` +Returns a list of API keys in the project. - - `"list"` +### Parameters - - `role: Optional[str]` +- `project_id: str` - `owner` or `reader` +- `after: Optional[str]` - - `technical_level: Optional[str]` + A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - The technical level metadata for the user. +- `limit: Optional[int]` - - `user: Optional[User]` + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - Nested user details. +### Returns - - `id: str` +- `class ProjectAPIKey: …` - - `object: Literal["user"]` + Represents an individual API key in a project. - - `"user"` + - `id: str` - - `banned: Optional[bool]` + The identifier, which can be referenced in API endpoints - - `banned_at: Optional[int]` + - `created_at: int` - - `email: Optional[str]` + The Unix timestamp (in seconds) of when the API key was created - - `enabled: Optional[bool]` + - `last_used_at: Optional[int]` - - `name: Optional[str]` + The Unix timestamp (in seconds) of when the API key was last used. - - `picture: Optional[str]` + - `name: str` -### Role Delete Response + The name of the API key -- `class RoleDeleteResponse: …` + - `object: Literal["organization.project.api_key"]` - Confirmation payload returned after unassigning a role. + The object type, which is always `organization.project.api_key` - - `deleted: bool` + - `"organization.project.api_key"` - Whether the assignment was removed. + - `owner: Owner` - - `object: str` + - `service_account: Optional[OwnerServiceAccount]` - Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`. + The service account that owns a project API key. -# Service Accounts + - `id: str` -## List project service accounts + The identifier, which can be referenced in API endpoints -`admin.organization.projects.service_accounts.list(strproject_id, ServiceAccountListParams**kwargs) -> SyncConversationCursorPage[ProjectServiceAccount]` + - `created_at: int` -**get** `/organization/projects/{project_id}/service_accounts` + The Unix timestamp (in seconds) of when the service account was created. -Returns a list of service accounts in the project. + - `name: str` -### Parameters + The name of the service account. -- `project_id: str` + - `role: str` -- `after: Optional[str]` + The service account's project role. - A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + - `type: Optional[Literal["user", "service_account"]]` -- `limit: Optional[int]` + `user` or `service_account` - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + - `"user"` -### Returns + - `"service_account"` -- `class ProjectServiceAccount: …` + - `user: Optional[OwnerUser]` - Represents an individual service account in a project. + The user that owns a project API key. - `id: str` @@ -15105,25 +18467,23 @@ Returns a list of service accounts in the project. - `created_at: int` - The Unix timestamp (in seconds) of when the service account was created - - - `name: str` + The Unix timestamp (in seconds) of when the user was created. - The name of the service account + - `email: str` - - `object: Literal["organization.project.service_account"]` + The email address of the user. - The object type, which is always `organization.project.service_account` + - `name: str` - - `"organization.project.service_account"` + The name of the user. - - `role: Literal["owner", "member"]` + - `role: str` - `owner` or `member` + The user's project role. - - `"owner"` + - `redacted_value: str` - - `"member"` + The redacted value of the API key ### Example @@ -15134,7 +18494,7 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -page = client.admin.organization.projects.service_accounts.list( +page = client.admin.organization.projects.api_keys.list( project_id="project_id", ) page = page.data[0] @@ -15149,9 +18509,26 @@ print(page.id) { "id": "id", "created_at": 0, + "last_used_at": 0, "name": "name", - "object": "organization.project.service_account", - "role": "owner" + "object": "organization.project.api_key", + "owner": { + "service_account": { + "id": "id", + "created_at": 0, + "name": "name", + "role": "role" + }, + "type": "user", + "user": { + "id": "id", + "created_at": 0, + "email": "email", + "name": "name", + "role": "role" + } + }, + "redacted_value": "redacted_value" } ], "has_more": true, @@ -15161,112 +18538,81 @@ print(page.id) } ``` -## Create project service account +## Retrieve project API key -`admin.organization.projects.service_accounts.create(strproject_id, ServiceAccountCreateParams**kwargs) -> ServiceAccountCreateResponse` +`admin.organization.projects.api_keys.retrieve(strapi_key_id, APIKeyRetrieveParams**kwargs) -> ProjectAPIKey` -**post** `/organization/projects/{project_id}/service_accounts` +**get** `/organization/projects/{project_id}/api_keys/{api_key_id}` -Creates a new service account in the project. This also returns an unredacted API key for the service account. +Retrieves an API key in the project. ### Parameters - `project_id: str` -- `name: str` - - The name of the service account being created. +- `api_key_id: str` ### Returns -- `class ServiceAccountCreateResponse: …` - - - `id: str` +- `class ProjectAPIKey: …` - - `api_key: Optional[APIKey]` + Represents an individual API key in a project. - `id: str` - - `created_at: int` - - - `name: str` - - - `object: Literal["organization.project.service_account.api_key"]` + The identifier, which can be referenced in API endpoints - The object type, which is always `organization.project.service_account.api_key` + - `created_at: int` - - `"organization.project.service_account.api_key"` + The Unix timestamp (in seconds) of when the API key was created - - `value: str` + - `last_used_at: Optional[int]` - - `created_at: int` + The Unix timestamp (in seconds) of when the API key was last used. - `name: str` - - `object: Literal["organization.project.service_account"]` + The name of the API key - - `"organization.project.service_account"` + - `object: Literal["organization.project.api_key"]` - - `role: Literal["member"]` + The object type, which is always `organization.project.api_key` - Service accounts can only have one role of type `member` + - `"organization.project.api_key"` - - `"member"` + - `owner: Owner` -### Example + - `service_account: Optional[OwnerServiceAccount]` -```python -import os -from openai import OpenAI + The service account that owns a project API key. -client = OpenAI( - admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted -) -service_account = client.admin.organization.projects.service_accounts.create( - project_id="project_id", - name="name", -) -print(service_account.id) -``` + - `id: str` -#### Response + The identifier, which can be referenced in API endpoints -```json -{ - "id": "id", - "api_key": { - "id": "id", - "created_at": 0, - "name": "name", - "object": "organization.project.service_account.api_key", - "value": "value" - }, - "created_at": 0, - "name": "name", - "object": "organization.project.service_account", - "role": "member" -} -``` + - `created_at: int` -## Retrieve project service account + The Unix timestamp (in seconds) of when the service account was created. -`admin.organization.projects.service_accounts.retrieve(strservice_account_id, ServiceAccountRetrieveParams**kwargs) -> ProjectServiceAccount` + - `name: str` -**get** `/organization/projects/{project_id}/service_accounts/{service_account_id}` + The name of the service account. -Retrieves a service account in the project. + - `role: str` -### Parameters + The service account's project role. -- `project_id: str` + - `type: Optional[Literal["user", "service_account"]]` + + `user` or `service_account` -- `service_account_id: str` + - `"user"` -### Returns + - `"service_account"` -- `class ProjectServiceAccount: …` + - `user: Optional[OwnerUser]` - Represents an individual service account in a project. + The user that owns a project API key. - `id: str` @@ -15274,25 +18620,23 @@ Retrieves a service account in the project. - `created_at: int` - The Unix timestamp (in seconds) of when the service account was created - - - `name: str` + The Unix timestamp (in seconds) of when the user was created. - The name of the service account + - `email: str` - - `object: Literal["organization.project.service_account"]` + The email address of the user. - The object type, which is always `organization.project.service_account` + - `name: str` - - `"organization.project.service_account"` + The name of the user. - - `role: Literal["owner", "member"]` + - `role: str` - `owner` or `member` + The user's project role. - - `"owner"` + - `redacted_value: str` - - `"member"` + The redacted value of the API key ### Example @@ -15303,11 +18647,11 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -project_service_account = client.admin.organization.projects.service_accounts.retrieve( - service_account_id="service_account_id", +project_api_key = client.admin.organization.projects.api_keys.retrieve( + api_key_id="api_key_id", project_id="project_id", ) -print(project_service_account.id) +print(project_api_key.id) ``` #### Response @@ -15316,40 +18660,57 @@ print(project_service_account.id) { "id": "id", "created_at": 0, + "last_used_at": 0, "name": "name", - "object": "organization.project.service_account", - "role": "owner" + "object": "organization.project.api_key", + "owner": { + "service_account": { + "id": "id", + "created_at": 0, + "name": "name", + "role": "role" + }, + "type": "user", + "user": { + "id": "id", + "created_at": 0, + "email": "email", + "name": "name", + "role": "role" + } + }, + "redacted_value": "redacted_value" } ``` -## Delete project service account +## Delete project API key -`admin.organization.projects.service_accounts.delete(strservice_account_id, ServiceAccountDeleteParams**kwargs) -> ServiceAccountDeleteResponse` +`admin.organization.projects.api_keys.delete(strapi_key_id, APIKeyDeleteParams**kwargs) -> APIKeyDeleteResponse` -**delete** `/organization/projects/{project_id}/service_accounts/{service_account_id}` +**delete** `/organization/projects/{project_id}/api_keys/{api_key_id}` -Deletes a service account from the project. +Deletes an API key from the project. -Returns confirmation of service account deletion, or an error if the project -is archived (archived projects have no service accounts). +Returns confirmation of the key deletion, or an error if the key belonged to +a service account. ### Parameters - `project_id: str` -- `service_account_id: str` +- `api_key_id: str` ### Returns -- `class ServiceAccountDeleteResponse: …` +- `class APIKeyDeleteResponse: …` - `id: str` - `deleted: bool` - - `object: Literal["organization.project.service_account.deleted"]` + - `object: Literal["organization.project.api_key.deleted"]` - - `"organization.project.service_account.deleted"` + - `"organization.project.api_key.deleted"` ### Example @@ -15360,11 +18721,11 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -service_account = client.admin.organization.projects.service_accounts.delete( - service_account_id="service_account_id", +api_key = client.admin.organization.projects.api_keys.delete( + api_key_id="api_key_id", project_id="project_id", ) -print(service_account.id) +print(api_key.id) ``` #### Response @@ -15373,17 +18734,17 @@ print(service_account.id) { "id": "id", "deleted": true, - "object": "organization.project.service_account.deleted" + "object": "organization.project.api_key.deleted" } ``` ## Domain Types -### Project Service Account +### Project API Key -- `class ProjectServiceAccount: …` +- `class ProjectAPIKey: …` - Represents an individual service account in a project. + Represents an individual API key in a project. - `id: str` @@ -15391,83 +18752,101 @@ print(service_account.id) - `created_at: int` - The Unix timestamp (in seconds) of when the service account was created - - - `name: str` + The Unix timestamp (in seconds) of when the API key was created - The name of the service account + - `last_used_at: Optional[int]` - - `object: Literal["organization.project.service_account"]` + The Unix timestamp (in seconds) of when the API key was last used. - The object type, which is always `organization.project.service_account` + - `name: str` - - `"organization.project.service_account"` + The name of the API key - - `role: Literal["owner", "member"]` + - `object: Literal["organization.project.api_key"]` - `owner` or `member` + The object type, which is always `organization.project.api_key` - - `"owner"` + - `"organization.project.api_key"` - - `"member"` + - `owner: Owner` -### Service Account Create Response + - `service_account: Optional[OwnerServiceAccount]` -- `class ServiceAccountCreateResponse: …` + The service account that owns a project API key. - `id: str` - - `api_key: Optional[APIKey]` - - - `id: str` + The identifier, which can be referenced in API endpoints - `created_at: int` + The Unix timestamp (in seconds) of when the service account was created. + - `name: str` - - `object: Literal["organization.project.service_account.api_key"]` + The name of the service account. - The object type, which is always `organization.project.service_account.api_key` + - `role: str` - - `"organization.project.service_account.api_key"` + The service account's project role. - - `value: str` + - `type: Optional[Literal["user", "service_account"]]` + + `user` or `service_account` + + - `"user"` + + - `"service_account"` + + - `user: Optional[OwnerUser]` + + The user that owns a project API key. + + - `id: str` + + The identifier, which can be referenced in API endpoints - `created_at: int` + The Unix timestamp (in seconds) of when the user was created. + + - `email: str` + + The email address of the user. + - `name: str` - - `object: Literal["organization.project.service_account"]` + The name of the user. - - `"organization.project.service_account"` + - `role: str` - - `role: Literal["member"]` + The user's project role. - Service accounts can only have one role of type `member` + - `redacted_value: str` - - `"member"` + The redacted value of the API key -### Service Account Delete Response +### API Key Delete Response -- `class ServiceAccountDeleteResponse: …` +- `class APIKeyDeleteResponse: …` - `id: str` - `deleted: bool` - - `object: Literal["organization.project.service_account.deleted"]` + - `object: Literal["organization.project.api_key.deleted"]` - - `"organization.project.service_account.deleted"` + - `"organization.project.api_key.deleted"` -# API Keys +# Rate Limits -## List project API keys +## List project rate limits -`admin.organization.projects.api_keys.list(strproject_id, APIKeyListParams**kwargs) -> SyncConversationCursorPage[ProjectAPIKey]` +`admin.organization.projects.rate_limits.list_rate_limits(strproject_id, RateLimitListRateLimitsParams**kwargs) -> SyncConversationCursorPage[ProjectRateLimit]` -**get** `/organization/projects/{project_id}/api_keys` +**get** `/organization/projects/{project_id}/rate_limits` -Returns a list of API keys in the project. +Returns the rate limits per model for a project. ### Parameters @@ -15477,95 +18856,179 @@ Returns a list of API keys in the project. A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. +- `before: Optional[str]` + + A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, beginning with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + - `limit: Optional[int]` - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + A limit on the number of objects to be returned. The default is 100. ### Returns -- `class ProjectAPIKey: …` +- `class ProjectRateLimit: …` + + Represents a project rate limit config. + + - `id: str` + + The identifier, which can be referenced in API endpoints. + + - `max_requests_per_1_minute: int` + + The maximum requests per minute. + + - `max_tokens_per_1_minute: int` + + The maximum tokens per minute. + + - `model: str` + + The model this rate limit applies to. + + - `object: Literal["project.rate_limit"]` + + The object type, which is always `project.rate_limit` + + - `"project.rate_limit"` + + - `batch_1_day_max_input_tokens: Optional[int]` + + The maximum batch input tokens per day. Only present for relevant models. + + - `max_audio_megabytes_per_1_minute: Optional[int]` + + The maximum audio megabytes per minute. Only present for relevant models. + + - `max_images_per_1_minute: Optional[int]` + + The maximum images per minute. Only present for relevant models. + + - `max_requests_per_1_day: Optional[int]` + + The maximum requests per day. Only present for relevant models. + +### Example + +```python +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 +) +page = client.admin.organization.projects.rate_limits.list_rate_limits( + project_id="project_id", +) +page = page.data[0] +print(page.id) +``` + +#### Response + +```json +{ + "data": [ + { + "id": "id", + "max_requests_per_1_minute": 0, + "max_tokens_per_1_minute": 0, + "model": "model", + "object": "project.rate_limit", + "batch_1_day_max_input_tokens": 0, + "max_audio_megabytes_per_1_minute": 0, + "max_images_per_1_minute": 0, + "max_requests_per_1_day": 0 + } + ], + "has_more": true, + "object": "list", + "first_id": "first_id", + "last_id": "last_id" +} +``` - Represents an individual API key in a project. +## Modify project rate limit - - `id: str` +`admin.organization.projects.rate_limits.update_rate_limit(strrate_limit_id, RateLimitUpdateRateLimitParams**kwargs) -> ProjectRateLimit` - The identifier, which can be referenced in API endpoints +**post** `/organization/projects/{project_id}/rate_limits/{rate_limit_id}` - - `created_at: int` +Updates a project rate limit. - The Unix timestamp (in seconds) of when the API key was created +### Parameters - - `last_used_at: Optional[int]` +- `project_id: str` - The Unix timestamp (in seconds) of when the API key was last used. +- `rate_limit_id: str` - - `name: str` +- `batch_1_day_max_input_tokens: Optional[int]` - The name of the API key + The maximum batch input tokens per day. Only relevant for certain models. - - `object: Literal["organization.project.api_key"]` +- `max_audio_megabytes_per_1_minute: Optional[int]` - The object type, which is always `organization.project.api_key` + The maximum audio megabytes per minute. Only relevant for certain models. - - `"organization.project.api_key"` +- `max_images_per_1_minute: Optional[int]` - - `owner: Owner` + The maximum images per minute. Only relevant for certain models. - - `service_account: Optional[OwnerServiceAccount]` +- `max_requests_per_1_day: Optional[int]` - The service account that owns a project API key. + The maximum requests per day. Only relevant for certain models. - - `id: str` +- `max_requests_per_1_minute: Optional[int]` - The identifier, which can be referenced in API endpoints + The maximum requests per minute. - - `created_at: int` +- `max_tokens_per_1_minute: Optional[int]` - The Unix timestamp (in seconds) of when the service account was created. + The maximum tokens per minute. - - `name: str` +### Returns - The name of the service account. +- `class ProjectRateLimit: …` - - `role: str` + Represents a project rate limit config. - The service account's project role. + - `id: str` - - `type: Optional[Literal["user", "service_account"]]` + The identifier, which can be referenced in API endpoints. - `user` or `service_account` + - `max_requests_per_1_minute: int` - - `"user"` + The maximum requests per minute. - - `"service_account"` + - `max_tokens_per_1_minute: int` - - `user: Optional[OwnerUser]` + The maximum tokens per minute. - The user that owns a project API key. + - `model: str` - - `id: str` + The model this rate limit applies to. - The identifier, which can be referenced in API endpoints + - `object: Literal["project.rate_limit"]` - - `created_at: int` + The object type, which is always `project.rate_limit` - The Unix timestamp (in seconds) of when the user was created. + - `"project.rate_limit"` - - `email: str` + - `batch_1_day_max_input_tokens: Optional[int]` - The email address of the user. + The maximum batch input tokens per day. Only present for relevant models. - - `name: str` + - `max_audio_megabytes_per_1_minute: Optional[int]` - The name of the user. + The maximum audio megabytes per minute. Only present for relevant models. - - `role: str` + - `max_images_per_1_minute: Optional[int]` - The user's project role. + The maximum images per minute. Only present for relevant models. - - `redacted_value: str` + - `max_requests_per_1_day: Optional[int]` - The redacted value of the API key + The maximum requests per day. Only present for relevant models. ### Example @@ -15576,149 +19039,112 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -page = client.admin.organization.projects.api_keys.list( +project_rate_limit = client.admin.organization.projects.rate_limits.update_rate_limit( + rate_limit_id="rate_limit_id", project_id="project_id", ) -page = page.data[0] -print(page.id) +print(project_rate_limit.id) ``` #### Response ```json { - "data": [ - { - "id": "id", - "created_at": 0, - "last_used_at": 0, - "name": "name", - "object": "organization.project.api_key", - "owner": { - "service_account": { - "id": "id", - "created_at": 0, - "name": "name", - "role": "role" - }, - "type": "user", - "user": { "id": "id", - "created_at": 0, - "email": "email", - "name": "name", - "role": "role" - } - }, - "redacted_value": "redacted_value" - } - ], - "has_more": true, - "object": "list", - "first_id": "first_id", - "last_id": "last_id" + "max_requests_per_1_minute": 0, + "max_tokens_per_1_minute": 0, + "model": "model", + "object": "project.rate_limit", + "batch_1_day_max_input_tokens": 0, + "max_audio_megabytes_per_1_minute": 0, + "max_images_per_1_minute": 0, + "max_requests_per_1_day": 0 } ``` -## Retrieve project API key - -`admin.organization.projects.api_keys.retrieve(strapi_key_id, APIKeyRetrieveParams**kwargs) -> ProjectAPIKey` - -**get** `/organization/projects/{project_id}/api_keys/{api_key_id}` - -Retrieves an API key in the project. - -### Parameters - -- `project_id: str` - -- `api_key_id: str` +## Domain Types -### Returns +### Project Rate Limit -- `class ProjectAPIKey: …` +- `class ProjectRateLimit: …` - Represents an individual API key in a project. + Represents a project rate limit config. - `id: str` - The identifier, which can be referenced in API endpoints - - - `created_at: int` - - The Unix timestamp (in seconds) of when the API key was created + The identifier, which can be referenced in API endpoints. - - `last_used_at: Optional[int]` + - `max_requests_per_1_minute: int` - The Unix timestamp (in seconds) of when the API key was last used. + The maximum requests per minute. - - `name: str` + - `max_tokens_per_1_minute: int` - The name of the API key + The maximum tokens per minute. - - `object: Literal["organization.project.api_key"]` + - `model: str` - The object type, which is always `organization.project.api_key` + The model this rate limit applies to. - - `"organization.project.api_key"` + - `object: Literal["project.rate_limit"]` - - `owner: Owner` + The object type, which is always `project.rate_limit` - - `service_account: Optional[OwnerServiceAccount]` + - `"project.rate_limit"` - The service account that owns a project API key. + - `batch_1_day_max_input_tokens: Optional[int]` - - `id: str` + The maximum batch input tokens per day. Only present for relevant models. - The identifier, which can be referenced in API endpoints + - `max_audio_megabytes_per_1_minute: Optional[int]` - - `created_at: int` + The maximum audio megabytes per minute. Only present for relevant models. - The Unix timestamp (in seconds) of when the service account was created. + - `max_images_per_1_minute: Optional[int]` - - `name: str` + The maximum images per minute. Only present for relevant models. - The name of the service account. + - `max_requests_per_1_day: Optional[int]` - - `role: str` + The maximum requests per day. Only present for relevant models. - The service account's project role. +# Model Permissions - - `type: Optional[Literal["user", "service_account"]]` +## Retrieve project model permissions - `user` or `service_account` +`admin.organization.projects.model_permissions.retrieve(strproject_id) -> ProjectModelPermissions` - - `"user"` +**get** `/organization/projects/{project_id}/model_permissions` - - `"service_account"` +Returns model permissions for a project. - - `user: Optional[OwnerUser]` +### Parameters - The user that owns a project API key. +- `project_id: str` - - `id: str` +### Returns - The identifier, which can be referenced in API endpoints +- `class ProjectModelPermissions: …` - - `created_at: int` + Represents the model allowlist or denylist policy for a project. - The Unix timestamp (in seconds) of when the user was created. + - `mode: Literal["allow_list", "deny_list"]` - - `email: str` + Whether the project uses an allowlist or a denylist. - The email address of the user. + - `"allow_list"` - - `name: str` + - `"deny_list"` - The name of the user. + - `model_ids: List[str]` - - `role: str` + The model IDs included in the model permissions policy. - The user's project role. + - `object: Literal["project.model_permissions"]` - - `redacted_value: str` + The object type, which is always `project.model_permissions`. - The redacted value of the API key + - `"project.model_permissions"` ### Example @@ -15729,70 +19155,71 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -project_api_key = client.admin.organization.projects.api_keys.retrieve( - api_key_id="api_key_id", - project_id="project_id", +project_model_permissions = client.admin.organization.projects.model_permissions.retrieve( + "project_id", ) -print(project_api_key.id) +print(project_model_permissions.model_ids) ``` #### Response ```json { - "id": "id", - "created_at": 0, - "last_used_at": 0, - "name": "name", - "object": "organization.project.api_key", - "owner": { - "service_account": { - "id": "id", - "created_at": 0, - "name": "name", - "role": "role" - }, - "type": "user", - "user": { - "id": "id", - "created_at": 0, - "email": "email", - "name": "name", - "role": "role" - } - }, - "redacted_value": "redacted_value" + "mode": "allow_list", + "model_ids": [ + "string" + ], + "object": "project.model_permissions" } ``` -## Delete project API key +## Modify project model permissions + +`admin.organization.projects.model_permissions.update(strproject_id, ModelPermissionUpdateParams**kwargs) -> ProjectModelPermissions` + +**post** `/organization/projects/{project_id}/model_permissions` + +Updates model permissions for a project. + +### Parameters + +- `project_id: str` + +- `mode: Literal["allow_list", "deny_list"]` + + The model permissions mode to apply. + + - `"allow_list"` + + - `"deny_list"` + +- `model_ids: Sequence[str]` -`admin.organization.projects.api_keys.delete(strapi_key_id, APIKeyDeleteParams**kwargs) -> APIKeyDeleteResponse` + The model IDs included in this permissions policy. -**delete** `/organization/projects/{project_id}/api_keys/{api_key_id}` +### Returns -Deletes an API key from the project. +- `class ProjectModelPermissions: …` -Returns confirmation of the key deletion, or an error if the key belonged to -a service account. + Represents the model allowlist or denylist policy for a project. -### Parameters + - `mode: Literal["allow_list", "deny_list"]` -- `project_id: str` + Whether the project uses an allowlist or a denylist. -- `api_key_id: str` + - `"allow_list"` -### Returns + - `"deny_list"` -- `class APIKeyDeleteResponse: …` + - `model_ids: List[str]` - - `id: str` + The model IDs included in the model permissions policy. - - `deleted: bool` + - `object: Literal["project.model_permissions"]` - - `object: Literal["organization.project.api_key.deleted"]` + The object type, which is always `project.model_permissions`. - - `"organization.project.api_key.deleted"` + - `"project.model_permissions"` ### Example @@ -15803,192 +19230,179 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -api_key = client.admin.organization.projects.api_keys.delete( - api_key_id="api_key_id", +project_model_permissions = client.admin.organization.projects.model_permissions.update( project_id="project_id", + mode="allow_list", + model_ids=["string"], ) -print(api_key.id) +print(project_model_permissions.model_ids) ``` #### Response ```json { - "id": "id", - "deleted": true, - "object": "organization.project.api_key.deleted" + "mode": "allow_list", + "model_ids": [ + "string" + ], + "object": "project.model_permissions" } ``` -## Domain Types - -### Project API Key - -- `class ProjectAPIKey: …` - - Represents an individual API key in a project. - - - `id: str` - - The identifier, which can be referenced in API endpoints - - - `created_at: int` - - The Unix timestamp (in seconds) of when the API key was created - - - `last_used_at: Optional[int]` - - The Unix timestamp (in seconds) of when the API key was last used. - - - `name: str` +## Delete project model permissions - The name of the API key +`admin.organization.projects.model_permissions.delete(strproject_id) -> ProjectModelPermissionsDeleted` - - `object: Literal["organization.project.api_key"]` +**delete** `/organization/projects/{project_id}/model_permissions` - The object type, which is always `organization.project.api_key` +Deletes model permissions for a project. - - `"organization.project.api_key"` +### Parameters - - `owner: Owner` +- `project_id: str` - - `service_account: Optional[OwnerServiceAccount]` +### Returns - The service account that owns a project API key. +- `class ProjectModelPermissionsDeleted: …` - - `id: str` + Confirmation payload returned after deleting project model permissions. - The identifier, which can be referenced in API endpoints + - `deleted: bool` - - `created_at: int` + Whether the project model permissions were deleted. - The Unix timestamp (in seconds) of when the service account was created. + - `object: Literal["project.model_permissions.deleted"]` - - `name: str` + The object type, which is always `project.model_permissions.deleted`. - The name of the service account. + - `"project.model_permissions.deleted"` - - `role: str` +### Example - The service account's project role. +```python +import os +from openai import OpenAI - - `type: Optional[Literal["user", "service_account"]]` +client = OpenAI( + admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted +) +project_model_permissions_deleted = client.admin.organization.projects.model_permissions.delete( + "project_id", +) +print(project_model_permissions_deleted.deleted) +``` - `user` or `service_account` +#### Response - - `"user"` +```json +{ + "deleted": true, + "object": "project.model_permissions.deleted" +} +``` - - `"service_account"` +## Domain Types - - `user: Optional[OwnerUser]` +### Project Model Permissions - The user that owns a project API key. +- `class ProjectModelPermissions: …` - - `id: str` + Represents the model allowlist or denylist policy for a project. - The identifier, which can be referenced in API endpoints + - `mode: Literal["allow_list", "deny_list"]` - - `created_at: int` + Whether the project uses an allowlist or a denylist. - The Unix timestamp (in seconds) of when the user was created. + - `"allow_list"` - - `email: str` + - `"deny_list"` - The email address of the user. + - `model_ids: List[str]` - - `name: str` + The model IDs included in the model permissions policy. - The name of the user. + - `object: Literal["project.model_permissions"]` - - `role: str` + The object type, which is always `project.model_permissions`. - The user's project role. + - `"project.model_permissions"` - - `redacted_value: str` +### Project Model Permissions Deleted - The redacted value of the API key +- `class ProjectModelPermissionsDeleted: …` -### API Key Delete Response + Confirmation payload returned after deleting project model permissions. -- `class APIKeyDeleteResponse: …` + - `deleted: bool` - - `id: str` + Whether the project model permissions were deleted. - - `deleted: bool` + - `object: Literal["project.model_permissions.deleted"]` - - `object: Literal["organization.project.api_key.deleted"]` + The object type, which is always `project.model_permissions.deleted`. - - `"organization.project.api_key.deleted"` + - `"project.model_permissions.deleted"` -# Rate Limits +# Hosted Tool Permissions -## List project rate limits +## Retrieve project hosted tool permissions -`admin.organization.projects.rate_limits.list_rate_limits(strproject_id, RateLimitListRateLimitsParams**kwargs) -> SyncConversationCursorPage[ProjectRateLimit]` +`admin.organization.projects.hosted_tool_permissions.retrieve(strproject_id) -> ProjectHostedToolPermissions` -**get** `/organization/projects/{project_id}/rate_limits` +**get** `/organization/projects/{project_id}/hosted_tool_permissions` -Returns the rate limits per model for a project. +Returns hosted tool permissions for a project. ### Parameters - `project_id: str` -- `after: Optional[str]` - - A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - -- `before: Optional[str]` - - A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, beginning with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. - -- `limit: Optional[int]` - - A limit on the number of objects to be returned. The default is 100. - ### Returns -- `class ProjectRateLimit: …` +- `class ProjectHostedToolPermissions: …` - Represents a project rate limit config. + Represents hosted tool permissions for a project. - - `id: str` + - `code_interpreter: CodeInterpreter` - The identifier, which can be referenced in API endpoints. + Permission state for a single hosted tool on a project. - - `max_requests_per_1_minute: int` + - `enabled: bool` - The maximum requests per minute. + Whether the hosted tool is enabled for the project. - - `max_tokens_per_1_minute: int` + - `file_search: FileSearch` - The maximum tokens per minute. + Permission state for a single hosted tool on a project. - - `model: str` + - `enabled: bool` - The model this rate limit applies to. + Whether the hosted tool is enabled for the project. - - `object: Literal["project.rate_limit"]` + - `image_generation: ImageGeneration` - The object type, which is always `project.rate_limit` + Permission state for a single hosted tool on a project. - - `"project.rate_limit"` + - `enabled: bool` - - `batch_1_day_max_input_tokens: Optional[int]` + Whether the hosted tool is enabled for the project. - The maximum batch input tokens per day. Only present for relevant models. + - `mcp: Mcp` - - `max_audio_megabytes_per_1_minute: Optional[int]` + Permission state for a single hosted tool on a project. - The maximum audio megabytes per minute. Only present for relevant models. + - `enabled: bool` - - `max_images_per_1_minute: Optional[int]` + Whether the hosted tool is enabled for the project. - The maximum images per minute. Only present for relevant models. + - `web_search: WebSearch` - - `max_requests_per_1_day: Optional[int]` + Permission state for a single hosted tool on a project. - The maximum requests per day. Only present for relevant models. + - `enabled: bool` + + Whether the hosted tool is enabled for the project. ### Example @@ -15999,118 +19413,131 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -page = client.admin.organization.projects.rate_limits.list_rate_limits( - project_id="project_id", +project_hosted_tool_permissions = client.admin.organization.projects.hosted_tool_permissions.retrieve( + "project_id", ) -page = page.data[0] -print(page.id) +print(project_hosted_tool_permissions.code_interpreter) ``` #### Response ```json { - "data": [ - { - "id": "id", - "max_requests_per_1_minute": 0, - "max_tokens_per_1_minute": 0, - "model": "model", - "object": "project.rate_limit", - "batch_1_day_max_input_tokens": 0, - "max_audio_megabytes_per_1_minute": 0, - "max_images_per_1_minute": 0, - "max_requests_per_1_day": 0 + "code_interpreter": { + "enabled": true + }, + "file_search": { + "enabled": true + }, + "image_generation": { + "enabled": true + }, + "mcp": { + "enabled": true + }, + "web_search": { + "enabled": true } - ], - "has_more": true, - "object": "list", - "first_id": "first_id", - "last_id": "last_id" } ``` -## Modify project rate limit +## Modify project hosted tool permissions -`admin.organization.projects.rate_limits.update_rate_limit(strrate_limit_id, RateLimitUpdateRateLimitParams**kwargs) -> ProjectRateLimit` +`admin.organization.projects.hosted_tool_permissions.update(strproject_id, HostedToolPermissionUpdateParams**kwargs) -> ProjectHostedToolPermissions` -**post** `/organization/projects/{project_id}/rate_limits/{rate_limit_id}` +**post** `/organization/projects/{project_id}/hosted_tool_permissions` -Updates a project rate limit. +Updates hosted tool permissions for a project. ### Parameters - `project_id: str` -- `rate_limit_id: str` +- `code_interpreter: Optional[CodeInterpreter]` -- `batch_1_day_max_input_tokens: Optional[int]` + The code interpreter permission update. - The maximum batch input tokens per day. Only relevant for certain models. + - `enabled: bool` -- `max_audio_megabytes_per_1_minute: Optional[int]` + Whether to enable the hosted tool for the project. - The maximum audio megabytes per minute. Only relevant for certain models. +- `file_search: Optional[FileSearch]` -- `max_images_per_1_minute: Optional[int]` + The file search permission update. - The maximum images per minute. Only relevant for certain models. + - `enabled: bool` -- `max_requests_per_1_day: Optional[int]` + Whether to enable the hosted tool for the project. - The maximum requests per day. Only relevant for certain models. +- `image_generation: Optional[ImageGeneration]` -- `max_requests_per_1_minute: Optional[int]` + The image generation permission update. - The maximum requests per minute. + - `enabled: bool` -- `max_tokens_per_1_minute: Optional[int]` + Whether to enable the hosted tool for the project. - The maximum tokens per minute. +- `mcp: Optional[Mcp]` + + The MCP permission update. + + - `enabled: bool` + + Whether to enable the hosted tool for the project. + +- `web_search: Optional[WebSearch]` + + The web search permission update. + + - `enabled: bool` + + Whether to enable the hosted tool for the project. ### Returns -- `class ProjectRateLimit: …` +- `class ProjectHostedToolPermissions: …` - Represents a project rate limit config. + Represents hosted tool permissions for a project. - - `id: str` + - `code_interpreter: CodeInterpreter` - The identifier, which can be referenced in API endpoints. + Permission state for a single hosted tool on a project. - - `max_requests_per_1_minute: int` + - `enabled: bool` - The maximum requests per minute. + Whether the hosted tool is enabled for the project. - - `max_tokens_per_1_minute: int` + - `file_search: FileSearch` - The maximum tokens per minute. + Permission state for a single hosted tool on a project. - - `model: str` + - `enabled: bool` - The model this rate limit applies to. + Whether the hosted tool is enabled for the project. - - `object: Literal["project.rate_limit"]` + - `image_generation: ImageGeneration` - The object type, which is always `project.rate_limit` + Permission state for a single hosted tool on a project. - - `"project.rate_limit"` + - `enabled: bool` - - `batch_1_day_max_input_tokens: Optional[int]` + Whether the hosted tool is enabled for the project. - The maximum batch input tokens per day. Only present for relevant models. + - `mcp: Mcp` - - `max_audio_megabytes_per_1_minute: Optional[int]` + Permission state for a single hosted tool on a project. - The maximum audio megabytes per minute. Only present for relevant models. + - `enabled: bool` - - `max_images_per_1_minute: Optional[int]` + Whether the hosted tool is enabled for the project. - The maximum images per minute. Only present for relevant models. + - `web_search: WebSearch` - - `max_requests_per_1_day: Optional[int]` + Permission state for a single hosted tool on a project. - The maximum requests per day. Only present for relevant models. + - `enabled: bool` + + Whether the hosted tool is enabled for the project. ### Example @@ -16121,74 +19548,81 @@ from openai import OpenAI client = OpenAI( admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"), # This is the default and can be omitted ) -project_rate_limit = client.admin.organization.projects.rate_limits.update_rate_limit( - rate_limit_id="rate_limit_id", +project_hosted_tool_permissions = client.admin.organization.projects.hosted_tool_permissions.update( project_id="project_id", ) -print(project_rate_limit.id) +print(project_hosted_tool_permissions.code_interpreter) ``` #### Response ```json { - "id": "id", - "max_requests_per_1_minute": 0, - "max_tokens_per_1_minute": 0, - "model": "model", - "object": "project.rate_limit", - "batch_1_day_max_input_tokens": 0, - "max_audio_megabytes_per_1_minute": 0, - "max_images_per_1_minute": 0, - "max_requests_per_1_day": 0 + "code_interpreter": { + "enabled": true + }, + "file_search": { + "enabled": true + }, + "image_generation": { + "enabled": true + }, + "mcp": { + "enabled": true + }, + "web_search": { + "enabled": true + } } ``` ## Domain Types -### Project Rate Limit +### Project Hosted Tool Permissions -- `class ProjectRateLimit: …` +- `class ProjectHostedToolPermissions: …` - Represents a project rate limit config. + Represents hosted tool permissions for a project. - - `id: str` + - `code_interpreter: CodeInterpreter` - The identifier, which can be referenced in API endpoints. + Permission state for a single hosted tool on a project. - - `max_requests_per_1_minute: int` + - `enabled: bool` - The maximum requests per minute. + Whether the hosted tool is enabled for the project. - - `max_tokens_per_1_minute: int` + - `file_search: FileSearch` - The maximum tokens per minute. + Permission state for a single hosted tool on a project. - - `model: str` + - `enabled: bool` - The model this rate limit applies to. + Whether the hosted tool is enabled for the project. - - `object: Literal["project.rate_limit"]` + - `image_generation: ImageGeneration` - The object type, which is always `project.rate_limit` + Permission state for a single hosted tool on a project. - - `"project.rate_limit"` + - `enabled: bool` - - `batch_1_day_max_input_tokens: Optional[int]` + Whether the hosted tool is enabled for the project. - The maximum batch input tokens per day. Only present for relevant models. + - `mcp: Mcp` - - `max_audio_megabytes_per_1_minute: Optional[int]` + Permission state for a single hosted tool on a project. - The maximum audio megabytes per minute. Only present for relevant models. + - `enabled: bool` - - `max_images_per_1_minute: Optional[int]` + Whether the hosted tool is enabled for the project. - The maximum images per minute. Only present for relevant models. + - `web_search: WebSearch` - - `max_requests_per_1_day: Optional[int]` + Permission state for a single hosted tool on a project. - The maximum requests per day. Only present for relevant models. + - `enabled: bool` + + Whether the hosted tool is enabled for the project. # Groups