{"record":{"id":"5f7e08bd0dd50602","repo":"BerriAI/litellm","slug":"500-5f7e08","errorCode":"500","errorMessage":"Cache type {litellm.cache.type} does not support deleting a key. only `redis` is supported","messagePattern":"Cache type (.+?) does not support deleting a key\\. only `redis` is supported","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"litellm/proxy/caching_routes.py","lineNumber":154,"sourceCode":"    -H \"Authorization: Bearer sk-1234\" \\\n    -d '{\"keys\": [\"key1\", \"key2\"]}'\n    ```\n\n    \"\"\"\n    try:\n        if litellm.cache is None:\n            raise HTTPException(status_code=503, detail=\"Cache not initialized. litellm.cache is None\")\n\n        request_data: Final = await request.json()\n        keys: Final = request_data.get(\"keys\", None)\n\n        if litellm.cache.type == \"redis\":\n            await litellm.cache.delete_cache_keys(keys=keys)\n            return {\n                \"status\": \"success\",\n            }\n        else:\n            raise HTTPException(\n                status_code=500,\n                detail=f\"Cache type {litellm.cache.type} does not support deleting a key. only `redis` is supported\",\n            )\n    except Exception as e:\n        raise HTTPException(\n            status_code=500,\n            detail=f\"Cache Delete Failed({e})\",\n        )\n\n\ndef _get_redis_client_info(cache_instance) -> tuple[list, int]:\n    \"\"\"\n    Helper function to safely get Redis client list information.\n\n    Returns:\n        tuple: (client_list, num_clients) where num_clients is -1 if CLIENT LIST is unavailable\n    \"\"\"\n    try:","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/caching_routes.py#L136-L172","documentation":"POST /cache/delete only implements key deletion for the plain Redis backend (litellm.cache.delete_cache_keys). With any other cache type (local, disk, redis-semantic-cache, dual-cache) it raises HTTPException 500 'Cache type X does not support deleting a key. only `redis` is supported'; the handler's catch-all then re-wraps it into 'Cache Delete Failed(500: Cache type ...)' on the wire.","triggerScenarios":"POST /cache/delete on a proxy whose cache_settings.type is anything except 'redis' - e.g. redis-semantic-cache, local, disk, dual-cache.","commonSituations":"Semantic-caching deployments trying to purge specific entries; local dev running the default in-memory cache; backend switched without updating cleanup jobs.","solutions":["Switch cache_settings.type to 'redis' if API-based key deletion is required.","Otherwise delete entries directly on the real backend (semantic-cache entries live in Redis - delete by key pattern; local cache clears on restart)."],"exampleFix":"# before\nlitellm_settings:\n  cache_settings:\n    type: redis-semantic-cache   # /cache/delete rejects non-redis\n# after\nlitellm_settings:\n  cache_settings:\n    type: redis","handlingStrategy":"type-guard","validationCode":"import httpx\n\ndef cache_type_supports_delete(base_url: str, api_key: str) -> bool:\n    r = httpx.get(f'{base_url}/cache/ping', headers={'Authorization': f'Bearer {api_key}'})\n    if r.status_code != 200:\n        return False\n    return r.json().get('cache_type') == 'redis'","typeGuard":"def supports_cache_key_deletion(cache_type: str) -> bool:\n    return cache_type == 'redis'","tryCatchPattern":"r = httpx.post(f'{base}/cache/delete', headers=auth, json={'keys': keys})\nif r.status_code == 500 and 'does not support deleting a key' in r.text:\n    purge_backend_directly()  # non-redis cache - bypass the endpoint","preventionTips":["Check cache_settings.type before building tooling that assumes /cache/delete works.","Only plain 'redis' supports API key deletion; semantic/dual/local caches need direct purges.","Document the backend per environment next to cleanup scripts."],"tags":["litellm-proxy","cache","redis","unsupported-operation","cache-delete","http-500"],"backgroundTag":"unsupported-cache-type","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}