{"record":{"id":"71b7175f76955da8","repo":"BerriAI/litellm","slug":"cost-per-ptu-per-hour-must-be-a-finite-number-betw","errorCode":null,"errorMessage":"cost_per_ptu_per_hour must be a finite number between 0 and {self.MAX_COST_PER_PTU_PER_HOUR}","messagePattern":"cost_per_ptu_per_hour must be a finite number between 0 and (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/types/router.py","lineNumber":203,"sourceCode":"    # router-wide default.\n    enable_tag_filtering: bool | None = None\n\n    def __init__(self, id: str | int | None = None, **params) -> None:\n        if id is None:\n            id = str(uuid.uuid4())  # Generate a UUID if id is None or not provided\n        elif isinstance(id, int):\n            id = str(id)\n        super().__init__(id=id, **params)\n\n    @model_validator(mode=\"after\")\n    def _validate_ptu_bounds(self) -> \"ModelInfo\":\n        if self.ptu_count is not None and not 0 < self.ptu_count <= self.MAX_PTU_COUNT:\n            raise ValueError(f\"ptu_count must be a positive integer no greater than {self.MAX_PTU_COUNT}\")\n        if (\n            self.cost_per_ptu_per_hour is not None\n            and not 0 <= self.cost_per_ptu_per_hour <= self.MAX_COST_PER_PTU_PER_HOUR\n        ):\n            raise ValueError(\n                f\"cost_per_ptu_per_hour must be a finite number between 0 and {self.MAX_COST_PER_PTU_PER_HOUR}\"\n            )\n        start: Final = _as_utc(self.ptu_effective_from)\n        end: Final = _as_utc(self.ptu_effective_to)\n        if start is not None and end is not None and end <= start:\n            raise ValueError(\"ptu_effective_to must be after ptu_effective_from\")\n        return self\n\n    model_config = ConfigDict(extra=\"allow\")\n\n    def __contains__(self, key) -> bool:\n        # Define custom behavior for the 'in' operator\n        return hasattr(self, key)\n\n    def get(self, key, default=None):\n        # Custom .get() method to access attributes with a default value if the attribute doesn't exist\n        return getattr(self, key, default)\n","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/types/router.py#L185-L221","documentation":"Model validator _validate_ptu_bounds on ModelInfo: cost_per_ptu_per_hour was supplied but is negative, exceeds MAX_COST_PER_PTU_PER_HOUR, or is non-finite (NaN/inf). Enforced so PTU cost math cannot produce nonsense spend values.","triggerScenarios":"Thrown at litellm/types/router.py:203 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set cost_per_ptu_per_hour to a finite number within [0, {self.MAX_COST_PER_PTU_PER_HOUR}]; avoid NaN/inf."],"exampleFix":null,"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"}