{"record":{"id":"8fe28e43c3f9f4c9","repo":"BerriAI/litellm","slug":"discount-for-provider-must-be-between-0-and-1-0","errorCode":null,"errorMessage":"Discount for {provider} must be between 0 and 1 (0% to 100%)","messagePattern":"Discount for (.+?) must be between 0 and 1 \\(0% to 100%\\)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"litellm/proxy/management_endpoints/cost_tracking_settings.py","lineNumber":231,"sourceCode":"    invalid_providers: Final = []\n    for provider in cost_discount_config:\n        if provider not in LlmProvidersSet:\n            invalid_providers.append(provider)\n\n    if invalid_providers:\n        raise HTTPException(\n            status_code=400,\n            detail={\n                \"error\": f\"Invalid provider(s): {', '.join(invalid_providers)}. Must be valid LiteLLM providers. See https://docs.litellm.ai/docs/providers for the full list.\"\n            },\n        )\n\n    # Validate discount values are between 0 and 1\n    for provider, discount in cost_discount_config.items():\n        if not isinstance(discount, (int, float)):\n            raise HTTPException(status_code=400, detail=f\"Discount for {provider} must be a number\")\n        if not (0 <= discount <= 1):\n            raise HTTPException(\n                status_code=400,\n                detail=f\"Discount for {provider} must be between 0 and 1 (0% to 100%)\",\n            )\n\n    try:\n        # Load existing config\n        config: Final = await proxy_config.get_config()\n\n        # Ensure litellm_settings exists\n        if \"litellm_settings\" not in config:\n            config[\"litellm_settings\"] = {}\n\n        # Update cost_discount_config\n        config[\"litellm_settings\"][\"cost_discount_config\"] = cost_discount_config\n\n        # Save the updated config to DB\n        await proxy_config.save_config(new_config=config)\n","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/cost_tracking_settings.py#L213-L249","documentation":"Validation error (HTTP 400) from PATCH /config/cost_discount_config: each discount must satisfy 0 <= discount <= 1, where 1 means a 100% discount. Values outside that range (negative, or > 1 like 10 meaning '10%') are rejected.","triggerScenarios":"Sending whole-percent values (10 for 10%) instead of the decimal fraction 0.10; sending a negative discount; sending 1.5 thinking it means 150% off.","commonSituations":"Misreading the units — the API uses fractional multipliers, not percent; porting configs from systems that express percent as integers.","solutions":["Convert percentages to decimals: 10% -> 0.10, 50% -> 0.5.","Ensure the value is >= 0 and <= 1.","Double-check upstream config tooling doesn't multiply/divide by 100."],"exampleFix":"# before\n{\"openai\": 10}   # 400 must be between 0 and 1\n\n# after\n{\"openai\": 0.10}","handlingStrategy":"validation","validationCode":"for provider, discount in cost_discount_config.items():\n    if not (0 <= discount <= 1):\n        raise ValueError(\n            f\"{provider}: discount {discount} outside [0,1]; express 10% as 0.10\"\n        )","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on decimal fractions (0.10 = 10%) across all cost config tooling.","Add unit checks on generated configs asserting 0 <= v <= 1.","Document the unit next to every discount field in your internal schemas."],"tags":["litellm-proxy","validation","range-error","cost-tracking"],"backgroundTag":"value-out-of-range","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}