{"record":{"id":"c1693790c1ea4aa0","repo":"BerriAI/litellm","slug":"token-not-found-in-db-c16937","errorCode":"token_not_found_in_db","errorMessage":"Authentication Error, Invalid proxy server token passed. key={hashed_token}, not found in db. Create key via `/key/generate` call.","messagePattern":"Authentication Error, Invalid proxy server token passed\\. key=(.+?), not found in db\\. Create key via `/key/generate` call\\.","errorType":"http","errorClass":"KeyNotFoundError","httpStatus":401,"severity":"error","filePath":"litellm/proxy/auth/resolvers/store.py","lineNumber":120,"sourceCode":"    async def _resolve_key(self, hashed_token: str) -> UserAPIKeyAuth:\n        if self._prisma is None:\n            raise NoDatabaseConnectionError()\n\n        cached: Final = await self._cache.async_get_cache(key=hashed_token, model_type=UserAPIKeyAuth)\n        if cached is not None:\n            return _copy_user_api_key_auth_for_cache(user_api_key_obj=cached)\n\n        if self._check_cache_only:\n            raise KeyNotInCacheError(hashed_token)\n\n        from_db: Final[BaseModel | None] = await _fetch_key_object_from_db_with_reconnect(\n            hashed_token=hashed_token,\n            prisma_client=self._prisma,\n            parent_otel_span=self._parent_otel_span,\n            proxy_logging_obj=self._proxy_logging_obj,\n        )\n        if from_db is None:\n            raise KeyNotFoundError(hashed_token)\n\n        key: Final = UserAPIKeyAuth.model_validate(from_db.model_dump(exclude_none=True))\n\n        if key.object_permission_id and not key.object_permission:\n            try:\n                key.object_permission = await get_object_permission(\n                    object_permission_id=key.object_permission_id,\n                    prisma_client=self._prisma,\n                    user_api_key_cache=self._cache,\n                    parent_otel_span=self._parent_otel_span,\n                    proxy_logging_obj=self._proxy_logging_obj,\n                )\n            except Exception as e:\n                verbose_proxy_logger.debug(\n                    \"Failed to load object_permission for key with object_permission_id=%s: %s\",\n                    key.object_permission_id,\n                    e,\n                )","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/auth/resolvers/store.py#L102-L138","documentation":"Raised after a cache miss and DB lookup when the hashed token matches no key row: the presented proxy key is invalid/revoked. The message points to /key/generate since only the hash is stored, not recoverable keys.","triggerScenarios":"Thrown at litellm/proxy/auth/resolvers/store.py:120 when the library encounters an invalid state.","commonSituations":"The presented proxy token was not found in the database (invalid, deleted, or never created).","solutions":["Create a key via the /key/generate endpoint and use that key.","Check for typos or truncation in the Bearer token being sent."],"exampleFix":"curl -X POST $PROXY/key/generate -H 'Authorization: Bearer $MASTER_KEY' -d '{}'","handlingStrategy":"validation","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"}