ScrapeGraphAI/Scrapegraph-ai · error · ValueError
Unsupported service tier {service_tier!r} for {model_name}
Error message
Unsupported service tier {service_tier!r} for {model_name} What it means
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).
Source
Thrown at scrapegraphai/utils/model_costs.py:167
}
}
def get_model_cost_per_1k_tokens(
model_name: str,
input_tokens: int,
is_completion: bool = False,
service_tier: str = "standard",
) -> float:
"""Return the applicable input or output rate for a model."""
if input_tokens < 0:
raise ValueError("input_tokens must not be negative")
if model_name in MODEL_COST_TIERS_PER_1K_TOKENS:
try:
pricing_tiers = MODEL_COST_TIERS_PER_1K_TOKENS[model_name][service_tier]
except KeyError as exc:
raise ValueError(
f"Unsupported service tier {service_tier!r} for {model_name}"
) from exc
rate_key = "output" if is_completion else "input"
for pricing in pricing_tiers:
upper_bound = pricing.get("input_tokens_lte")
lower_bound = pricing.get("input_tokens_gt")
if upper_bound is not None and input_tokens <= upper_bound:
return float(pricing[rate_key])
if lower_bound is not None and input_tokens > lower_bound:
return float(pricing[rate_key])
raise ValueError(f"No pricing tier matches {input_tokens} input tokens")
costs = (
MODEL_COST_PER_1K_TOKENS_OUTPUT
if is_completion
else MODEL_COST_PER_1K_TOKENS_INPUT
)View on GitHub (pinned to 532dfffbf6)
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
Example fix
# before
rate = get_model_cost_per_1k_tokens(model, n, service_tier="batch")
# after
tiers = MODEL_COST_TIERS_PER_1K_TOKENS.get(model, {})
rate = get_model_cost_per_1k_tokens(model, n, service_tier="batch" if "batch" in tiers else "standard") Defensive patterns
Strategy: validation
Validate before calling
from scrapegraphai.utils.model_costs import MODEL_COST_TIERS_PER_1K_TOKENS
tiers = MODEL_COST_TIERS_PER_1K_TOKENS.get(model, {})
service_tier = service_tier if service_tier in tiers else "standard" Type guard
def is_supported_tier(model, tier) -> bool:
return tier in MODEL_COST_TIERS_PER_1K_TOKENS.get(model, {}) Try / catch
try:
rate = get_model_cost_per_1k_tokens(model, n, service_tier=tier)
except ValueError:
rate = get_model_cost_per_1k_tokens(model, n) # default standard Prevention
- Inspect available tier keys per model before selecting one
- Normalize provider tier strings
- Keep a 'standard' tier in every tiered model entry
When it happens
Trigger: 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.
Common situations: Adding a new tiered-pricing model to the cost table without a 'standard' entry, or forwarding a provider-specific service tier string verbatim.
Related errors
- No pricing tier matches {input_tokens} input tokens
- The 'graphviz' library is required for this functionality. P
- The browserbase module is not installed. Please install it u
- Cannot deep copy object of type {type(obj)}
- input_tokens is required for completion costs with tiered pr
AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28).
Data as JSON: /api/errors/5424cffaa7397a06.
Report an issue: GitHub.