From dc00b4a7edb0cf20186df680828e16c9f106cc96 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Thu, 16 May 2024 15:47:40 -0700 Subject: [PATCH] fix(utils.py): update completion_cost docstring --- litellm/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index cef6bc7287..03d066d5a7 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -4422,15 +4422,17 @@ def completion_cost( Returns: float: The cost in USD dollars for the completion based on the provided parameters. + Exceptions: + Raises exception if model not in the litellm model cost map. Register model, via custom pricing or PR - https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json + + Note: + - For custom pricing, see this - https://docs.litellm.ai/docs/proxy/custom_pricing - If completion_response is provided, the function extracts token information and the model name from it. - If completion_response is not provided, the function calculates token counts based on the model and input text. - The cost is calculated based on the model, prompt tokens, and completion tokens. - For certain models containing "togethercomputer" in the name, prices are based on the model size. - For un-mapped Replicate models, the cost is calculated based on the total time used for the request. - - Exceptions: - - If an error occurs during execution, the error is raised """ try: if (