{"record":{"id":"5424cffaa7397a06","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"unsupported-service-tier-service-tier-r-for-mod","errorCode":null,"errorMessage":"Unsupported service tier {service_tier!r} for {model_name}","messagePattern":"Unsupported service tier (.+?) for (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/utils/model_costs.py","lineNumber":167,"sourceCode":"    }\n}\n\n\ndef get_model_cost_per_1k_tokens(\n    model_name: str,\n    input_tokens: int,\n    is_completion: bool = False,\n    service_tier: str = \"standard\",\n) -> float:\n    \"\"\"Return the applicable input or output rate for a model.\"\"\"\n    if input_tokens < 0:\n        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    )","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/utils/model_costs.py#L149-L185","documentation":"ValueError from get_model_cost_per_1k_tokens: the model has tiered pricing but the supplied service_tier key (default 'standard') has no entry in MODEL_COST_TIERS_PER_1K_TOKENS for that model (e.g. only 'priority'/'other' tiers defined).","triggerScenarios":"Calling get_model_cost_per_1k_tokens for a tiered model with service_tier set to a tier not defined for it, or a model whose dict lacks the default 'standard' key.","commonSituations":"Adding a new tiered-pricing model to the cost table without a 'standard' entry, or forwarding a provider-specific service tier string verbatim.","solutions":["Check MODEL_COST_TIERS_PER_1K_TOKENS[model] keys and pass a service_tier that exists (e.g. 'priority')","Ensure tiered model entries always include a 'standard' tier in the cost table","Normalize provider tier strings before passing them to the helper"],"exampleFix":"# before\nrate = get_model_cost_per_1k_tokens(model, n, service_tier=\"batch\")\n# after\ntiers = MODEL_COST_TIERS_PER_1K_TOKENS.get(model, {})\nrate = get_model_cost_per_1k_tokens(model, n, service_tier=\"batch\" if \"batch\" in tiers else \"standard\")","handlingStrategy":"validation","validationCode":"from scrapegraphai.utils.model_costs import MODEL_COST_TIERS_PER_1K_TOKENS\ntiers = MODEL_COST_TIERS_PER_1K_TOKENS.get(model, {})\nservice_tier = service_tier if service_tier in tiers else \"standard\"","typeGuard":"def is_supported_tier(model, tier) -> bool:\n    return tier in MODEL_COST_TIERS_PER_1K_TOKENS.get(model, {})","tryCatchPattern":"try:\n    rate = get_model_cost_per_1k_tokens(model, n, service_tier=tier)\nexcept ValueError:\n    rate = get_model_cost_per_1k_tokens(model, n)  # default standard","preventionTips":["Inspect available tier keys per model before selecting one","Normalize provider tier strings","Keep a 'standard' tier in every tiered model entry"],"tags":["pricing","config","cost-tracking"],"backgroundTag":"config-key-missing","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}