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]

fastuuid optional dependency

Alex Shoopc51e0fc54e6f
diff --git a/litellm/_uuid.py b/litellm/_uuid.py
new file mode 100644
index 00000000000..05b1adbf75b
--- /dev/null
+++ b/litellm/_uuid.py
@@ -0,0 +1,23 @@
+"""
+Internal unified UUID helper.
+
+Tries to use fastuuid (performance) and falls back to stdlib uuid if unavailable.
+"""
+
+FASTUUID_AVAILABLE = False
+
+try:
+ import fastuuid as _uuid # type: ignore
+
+ FASTUUID_AVAILABLE = True
+except Exception: # pragma: no cover - fallback path
+ import uuid as _uuid # type: ignore
+
+
+# Expose a module-like alias so callers can use: uuid.uuid4()
+uuid = _uuid
+
+
+def uuid4():
+ """Return a UUID4 using the selected backend."""
+ return uuid.uuid4()
diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py
index 059fd9f1fcf..9d67ec1a867 100644
--- a/litellm/litellm_core_utils/litellm_logging.py
+++ b/litellm/litellm_core_utils/litellm_logging.py
@@ -26,7 +26,7 @@ from typing import (
cast,
)
-import fastuuid as uuid
+from .._uuid import uuid
from httpx import Response
from pydantic import BaseModel
diff --git a/litellm/llms/bedrock/common_utils.py b/litellm/llms/bedrock/common_utils.py
index c7f7acf331d..edfbca8fce6 100644
--- a/litellm/llms/bedrock/common_utils.py
+++ b/litellm/llms/bedrock/common_utils.py
@@ -774,7 +774,7 @@ class CommonBatchFilesUtils:
Returns:
Unique job name (≤ 63 characters for Bedrock compatibility)
"""
- import fastuuid as uuid
+ from ..._uuid import uuid
unique_id = str(uuid.uuid4())[:8]
# Format: {prefix}-batch-{model}-{uuid}
# Example: litellm-batch-claude-266c398e
diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.py
index 5739e652043..3807559b35d 100644
--- a/litellm/proxy/common_request_processing.py
+++ b/litellm/proxy/common_request_processing.py
@@ -14,7 +14,7 @@ from typing import (
Union,
)
-import fastuuid as uuid
+from .._uuid import uuid
import httpx
import orjson
from fastapi import HTTPException, Request, status
diff --git a/litellm/types/utils.py b/litellm/types/utils.py
index 25f353b3bc3..e89a98fb2e0 100644
--- a/litellm/types/utils.py
+++ b/litellm/types/utils.py
@@ -13,7 +13,7 @@ from typing import (
Union,
)
-import fastuuid as uuid
+from .._uuid import uuid
from aiohttp import FormData
from openai._models import BaseModel as OpenAIObject
from openai.types.audio.transcription_create_params import FileTypes # type: ignore
diff --git a/litellm/utils.py b/litellm/utils.py
index e4cbaec7065..6edb44e48d6 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -40,7 +40,7 @@ from os.path import abspath, dirname, join
import aiohttp
import dotenv
-import fastuuid as uuid
+from ._uuid import uuid
import httpx
import openai
import tiktoken
diff --git a/poetry.lock b/poetry.lock
index 4d0e3bea696..4eb9cae6082 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -555,7 +555,7 @@ description = "Foreign Function Interface for Python calling C code."
optional = false
python-versions = ">=3.8"
groups = ["main", "dev", "proxy-dev"]
-markers = "python_version < \"3.14\" and platform_python_implementation != \"PyPy\""
+markers = "python_version < \"3.10\" and platform_python_implementation != \"PyPy\""
files = [
{file = "cffi-1.17.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:df8b1c11f177bc2313ec4b2d46baec87a5f3e71fc8b45dab2ee7cae86d9aba14"},
{file = "cffi-1.17.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8f2cdc858323644ab277e9bb925ad72ae0e67f69e804f4898c070998d50b1a67"},
@@ -636,7 +636,7 @@ description = "Foreign Function Interface for Python calling C code."
optional = false
python-versions = ">=3.9"
groups = ["main", "dev", "proxy-dev"]
-markers = "platform_python_implementation != \"PyPy\" and python_version >= \"3.14\""
+markers = "python_version >= \"3.10\" and platform_python_implementation != \"PyPy\""
files = [
{file = "cffi-2.0.0-cp310-cp310-macosx_10_13_x86_64.whl", hash = "sha256:0cf2d91ecc3fcc0625c2c530fe004f82c110405f101548512cce44322fa8ac44"},
{file = "cffi-2.0.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f73b96c41e3b2adedc34a7356e64c8eb96e03a3782b535e043a986276ce12a49"},
@@ -1339,9 +1339,10 @@ zstandard = ["zstandard"]
name = "fastuuid"
version = "0.12.0"
description = "Python bindings to Rust's UUID library."
-optional = false
+optional = true
python-versions = ">=3.8"
groups = ["main"]
+markers = "extra == \"perf\""
files = [
{file = "fastuuid-0.12.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:22a900ef0956aacf862b460e20541fdae2d7c340594fe1bd6fdcb10d5f0791a9"},
{file = "fastuuid-0.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0302f5acf54dc75de30103025c5a95db06d6c2be36829043a0aa16fc170076bc"},
@@ -4361,7 +4362,7 @@ description = "C parser in Python"
optional = false
python-versions = ">=3.8"
groups = ["main", "dev", "proxy-dev"]
-markers = "platform_python_implementation != \"PyPy\" and (python_version < \"3.14\" or implementation_name != \"PyPy\")"
+markers = "platform_python_implementation != \"PyPy\" and (implementation_name != \"PyPy\" or python_version < \"3.10\")"
files = [
{file = "pycparser-2.23-py3-none-any.whl", hash = "sha256:e5c6e8d3fbad53479cab09ac03729e0a9faf2bee3db8208a550daf5af81a5934"},
{file = "pycparser-2.23.tar.gz", hash = "sha256:78816d4f24add8f10a06d6f05b4d424ad9e96cfebf68a4ddc99c65c0720d00c2"},
@@ -6746,6 +6747,7 @@ type = ["pytest-mypy"]
caching = ["diskcache"]
extra-proxy = ["azure-identity", "azure-keyvault-secrets", "google-cloud-iam", "google-cloud-kms", "prisma", "redisvl", "resend"]
mlflow = ["mlflow"]
+perf = ["fastuuid"]
proxy = ["PyJWT", "apscheduler", "azure-identity", "azure-storage-blob", "backoff", "boto3", "cryptography", "fastapi", "fastapi-sso", "gunicorn", "litellm-enterprise", "litellm-proxy-extras", "mcp", "orjson", "polars", "pynacl", "python-multipart", "pyyaml", "rich", "rq", "uvicorn", "uvloop", "websockets"]
semantic-router = ["semantic-router"]
utils = ["numpydoc"]
@@ -6753,4 +6755,4 @@ utils = ["numpydoc"]
[metadata]
lock-version = "2.1"
python-versions = ">=3.8.1,<4.0, !=3.9.7"
-content-hash = "dcec654bc4b233d2f0d160341d8adf1ba2017ccb74c104bff9ba4cf027ba0186"
+content-hash = "608a9e7680b4109b938a642007a80cc8e8fa57142b614a17b9e9723c8380b2cd"
diff --git a/pyproject.toml b/pyproject.toml
index 81104d072ee..471e1d17387 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -20,7 +20,6 @@ Documentation = "https://docs.litellm.ai"
[tool.poetry.dependencies]
python = ">=3.8.1,<4.0, !=3.9.7"
-fastuuid = ">=0.12.0"
httpx = ">=0.23.0"
openai = ">=1.99.5"
python-dotenv = ">=0.2.0"
@@ -34,6 +33,7 @@ pydantic = "^2.5.0"
jsonschema = "^4.22.0"
pondpond = "^1.4.1"
numpydoc = {version = "*", optional = true} # used in utils.py
+fastuuid = {version = ">=0.12.0", optional = true}
uvicorn = {version = "^0.29.0", optional = true}
uvloop = {version = "^0.21.0", optional = true, markers="sys_platform != 'win32'"}
@@ -115,6 +115,8 @@ semantic-router = ["semantic-router"]
mlflow = ["mlflow"]
+perf = ["fastuuid"]
+
[tool.isort]
profile = "black"
diff --git a/requirements.txt b/requirements.txt
index 41f4c646958..a276da2da72 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -8,7 +8,8 @@ backoff==2.2.1 # server dep
pyyaml==6.0.2 # server dep
uvicorn==0.29.0 # server dep
gunicorn==23.0.0 # server dep
-fastuuid==0.12.0 # for uuid4
+# Optional performance extra: install via `pip install litellm[perf]`
+# fastuuid==0.12.0 # for uuid4
uvloop==0.21.0 # uvicorn dep, gives us much better performance under load
boto3==1.36.0 # aws bedrock/sagemaker calls
redis==5.2.1 # redis caching
@@ -58,7 +59,7 @@ tenacity==8.2.3 # for retrying requests, when litellm.num_retries set
pydantic==2.10.2 # proxy + openai req.
jsonschema==4.22.0 # validating json schema
websockets==13.1.0 # for realtime API
-pondpond==1.4.1 # for object pooling
+# pondpond==1.4.1 # for object pooling
########################
# LITELLM ENTERPRISE DEPENDENCIES
diff --git a/tests/test_uuid_fallback.py b/tests/test_uuid_fallback.py
new file mode 100644
index 00000000000..e18bdabda8a
--- /dev/null
+++ b/tests/test_uuid_fallback.py
@@ -0,0 +1,11 @@
+import importlib
+
+
+def test_fastuuid_flag_exposed():
+ mod = importlib.import_module("litellm._uuid")
+ assert hasattr(mod, "FASTUUID_AVAILABLE")
+ assert hasattr(mod, "uuid4")
+ # Ensure uuid4 returns something that looks like a UUID string
+ val = str(mod.uuid4())
+ assert isinstance(val, str)
+ assert len(val) >= 8