BerriAI/litellm · critical · ValueError
Prisma client is not initialized. Database connection…
Error message
Prisma client is not initialized. Database connection required for LiteLLM skills.
What it means
All LiteLLM skills CRUD operations go through the proxy's shared Prisma client (litellm.proxy.proxy_server.prisma_client). That object only exists when the proxy started with a working database connection; if it is None — DATABASE_URL unset or the DB connection failed at startup — _get_prisma_client raises ValueError for every skills call.
Solutions
- Set DATABASE_URL (e.g. postgres://...) in the proxy's environment and restart it so Prisma connects
- Check proxy startup logs for Prisma connect/migration errors and fix them
- Run prisma migrations if the schema is not yet initialized
- Confirm you are calling the proxy instance that actually has the database configured, not a separate bare one
Example fix
# before litellm --config config.yaml --port 4000 # started without DATABASE_URL # -> POST /v1/skills -> 500 ValueError: Prisma client is not initialized # after export DATABASE_URL="postgresql://user:pass@host:5432/litellm" litellm --config config.yaml --port 4000 # prisma_client connects at startup
Defensive patterns
Strategy: validation
Validate before calling
import os
if not os.getenv("DATABASE_URL"):
raise SystemExit("Skills endpoints require a database — set DATABASE_URL before starting the proxy")
# alternatively at request time:
# from litellm.proxy.proxy_server import prisma_client
# if prisma_client is None: return JSONResponse(status_code=503, content={"error": "database not configured"}) Try / catch
try:
skill = await LiteLLMSkillsHandler.get_skill(skill_id, user_api_key_dict=auth)
except ValueError as e:
if "Prisma client is not initialized" in str(e):
raise HTTPException(status_code=503, detail="Skills unavailable: database not configured") from e
raise Prevention
- Always start the proxy with DATABASE_URL when skills routes are exposed
- Run startup health checks that assert prisma_client is not None before accepting traffic
- In tests, initialize a Prisma test client (or skip skills tests) instead of hitting the None guard
When it happens
Trigger: Hitting the proxy's skills endpoints (create/get/update/delete skill) or calling LiteLLMSkillsHandler methods directly while the proxy server runs without a database; unit tests importing the handler without initializing prisma; DB went down after startup and the client was never constructed.
Common situations: Starting litellm proxy without DATABASE_URL (in-memory mode) but exposing skills routes; Prisma migration/connection failure at boot that was missed in the logs; CI tests exercising skills without a database fixture.
Related errors
- DB not connected. This endpoint needs a database; set…
- DB not connected. This endpoint needs a database; set…
- No db connected
- No DB Connected. See -…
- Prisma client not initialized
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/83a7ba8027dacdb7.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/litellm_proxy/skills/handler.py:58
data: Final = prisma_skill.model_dump()
if data.get("file_content") is not None:
if isinstance(data["file_content"], str):
data["file_content"] = base64.b64decode(data["file_content"])
return LiteLLM_SkillsTable(**data)
class LiteLLMSkillsHandler:
"""CRUD for skills stored in ``litellm_skillstable``."""
@staticmethod
async def _get_prisma_client():
from litellm.proxy.proxy_server import prisma_client
if prisma_client is None:
raise ValueError("Prisma client is not initialized. Database connection required for LiteLLM skills.")
return prisma_client
@staticmethod
async def create_skill(
data: NewSkillRequest,
user_id: str | None = None,
user_api_key_dict: UserAPIKeyAuth | None = None,
) -> LiteLLM_SkillsTable:
prisma_client: Final = await LiteLLMSkillsHandler._get_prisma_client()
skill_id: Final = f"{LITELLM_SKILL_ID_PREFIX}{uuid.uuid4()}"
owner: Final = get_primary_resource_owner_scope(user_api_key_dict) or user_id
if owner is None:
# Identity-less callers (no user_id / team_id / org_id /
# api_key / token) can't be uniquely stamped on the row.
# Stamping a placeholder would let any two such callers see
# each other's skills via the shared owner. ValueError keeps
# this module FastAPI-free per the project layering rule.View on GitHub (pinned to 77b7c6c40c)