mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-02 02:11:58 +00:00
fix(ci): skip Vercel AI Gateway models without input pricing
The Vercel AI Gateway models endpoint now returns video, image, and reranking model entries that lack the standard input/output token pricing keys (some embedding entries also omit the output key). The auto_update workflow blew up with a KeyError on row['pricing']['output'] the first time it hit one of those rows. Skip rows that don't expose an input price, default the output price to zero when only input is provided (covers embedding models), and read pricing once into a local to drop the redundant 'pricing in row' guard. Co-authored-by: Krrish Dholakia <krrish-berri-2@users.noreply.github.com>
This commit is contained in:
parent
13924fa1d6
commit
17050cdf06
1 changed files with 11 additions and 8 deletions
|
|
@ -85,21 +85,24 @@ def transform_openrouter_data(data):
|
|||
def transform_vercel_ai_gateway_data(data):
|
||||
transformed = {}
|
||||
for row in data:
|
||||
pricing = row.get("pricing") or {}
|
||||
if "input" not in pricing:
|
||||
continue
|
||||
|
||||
obj = {
|
||||
"max_tokens": row["context_window"],
|
||||
"input_cost_per_token": float(row["pricing"]["input"]),
|
||||
"output_cost_per_token": float(row["pricing"]["output"]),
|
||||
"input_cost_per_token": float(pricing["input"]),
|
||||
"output_cost_per_token": float(pricing.get("output", 0.0)),
|
||||
'max_output_tokens': row['max_tokens'],
|
||||
'max_input_tokens': row["context_window"],
|
||||
}
|
||||
|
||||
# Handle cache pricing if available
|
||||
if "pricing" in row:
|
||||
if "input_cache_read" in row["pricing"] and row["pricing"]["input_cache_read"] is not None:
|
||||
obj['cache_read_input_token_cost'] = float(f"{float(row['pricing']['input_cache_read']):e}")
|
||||
|
||||
if "input_cache_write" in row["pricing"] and row["pricing"]["input_cache_write"] is not None:
|
||||
obj['cache_creation_input_token_cost'] = float(f"{float(row['pricing']['input_cache_write']):e}")
|
||||
if "input_cache_read" in pricing and pricing["input_cache_read"] is not None:
|
||||
obj['cache_read_input_token_cost'] = float(f"{float(pricing['input_cache_read']):e}")
|
||||
|
||||
if "input_cache_write" in pricing and pricing["input_cache_write"] is not None:
|
||||
obj['cache_creation_input_token_cost'] = float(f"{float(pricing['input_cache_write']):e}")
|
||||
|
||||
mode = "embedding" if "embedding" in row["id"].lower() else "chat"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue