UNPKG

@cotofe/service-of-litellm

Version:

OpenAPI client for @cotofe/service-of-litellm

328 lines (327 loc) 26.3 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.LitellmModelManagementApi = void 0; const runtime = require("../runtime"); /** * */ class LitellmModelManagementApi extends runtime.BaseAPI { /** * Allows adding new models to the model list in the config.yaml * Add New Model */ addNewModelModelNewPostRaw(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: `/model/new`, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.deployment, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response); } }); } /** * Allows adding new models to the model list in the config.yaml * Add New Model */ addNewModelModelNewPost() { return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) { const response = yield this.addNewModelModelNewPostRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * Allows deleting models in the model list in the config.yaml * Delete Model */ deleteModelModelDeletePostRaw(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: `/model/delete`, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.modelInfoDelete, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response); } }); } /** * Allows deleting models in the model list in the config.yaml * Delete Model */ deleteModelModelDeletePost() { return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) { const response = yield this.deleteModelModelDeletePostRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * Get information about all the deployments on litellm proxy, including config.yaml descriptions (except api key and api base) - /model_group/info returns all model groups. End users of proxy should use /model_group/info since those models will be used for /chat/completions, /embeddings, etc. - /model_group/info?model_group=rerank-english-v3.0 returns all model groups for a specific model group (`model_name` in config.yaml) Example Request (All Models): ```shell curl -X \'GET\' \'http://localhost:4000/model_group/info\' -H \'accept: application/json\' -H \'x-api-key: sk-1234\' ``` Example Request (Specific Model Group): ```shell curl -X \'GET\' \'http://localhost:4000/model_group/info?model_group=rerank-english-v3.0\' -H \'accept: application/json\' -H \'Authorization: Bearer sk-1234\' ``` Example Request (Specific Wildcard Model Group): (e.g. `model_name: openai/_*` on config.yaml) ```shell curl -X \'GET\' \'http://localhost:4000/model_group/info?model_group=openai/tts-1\' -H \'accept: application/json\' -H \'Authorization: Bearersk-1234\' ``` Learn how to use and set wildcard models [here](https://docs.litellm.ai/docs/wildcard_routing) Example Response: ```json { \"data\": [ { \"model_group\": \"rerank-english-v3.0\", \"providers\": [ \"cohere\" ], \"max_input_tokens\": null, \"max_output_tokens\": null, \"input_cost_per_token\": 0.0, \"output_cost_per_token\": 0.0, \"mode\": null, \"tpm\": null, \"rpm\": null, \"supports_parallel_function_calling\": false, \"supports_vision\": false, \"supports_function_calling\": false, \"supported_openai_params\": [ \"stream\", \"temperature\", \"max_tokens\", \"logit_bias\", \"top_p\", \"frequency_penalty\", \"presence_penalty\", \"stop\", \"n\", \"extra_headers\" ] }, { \"model_group\": \"gpt-3.5-turbo\", \"providers\": [ \"openai\" ], \"max_input_tokens\": 16385.0, \"max_output_tokens\": 4096.0, \"input_cost_per_token\": 1.5e-06, \"output_cost_per_token\": 2e-06, \"mode\": \"chat\", \"tpm\": null, \"rpm\": null, \"supports_parallel_function_calling\": false, \"supports_vision\": false, \"supports_function_calling\": true, \"supported_openai_params\": [ \"frequency_penalty\", \"logit_bias\", \"logprobs\", \"top_logprobs\", \"max_tokens\", \"max_completion_tokens\", \"n\", \"presence_penalty\", \"seed\", \"stop\", \"stream\", \"stream_options\", \"temperature\", \"top_p\", \"tools\", \"tool_choice\", \"function_call\", \"functions\", \"max_retries\", \"extra_headers\", \"parallel_tool_calls\", \"response_format\" ] }, { \"model_group\": \"llava-hf\", \"providers\": [ \"openai\" ], \"max_input_tokens\": null, \"max_output_tokens\": null, \"input_cost_per_token\": 0.0, \"output_cost_per_token\": 0.0, \"mode\": null, \"tpm\": null, \"rpm\": null, \"supports_parallel_function_calling\": false, \"supports_vision\": true, \"supports_function_calling\": false, \"supported_openai_params\": [ \"frequency_penalty\", \"logit_bias\", \"logprobs\", \"top_logprobs\", \"max_tokens\", \"max_completion_tokens\", \"n\", \"presence_penalty\", \"seed\", \"stop\", \"stream\", \"stream_options\", \"temperature\", \"top_p\", \"tools\", \"tool_choice\", \"function_call\", \"functions\", \"max_retries\", \"extra_headers\", \"parallel_tool_calls\", \"response_format\" ] } ] } ``` * Model Group Info */ modelGroupInfoModelGroupInfoGetRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = {}; if (requestParameters.modelGroup != null) { queryParameters.model_group = requestParameters.modelGroup; } 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: `/model_group/info`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response); } }); } /** * Get information about all the deployments on litellm proxy, including config.yaml descriptions (except api key and api base) - /model_group/info returns all model groups. End users of proxy should use /model_group/info since those models will be used for /chat/completions, /embeddings, etc. - /model_group/info?model_group=rerank-english-v3.0 returns all model groups for a specific model group (`model_name` in config.yaml) Example Request (All Models): ```shell curl -X \'GET\' \'http://localhost:4000/model_group/info\' -H \'accept: application/json\' -H \'x-api-key: sk-1234\' ``` Example Request (Specific Model Group): ```shell curl -X \'GET\' \'http://localhost:4000/model_group/info?model_group=rerank-english-v3.0\' -H \'accept: application/json\' -H \'Authorization: Bearer sk-1234\' ``` Example Request (Specific Wildcard Model Group): (e.g. `model_name: openai/_*` on config.yaml) ```shell curl -X \'GET\' \'http://localhost:4000/model_group/info?model_group=openai/tts-1\' -H \'accept: application/json\' -H \'Authorization: Bearersk-1234\' ``` Learn how to use and set wildcard models [here](https://docs.litellm.ai/docs/wildcard_routing) Example Response: ```json { \"data\": [ { \"model_group\": \"rerank-english-v3.0\", \"providers\": [ \"cohere\" ], \"max_input_tokens\": null, \"max_output_tokens\": null, \"input_cost_per_token\": 0.0, \"output_cost_per_token\": 0.0, \"mode\": null, \"tpm\": null, \"rpm\": null, \"supports_parallel_function_calling\": false, \"supports_vision\": false, \"supports_function_calling\": false, \"supported_openai_params\": [ \"stream\", \"temperature\", \"max_tokens\", \"logit_bias\", \"top_p\", \"frequency_penalty\", \"presence_penalty\", \"stop\", \"n\", \"extra_headers\" ] }, { \"model_group\": \"gpt-3.5-turbo\", \"providers\": [ \"openai\" ], \"max_input_tokens\": 16385.0, \"max_output_tokens\": 4096.0, \"input_cost_per_token\": 1.5e-06, \"output_cost_per_token\": 2e-06, \"mode\": \"chat\", \"tpm\": null, \"rpm\": null, \"supports_parallel_function_calling\": false, \"supports_vision\": false, \"supports_function_calling\": true, \"supported_openai_params\": [ \"frequency_penalty\", \"logit_bias\", \"logprobs\", \"top_logprobs\", \"max_tokens\", \"max_completion_tokens\", \"n\", \"presence_penalty\", \"seed\", \"stop\", \"stream\", \"stream_options\", \"temperature\", \"top_p\", \"tools\", \"tool_choice\", \"function_call\", \"functions\", \"max_retries\", \"extra_headers\", \"parallel_tool_calls\", \"response_format\" ] }, { \"model_group\": \"llava-hf\", \"providers\": [ \"openai\" ], \"max_input_tokens\": null, \"max_output_tokens\": null, \"input_cost_per_token\": 0.0, \"output_cost_per_token\": 0.0, \"mode\": null, \"tpm\": null, \"rpm\": null, \"supports_parallel_function_calling\": false, \"supports_vision\": true, \"supports_function_calling\": false, \"supported_openai_params\": [ \"frequency_penalty\", \"logit_bias\", \"logprobs\", \"top_logprobs\", \"max_tokens\", \"max_completion_tokens\", \"n\", \"presence_penalty\", \"seed\", \"stop\", \"stream\", \"stream_options\", \"temperature\", \"top_p\", \"tools\", \"tool_choice\", \"function_call\", \"functions\", \"max_retries\", \"extra_headers\", \"parallel_tool_calls\", \"response_format\" ] } ] } ``` * Model Group Info */ modelGroupInfoModelGroupInfoGet() { return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) { const response = yield this.modelGroupInfoModelGroupInfoGetRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * Provides more info about each model in /models, including config.yaml descriptions (except api key and api base) Parameters: litellm_model_id: Optional[str] = None (this is the value of `x-litellm-model-id` returned in response headers) - When litellm_model_id is passed, it will return the info for that specific model - When litellm_model_id is not passed, it will return the info for all models Returns: Returns a dictionary containing information about each model. Example Response: ```json { \"data\": [ { \"model_name\": \"fake-openai-endpoint\", \"litellm_params\": { \"api_base\": \"https://exampleopenaiendpoint-production.up.railway.app/\", \"model\": \"openai/fake\" }, \"model_info\": { \"id\": \"112f74fab24a7a5245d2ced3536dd8f5f9192c57ee6e332af0f0512e08bed5af\", \"db_model\": false } } ] } ``` * Model Info V1 */ modelInfoV1ModelInfoGetRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = {}; if (requestParameters.litellmModelId != null) { queryParameters.litellm_model_id = requestParameters.litellmModelId; } 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: `/model/info`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response); } }); } /** * Provides more info about each model in /models, including config.yaml descriptions (except api key and api base) Parameters: litellm_model_id: Optional[str] = None (this is the value of `x-litellm-model-id` returned in response headers) - When litellm_model_id is passed, it will return the info for that specific model - When litellm_model_id is not passed, it will return the info for all models Returns: Returns a dictionary containing information about each model. Example Response: ```json { \"data\": [ { \"model_name\": \"fake-openai-endpoint\", \"litellm_params\": { \"api_base\": \"https://exampleopenaiendpoint-production.up.railway.app/\", \"model\": \"openai/fake\" }, \"model_info\": { \"id\": \"112f74fab24a7a5245d2ced3536dd8f5f9192c57ee6e332af0f0512e08bed5af\", \"db_model\": false } } ] } ``` * Model Info V1 */ modelInfoV1ModelInfoGet() { return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) { const response = yield this.modelInfoV1ModelInfoGetRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * Use `/model/info` - to get detailed model information, example - pricing, mode, etc. This is just for compatibility with openai projects like aider. * Model List */ modelListModelsGetRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const queryParameters = {}; if (requestParameters.returnWildcardRoutes != null) { queryParameters.return_wildcard_routes = requestParameters.returnWildcardRoutes; } if (requestParameters.teamId != null) { queryParameters.team_id = requestParameters.teamId; } 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: `/models`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response); } }); } /** * Use `/model/info` - to get detailed model information, example - pricing, mode, etc. This is just for compatibility with openai projects like aider. * Model List */ modelListModelsGet() { return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) { const response = yield this.modelListModelsGetRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * PATCH Endpoint for partial model updates. Only updates the fields specified in the request while preserving other existing values. Follows proper PATCH semantics by only modifying provided fields. Args: model_id: The ID of the model to update patch_data: The fields to update and their new values user_api_key_dict: User authentication information Returns: Updated model information Raises: ProxyException: For various error conditions including authentication and database errors * Patch Model */ patchModelModelModelIdUpdatePatchRaw(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { if (requestParameters.modelId == null) { throw new runtime.RequiredError('modelId', 'Required parameter "modelId" was null or undefined when calling patchModelModelModelIdUpdatePatch().'); } 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: `/model/{model_id}/update`.replace(`{${'model_id'}}`, encodeURIComponent(String(requestParameters.modelId))), method: 'PATCH', headers: headerParameters, query: queryParameters, body: requestParameters.updateDeployment, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response); } }); } /** * PATCH Endpoint for partial model updates. Only updates the fields specified in the request while preserving other existing values. Follows proper PATCH semantics by only modifying provided fields. Args: model_id: The ID of the model to update patch_data: The fields to update and their new values user_api_key_dict: User authentication information Returns: Updated model information Raises: ProxyException: For various error conditions including authentication and database errors * Patch Model */ patchModelModelModelIdUpdatePatch(requestParameters, initOverrides) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.patchModelModelModelIdUpdatePatchRaw(requestParameters, initOverrides); return yield response.value(); }); } /** * Edit existing model params * Update Model */ updateModelModelUpdatePostRaw(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: `/model/update`, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.updateDeployment, }, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); } else { return new runtime.TextApiResponse(response); } }); } /** * Edit existing model params * Update Model */ updateModelModelUpdatePost() { return __awaiter(this, arguments, void 0, function* (requestParameters = {}, initOverrides) { const response = yield this.updateModelModelUpdatePostRaw(requestParameters, initOverrides); return yield response.value(); }); } } exports.LitellmModelManagementApi = LitellmModelManagementApi;