UNPKG

openai

Version:

The official TypeScript library for the OpenAI API

64 lines 2.13 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../../core/resource.mjs"; import { ConversationCursorPage, } from "../../../../core/pagination.mjs"; import { path } from "../../../../internal/utils/path.mjs"; export class APIKeys extends APIResource { /** * Retrieves an API key in the project. * * @example * ```ts * const projectAPIKey = * await client.admin.organization.projects.apiKeys.retrieve( * 'api_key_id', * { project_id: 'project_id' }, * ); * ``` */ retrieve(apiKeyID, params, options) { const { project_id } = params; return this._client.get(path `/organization/projects/${project_id}/api_keys/${apiKeyID}`, { ...options, __security: { adminAPIKeyAuth: true }, }); } /** * Returns a list of API keys in the project. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const projectAPIKey of client.admin.organization.projects.apiKeys.list( * 'project_id', * )) { * // ... * } * ``` */ list(projectID, query = {}, options) { return this._client.getAPIList(path `/organization/projects/${projectID}/api_keys`, (ConversationCursorPage), { query, ...options, __security: { adminAPIKeyAuth: true } }); } /** * Deletes an API key from the project. * * Returns confirmation of the key deletion, or an error if the key belonged to a * service account. * * @example * ```ts * const apiKey = * await client.admin.organization.projects.apiKeys.delete( * 'api_key_id', * { project_id: 'project_id' }, * ); * ``` */ delete(apiKeyID, params, options) { const { project_id } = params; return this._client.delete(path `/organization/projects/${project_id}/api_keys/${apiKeyID}`, { ...options, __security: { adminAPIKeyAuth: true }, }); } } //# sourceMappingURL=api-keys.mjs.map