{"record":{"id":"71923f2592908549","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"no-pricing-tier-matches-input-tokens-input-token","errorCode":null,"errorMessage":"No pricing tier matches {input_tokens} input tokens","messagePattern":"No pricing tier matches (.+?) input tokens","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/utils/model_costs.py","lineNumber":179,"sourceCode":"        raise ValueError(\"input_tokens must not be negative\")\n\n    if model_name in MODEL_COST_TIERS_PER_1K_TOKENS:\n        try:\n            pricing_tiers = MODEL_COST_TIERS_PER_1K_TOKENS[model_name][service_tier]\n        except KeyError as exc:\n            raise ValueError(\n                f\"Unsupported service tier {service_tier!r} for {model_name}\"\n            ) from exc\n\n        rate_key = \"output\" if is_completion else \"input\"\n        for pricing in pricing_tiers:\n            upper_bound = pricing.get(\"input_tokens_lte\")\n            lower_bound = pricing.get(\"input_tokens_gt\")\n            if upper_bound is not None and input_tokens <= upper_bound:\n                return float(pricing[rate_key])\n            if lower_bound is not None and input_tokens > lower_bound:\n                return float(pricing[rate_key])\n        raise ValueError(f\"No pricing tier matches {input_tokens} input tokens\")\n\n    costs = (\n        MODEL_COST_PER_1K_TOKENS_OUTPUT\n        if is_completion\n        else MODEL_COST_PER_1K_TOKENS_INPUT\n    )\n    return costs[model_name]\n","sourceCodeStart":161,"sourceCodeEnd":187,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/utils/model_costs.py#L161-L187","documentation":"ValueError from get_model_cost_per_1k_tokens: none of the pricing tiers for the model matched the given input_tokens. Tiers are defined via input_tokens_lte / input_tokens_gt bounds; if the tier table has gaps (e.g. no open-ended top tier), large token counts fall through.","triggerScenarios":"Passing an input_tokens value outside every defined tier bound for a tiered model — typically a very large count when the top tier lacks an input_tokens_gt-only entry.","commonSituations":"Hand-edited tier tables missing an unbounded final tier, or token counts exceeding the highest input_tokens_lte.","solutions":["Fix the tier definition to include an open-ended top tier (only input_tokens_gt, no lte)","Verify the input_tokens value is sane (not multiplied/overflowed)","Add a final catch-all tier covering the missing range"],"exampleFix":"# before\nMODEL_COST_TIERS_PER_1K_TOKENS[\"m\"] = {\"standard\": [{\"input_tokens_lte\": 1000000, ...}]}\n# after\nMODEL_COST_TIERS_PER_1K_TOKENS[\"m\"] = {\"standard\": [{\"input_tokens_lte\": 1000000, ...}, {\"input_tokens_gt\": 1000000, ...}]}","handlingStrategy":"try-catch","validationCode":"tiers = MODEL_COST_TIERS_PER_1K_TOKENS.get(model, {}).get(service_tier, [])\ndef matches(t, n):\n    return (t.get(\"input_tokens_lte\") is not None and n <= t[\"input_tokens_lte\"]) or (t.get(\"input_tokens_gt\") is not None and n > t[\"input_tokens_gt\"])\nassert any(matches(t, input_tokens) for t in tiers) or not tiers","typeGuard":null,"tryCatchPattern":"try:\n    rate = get_model_cost_per_1k_tokens(model, n)\nexcept ValueError as e:\n    rate = float(tiers[-1][\"output\" if is_completion else \"input\"])  # top tier fallback","preventionTips":["Define an open-ended top tier (input_tokens_gt only)","Sanity-check token counts before cost math","Add regression tests covering boundary token counts"],"tags":["pricing","tier-config","cost-tracking"],"backgroundTag":"config-value-out-of-range","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}