{"record":{"id":"c06e24a712575182","repo":"BerriAI/litellm","slug":"new-key-must-start-with-sk-this-is-to-distingu","errorCode":null,"errorMessage":"New key must start with 'sk-'. This is to distinguish a key hash (used by litellm for logging / internal logic) from the actual key.","messagePattern":"New key must start with 'sk-'\\. This is to distinguish a key hash \\(used by litellm for logging / internal logic\\) from the actual key\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/management_endpoints/key_management_endpoints.py","lineNumber":4607,"sourceCode":"    from litellm.proxy.proxy_server import prisma_client\n\n    _require_proxy_admin(user_api_key_dict)\n    if prisma_client is None:\n        raise HTTPException(\n            status_code=500,\n            detail={\"error\": CommonProxyErrors.db_not_connected_error.value},\n        )\n\n    report: Final = await check_encryption(prisma_client=prisma_client)\n    return {\"status\": \"success\", \"report\": report.as_dict()}\n\n\nasync def get_new_token(data: RegenerateKeyRequest | None) -> str:\n    if data and data.new_key is not None:\n        # Reject custom key values if disabled by admin\n        await _check_custom_key_allowed(data.new_key)\n        if not data.new_key.startswith(\"sk-\"):\n            raise HTTPException(\n                status_code=status.HTTP_400_BAD_REQUEST,\n                detail={\n                    \"error\": \"New key must start with 'sk-'. This is to distinguish a key hash (used by litellm for logging / internal logic) from the actual key.\"\n                },\n            )\n        if len(data.new_key) < MINIMUM_CUSTOM_KEY_LENGTH:\n            raise HTTPException(\n                status_code=status.HTTP_400_BAD_REQUEST,\n                detail={\"error\": f\"New key must be at least {MINIMUM_CUSTOM_KEY_LENGTH} characters long.\"},\n            )\n        new_token = data.new_key\n    else:\n        new_token = f\"sk-{secrets.token_urlsafe(LENGTH_OF_LITELLM_GENERATED_KEY)}\"\n    return new_token\n\n\nasync def _insert_deprecated_key(\n    prisma_client: \"PrismaClient\",","sourceCodeStart":4589,"sourceCodeEnd":4625,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/key_management_endpoints.py#L4589-L4625","documentation":"Error \"New key must start with 'sk-'. This is to distinguish a key hash (used by litellm for logging / internal logic) from the actual key.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/key_management_endpoints.py:4607 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a new key value that starts with the 'sk-' prefix.","Omit the custom key to let the proxy auto-generate a properly formatted key."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}