{"record":{"id":"4f277275ed8bfe1e","repo":"BerriAI/litellm","slug":"either-key-or-key-alias-must-be-provided","errorCode":null,"errorMessage":"either key or key_alias must be provided","messagePattern":"either key or key_alias must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/_types.py","lineNumber":1242,"sourceCode":"    spend: float | None = None\n    metadata: dict | None = None\n    temp_budget_increase: float | None = None\n    temp_budget_expiry: datetime | None = None\n    auto_rotate: bool | None = None\n    rotation_interval: str | None = None\n    organization_id: str | None = None\n\n    @model_validator(mode=\"after\")\n    def validate_temp_budget(self) -> \"UpdateKeyRequest\":\n        if self.temp_budget_increase is not None or self.temp_budget_expiry is not None:\n            if self.temp_budget_increase is None or self.temp_budget_expiry is None:\n                raise ValueError(\"temp_budget_increase and temp_budget_expiry must be set together\")\n        return self\n\n    @model_validator(mode=\"after\")\n    def validate_key_identifier(self) -> \"UpdateKeyRequest\":\n        if self.key is None and self.key_alias is None:\n            raise ValueError(\"either key or key_alias must be provided\")\n        return self\n\n\nclass RegenerateKeyRequest(GenerateKeyRequest):\n    # This needs to be different from UpdateKeyRequest, because \"key\" is optional for this\n    key: str | None = None\n    new_key: str | None = None\n    duration: str | None = None\n    spend: float | None = None\n    metadata: dict | None = None\n    new_master_key: str | None = None\n    grace_period: str | None = None  # Duration to keep old key valid (e.g. \"24h\", \"2d\"); None = immediate revoke\n\n\nclass ResetSpendRequest(LiteLLMPydanticObjectBase):\n    reset_to: float\n\n","sourceCodeStart":1224,"sourceCodeEnd":1260,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/_types.py#L1224-L1260","documentation":"Pydantic model_validator on UpdateKeyRequest rejecting an update that identifies no key: neither key nor key_alias was provided. The budget-validator shown is one of several guards on this model; this specific one fires when the request has payload fields (e.g. spend/metadata changes) but no key identifier to apply them to, making the update a no-op.","triggerScenarios":"Thrown at litellm/proxy/_types.py:1242 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide either key or key_alias in the request."],"exampleFix":"key_alias='my-key'","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-14T05:17:10.506Z"}