From be70a3539e39e735c3c28363bd603957fa78941a Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 14 Jun 2026 04:04:40 +0000 Subject: [PATCH] fix(ci): skip missing pricing keys in Vercel AI Gateway transform The auto_update_price_and_context_window_file.py script crashed with KeyError: 'output' on the latest Vercel AI Gateway response, where 88 of 280 models (embeddings, image/video, etc.) don't expose 'output' pricing and 62 don't expose 'input'. Treat both pricing fields as optional so the daily price-update job stops failing Co-authored-by: Krrish Dholakia --- ...to_update_price_and_context_window_file.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/auto_update_price_and_context_window_file.py b/.github/workflows/auto_update_price_and_context_window_file.py index 461d8d347d9..f57e0d05c37 100644 --- a/.github/workflows/auto_update_price_and_context_window_file.py +++ b/.github/workflows/auto_update_price_and_context_window_file.py @@ -85,24 +85,27 @@ def transform_openrouter_data(data): def transform_vercel_ai_gateway_data(data): transformed = {} for row in data: + pricing = row.get("pricing") or {} obj = { "max_tokens": row["context_window"], - "input_cost_per_token": float(row["pricing"]["input"]), - "output_cost_per_token": float(row["pricing"]["output"]), '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" in pricing: + obj["input_cost_per_token"] = float(pricing["input"]) + + if "output" in pricing: + obj["output_cost_per_token"] = float(pricing["output"]) + + if pricing.get("input_cache_read") is not None: + obj['cache_read_input_token_cost'] = float(f"{float(pricing['input_cache_read']):e}") + + if pricing.get("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" - + obj.update({"litellm_provider": "vercel_ai_gateway", "mode": mode}) transformed[f'vercel_ai_gateway/{row["id"]}'] = obj