mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-29 06:33:28 +00:00
fix(cost-map): drop the gpt-5-nano priority input price OpenAI does not sell (#48763)
gpt-5-nano and gpt-5-nano-2025-08-07 carried gpt-5's priority input price, 50x the nano standard rate. OpenAI sells no priority tier for nano and answers a nano priority request with service_tier default, so proxy spend on real calls was already billed at the standard rate. The wrong price showed in /model/info, in the tier pricing a custom-priced nano deployment inherited, and in SDK cost estimates like litellm.cost_per_token with service_tier priority. The key is removed, and a new test keeps every priority rate between 1x and 5x of its standard rate in both cost map files
This commit is contained in:
parent
94e4ebd63d
commit
4b0aa0f446
3 changed files with 45 additions and 5 deletions
|
|
@ -37504,7 +37504,6 @@
|
|||
"input_cost_per_token": 5e-08,
|
||||
"input_cost_per_token_batches": 2.5e-08,
|
||||
"input_cost_per_token_flex": 2.5e-08,
|
||||
"input_cost_per_token_priority": 2.5e-06,
|
||||
"litellm_provider": "openai",
|
||||
"max_input_tokens": 272000,
|
||||
"max_output_tokens": 128000,
|
||||
|
|
@ -37552,7 +37551,6 @@
|
|||
"deprecation_date": "2026-12-11",
|
||||
"input_cost_per_token": 5e-08,
|
||||
"input_cost_per_token_batches": 2.5e-08,
|
||||
"input_cost_per_token_priority": 2.5e-06,
|
||||
"input_cost_per_token_flex": 2.5e-08,
|
||||
"litellm_provider": "openai",
|
||||
"max_input_tokens": 272000,
|
||||
|
|
|
|||
|
|
@ -37504,7 +37504,6 @@
|
|||
"input_cost_per_token": 5e-08,
|
||||
"input_cost_per_token_batches": 2.5e-08,
|
||||
"input_cost_per_token_flex": 2.5e-08,
|
||||
"input_cost_per_token_priority": 2.5e-06,
|
||||
"litellm_provider": "openai",
|
||||
"max_input_tokens": 272000,
|
||||
"max_output_tokens": 128000,
|
||||
|
|
@ -37552,7 +37551,6 @@
|
|||
"deprecation_date": "2026-12-11",
|
||||
"input_cost_per_token": 5e-08,
|
||||
"input_cost_per_token_batches": 2.5e-08,
|
||||
"input_cost_per_token_priority": 2.5e-06,
|
||||
"input_cost_per_token_flex": 2.5e-08,
|
||||
"litellm_provider": "openai",
|
||||
"max_input_tokens": 272000,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import json
|
||||
import re
|
||||
from collections.abc import Mapping
|
||||
from collections.abc import Iterator, Mapping
|
||||
from pathlib import Path
|
||||
from types import MappingProxyType
|
||||
from typing import Final
|
||||
|
|
@ -224,6 +224,50 @@ def test_dated_variants_carry_base_alias_service_tier_pricing(prices: dict):
|
|||
)
|
||||
|
||||
|
||||
PRIORITY_SUFFIX: Final = "_priority"
|
||||
MIN_PRIORITY_MARKUP: Final = 1.0
|
||||
MAX_PRIORITY_MARKUP: Final = 5.0
|
||||
|
||||
|
||||
def _rate(value: JsonValue | None) -> float | None:
|
||||
return float(value) if isinstance(value, (int, float)) and not isinstance(value, bool) else None
|
||||
|
||||
|
||||
def _priority_markup(entry: Mapping[str, JsonValue], key: str) -> float | None:
|
||||
if not key.endswith(PRIORITY_SUFFIX):
|
||||
return None
|
||||
priority: Final = _rate(entry[key])
|
||||
standard: Final = _rate(entry.get(key.removesuffix(PRIORITY_SUFFIX)))
|
||||
if priority is None or standard is None or standard <= 0:
|
||||
return None
|
||||
return priority / standard
|
||||
|
||||
|
||||
def priority_markups(prices: Mapping[str, JsonValue]) -> Iterator[tuple[str, str, float]]:
|
||||
for name, entry in prices.items():
|
||||
if not isinstance(entry, dict):
|
||||
continue
|
||||
for key in entry:
|
||||
if (markup := _priority_markup(entry, key)) is not None:
|
||||
yield name, key, markup
|
||||
|
||||
|
||||
@pytest.mark.parametrize("path", (PRICES_PATH, BACKUP_PRICES_PATH), ids=("main", "backup"))
|
||||
def test_priority_rates_stay_within_a_premium_of_their_standard_rate(path: Path) -> None:
|
||||
prices: Final = TypeAdapter(dict[str, JsonValue]).validate_json(path.read_bytes())
|
||||
markups: Final = tuple(priority_markups(prices))
|
||||
assert markups
|
||||
overpriced: Final = tuple(
|
||||
f"{name}.{key} is {markup:.1f}x its standard rate"
|
||||
for name, key, markup in markups
|
||||
if not MIN_PRIORITY_MARKUP <= markup <= MAX_PRIORITY_MARKUP
|
||||
)
|
||||
assert overpriced == (), (
|
||||
"a priority rate is a premium on the standard rate, so one below it or far above it was likely copied from "
|
||||
"another model; drop the key when the provider sells no priority tier for the model:\n" + "\n".join(overpriced)
|
||||
)
|
||||
|
||||
|
||||
# Azure Foundry GPT-6.1 Sol announcement, 2026-09-29: https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/introducing-gpt-6-1-sol-in-microsoft-foundry-advanced-intelligence-optimized-for/4560811
|
||||
AZURE_GPT_6_1_SOL_REGIONAL_PREMIUM: Final = MappingProxyType({"us": 1.1, "eu": 1.2, "apac": 1.2})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue