UNPKG

@cotofe/service-of-litellm

Version:

OpenAPI client for @cotofe/service-of-litellm

310 lines (309 loc) 21.5 kB
"use strict"; /** * Platform * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CustomerManagementApi = void 0; const runtime = require("../runtime"); /** * */ class CustomerManagementApi extends runtime.BaseAPI { /** * [BETA] Reject calls with this end-user id Parameters: - user_ids (List[str], required): The unique `user_id`s for the users to block (any /chat/completion call with this user={end-user-id} param, will be rejected.) ``` curl -X POST \"http://0.0.0.0:8000/user/block\" -H \"Authorization: Bearer sk-1234\" -d \'{ \"user_ids\": [<user_id>, ...] }\' ``` * Block User */ blockUserCustomerBlockPostRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = yield token('bearer', []); if (tokenString) { headerParameters.Authorization = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/customer/block`, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.blockUsers, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response); } }); } /** * [BETA] Reject calls with this end-user id Parameters: - user_ids (List[str], required): The unique `user_id`s for the users to block (any /chat/completion call with this user={end-user-id} param, will be rejected.) ``` curl -X POST \"http://0.0.0.0:8000/user/block\" -H \"Authorization: Bearer sk-1234\" -d \'{ \"user_ids\": [<user_id>, ...] }\' ``` * Block User */ blockUserCustomerBlockPost() { return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) { const response = yield this.blockUserCustomerBlockPostRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * Delete multiple end-users. Parameters: - user_ids (List[str], required): The unique `user_id`s for the users to delete Example curl: ``` curl --location \'http://0.0.0.0:4000/customer/delete\' --header \'Authorization: Bearer sk-1234\' --header \'Content-Type: application/json\' --data \'{ \"user_ids\" :[\"ishaan-jaff-5\"] }\' See below for all params ``` * Delete End User */ deleteEndUserCustomerDeletePostRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = yield token('bearer', []); if (tokenString) { headerParameters.Authorization = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/customer/delete`, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.deleteCustomerRequest, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response); } }); } /** * Delete multiple end-users. Parameters: - user_ids (List[str], required): The unique `user_id`s for the users to delete Example curl: ``` curl --location \'http://0.0.0.0:4000/customer/delete\' --header \'Authorization: Bearer sk-1234\' --header \'Content-Type: application/json\' --data \'{ \"user_ids\" :[\"ishaan-jaff-5\"] }\' See below for all params ``` * Delete End User */ deleteEndUserCustomerDeletePost() { return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) { const response = yield this.deleteEndUserCustomerDeletePostRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * Get information about an end-user. An `end_user` is a customer (external user) of the proxy. Parameters: - end_user_id (str, required): The unique identifier for the end-user Example curl: ``` curl -X GET \'http://localhost:4000/customer/info?end_user_id=test-litellm-user-4\' -H \'Authorization: Bearer sk-1234\' ``` * End User Info */ endUserInfoCustomerInfoGetRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { if (requestParameters.endUserId == null) { throw new runtime.RequiredError('endUserId', 'Required parameter "endUserId" was null or undefined when calling endUserInfoCustomerInfoGet().'); } const queryParameters = {}; if (requestParameters.endUserId != null) { queryParameters.end_user_id = requestParameters.endUserId; } const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = yield token('bearer', []); if (tokenString) { headerParameters.Authorization = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/customer/info`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response); }); } /** * Get information about an end-user. An `end_user` is a customer (external user) of the proxy. Parameters: - end_user_id (str, required): The unique identifier for the end-user Example curl: ``` curl -X GET \'http://localhost:4000/customer/info?end_user_id=test-litellm-user-4\' -H \'Authorization: Bearer sk-1234\' ``` * End User Info */ endUserInfoCustomerInfoGet(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.endUserInfoCustomerInfoGetRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * [Admin-only] List all available customers Example curl: ``` curl --location --request GET \'http://0.0.0.0:4000/customer/list\' --header \'Authorization: Bearer sk-1234\' ``` * List End User */ listEndUserCustomerListGetRaw(initOverrides) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = yield token('bearer', []); if (tokenString) { headerParameters.Authorization = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/customer/list`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response); }); } /** * [Admin-only] List all available customers Example curl: ``` curl --location --request GET \'http://0.0.0.0:4000/customer/list\' --header \'Authorization: Bearer sk-1234\' ``` * List End User */ listEndUserCustomerListGet(initOverrides) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.listEndUserCustomerListGetRaw(initOverrides); return yield response.value(); }); } /** * Allow creating a new Customer Parameters: - user_id: str - The unique identifier for the user. - alias: Optional[str] - A human-friendly alias for the user. - blocked: bool - Flag to allow or disallow requests for this end-user. Default is False. - max_budget: Optional[float] - The maximum budget allocated to the user. Either \'max_budget\' or \'budget_id\' should be provided, not both. - budget_id: Optional[str] - The identifier for an existing budget allocated to the user. Either \'max_budget\' or \'budget_id\' should be provided, not both. - allowed_model_region: Optional[Union[Literal[\"eu\"], Literal[\"us\"]]] - Require all user requests to use models in this specific region. - default_model: Optional[str] - If no equivalent model in the allowed region, default all requests to this model. - metadata: Optional[dict] = Metadata for customer, store information for customer. Example metadata = {\"data_training_opt_out\": True} - budget_duration: Optional[str] - Budget is reset at the end of specified duration. If not set, budget is never reset. You can set duration as seconds (\"30s\"), minutes (\"30m\"), hours (\"30h\"), days (\"30d\"). - tpm_limit: Optional[int] - [Not Implemented Yet] Specify tpm limit for a given customer (Tokens per minute) - rpm_limit: Optional[int] - [Not Implemented Yet] Specify rpm limit for a given customer (Requests per minute) - model_max_budget: Optional[dict] - [Not Implemented Yet] Specify max budget for a given model. Example: {\"openai/gpt-4o-mini\": {\"max_budget\": 100.0, \"budget_duration\": \"1d\"}} - max_parallel_requests: Optional[int] - [Not Implemented Yet] Specify max parallel requests for a given customer. - soft_budget: Optional[float] - [Not Implemented Yet] Get alerts when customer crosses given budget, doesn\'t block requests. - Allow specifying allowed regions - Allow specifying default model Example curl: ``` curl --location \'http://0.0.0.0:4000/customer/new\' --header \'Authorization: Bearer sk-1234\' --header \'Content-Type: application/json\' --data \'{ \"user_id\" : \"ishaan-jaff-3\", \"allowed_region\": \"eu\", \"budget_id\": \"free_tier\", \"default_model\": \"azure/gpt-3.5-turbo-eu\" <- all calls from this user, use this model? }\' # return end-user object ``` NOTE: This used to be called `/end_user/new`, we will still be maintaining compatibility for /end_user/XXX for these endpoints * New End User */ newEndUserCustomerNewPostRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = yield token('bearer', []); if (tokenString) { headerParameters.Authorization = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/customer/new`, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.newCustomerRequest, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response); } }); } /** * Allow creating a new Customer Parameters: - user_id: str - The unique identifier for the user. - alias: Optional[str] - A human-friendly alias for the user. - blocked: bool - Flag to allow or disallow requests for this end-user. Default is False. - max_budget: Optional[float] - The maximum budget allocated to the user. Either \'max_budget\' or \'budget_id\' should be provided, not both. - budget_id: Optional[str] - The identifier for an existing budget allocated to the user. Either \'max_budget\' or \'budget_id\' should be provided, not both. - allowed_model_region: Optional[Union[Literal[\"eu\"], Literal[\"us\"]]] - Require all user requests to use models in this specific region. - default_model: Optional[str] - If no equivalent model in the allowed region, default all requests to this model. - metadata: Optional[dict] = Metadata for customer, store information for customer. Example metadata = {\"data_training_opt_out\": True} - budget_duration: Optional[str] - Budget is reset at the end of specified duration. If not set, budget is never reset. You can set duration as seconds (\"30s\"), minutes (\"30m\"), hours (\"30h\"), days (\"30d\"). - tpm_limit: Optional[int] - [Not Implemented Yet] Specify tpm limit for a given customer (Tokens per minute) - rpm_limit: Optional[int] - [Not Implemented Yet] Specify rpm limit for a given customer (Requests per minute) - model_max_budget: Optional[dict] - [Not Implemented Yet] Specify max budget for a given model. Example: {\"openai/gpt-4o-mini\": {\"max_budget\": 100.0, \"budget_duration\": \"1d\"}} - max_parallel_requests: Optional[int] - [Not Implemented Yet] Specify max parallel requests for a given customer. - soft_budget: Optional[float] - [Not Implemented Yet] Get alerts when customer crosses given budget, doesn\'t block requests. - Allow specifying allowed regions - Allow specifying default model Example curl: ``` curl --location \'http://0.0.0.0:4000/customer/new\' --header \'Authorization: Bearer sk-1234\' --header \'Content-Type: application/json\' --data \'{ \"user_id\" : \"ishaan-jaff-3\", \"allowed_region\": \"eu\", \"budget_id\": \"free_tier\", \"default_model\": \"azure/gpt-3.5-turbo-eu\" <- all calls from this user, use this model? }\' # return end-user object ``` NOTE: This used to be called `/end_user/new`, we will still be maintaining compatibility for /end_user/XXX for these endpoints * New End User */ newEndUserCustomerNewPost() { return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) { const response = yield this.newEndUserCustomerNewPostRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * [BETA] Unblock calls with this user id Example ``` curl -X POST \"http://0.0.0.0:8000/user/unblock\" -H \"Authorization: Bearer sk-1234\" -d \'{ \"user_ids\": [<user_id>, ...] }\' ``` * Unblock User */ unblockUserCustomerUnblockPostRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = yield token('bearer', []); if (tokenString) { headerParameters.Authorization = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/customer/unblock`, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.blockUsers, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response); } }); } /** * [BETA] Unblock calls with this user id Example ``` curl -X POST \"http://0.0.0.0:8000/user/unblock\" -H \"Authorization: Bearer sk-1234\" -d \'{ \"user_ids\": [<user_id>, ...] }\' ``` * Unblock User */ unblockUserCustomerUnblockPost() { return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) { const response = yield this.unblockUserCustomerUnblockPostRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * Example curl Parameters: - user_id: str - alias: Optional[str] = None # human-friendly alias - blocked: bool = False # allow/disallow requests for this end-user - max_budget: Optional[float] = None - budget_id: Optional[str] = None # give either a budget_id or max_budget - allowed_model_region: Optional[AllowedModelRegion] = ( None # require all user requests to use models in this specific region ) - default_model: Optional[str] = ( None # if no equivalent model in allowed region - default all requests to this model ) Example curl: ``` curl --location \'http://0.0.0.0:4000/customer/update\' --header \'Authorization: Bearer sk-1234\' --header \'Content-Type: application/json\' --data \'{ \"user_id\": \"test-litellm-user-4\", \"budget_id\": \"paid_tier\" }\' See below for all params ``` * Update End User */ updateEndUserCustomerUpdatePostRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = yield token('bearer', []); if (tokenString) { headerParameters.Authorization = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/customer/update`, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.updateCustomerRequest, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response); } }); } /** * Example curl Parameters: - user_id: str - alias: Optional[str] = None # human-friendly alias - blocked: bool = False # allow/disallow requests for this end-user - max_budget: Optional[float] = None - budget_id: Optional[str] = None # give either a budget_id or max_budget - allowed_model_region: Optional[AllowedModelRegion] = ( None # require all user requests to use models in this specific region ) - default_model: Optional[str] = ( None # if no equivalent model in allowed region - default all requests to this model ) Example curl: ``` curl --location \'http://0.0.0.0:4000/customer/update\' --header \'Authorization: Bearer sk-1234\' --header \'Content-Type: application/json\' --data \'{ \"user_id\": \"test-litellm-user-4\", \"budget_id\": \"paid_tier\" }\' See below for all params ``` * Update End User */ updateEndUserCustomerUpdatePost() { return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) { const response = yield this.updateEndUserCustomerUpdatePostRaw(requestParameters, initOverrides); return yield response.value(); }); } } exports.CustomerManagementApi = CustomerManagementApi;