Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

use file_checksum

Ishaan Jaffc19066e78ebb
diff --git a/litellm/utils.py b/litellm/utils.py
index fbe6bd26e01..c859a962d70 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -13,6 +13,7 @@ import base64
import binascii
import copy
import datetime
+import hashlib
import inspect
import itertools
import json
@@ -554,6 +555,12 @@ def function_setup(
):
_file_name: BinaryIO = args[1] if len(args) > 1 else kwargs["file"]
file_name = getattr(_file_name, "name", "audio_file")
+ # Add file checksum to metadata
+ file_checksum = hashlib.sha256(_file_name.read()).hexdigest()
+ if "metadata" in kwargs:
+ kwargs["metadata"]["file_checksum"] = file_checksum
+ else:
+ kwargs["metadata"] = {"file_checksum": file_checksum}
messages = file_name
elif (
call_type == CallTypes.aspeech.value or call_type == CallTypes.speech.value