diff --git a/.github/scripts/auto_update_price_and_context_window_file.py b/.github/scripts/auto_update_price_and_context_window_file.py index 461d8d347d9..523ec148fc6 100644 --- a/.github/scripts/auto_update_price_and_context_window_file.py +++ b/.github/scripts/auto_update_price_and_context_window_file.py @@ -1,6 +1,7 @@ import asyncio import aiohttp import json +from typing import Any, Optional # Asynchronously fetch data from a given URL async def fetch_data(url): @@ -21,6 +22,145 @@ async def fetch_data(url): print("Error fetching data from URL:", e) return None + +FRIENDLI_API_URL = "https://api.friendli.ai/serverless/v1/models" +FRIENDLI_PROVIDER = "friendliai" + +INHERITABLE_BASE_KEYS = ( + "supports_reasoning", + "supports_function_calling", + "supports_parallel_function_calling", + "supports_response_schema", + "supports_system_messages", + "supports_tool_choice", + "supports_vision", + "supports_pdf_input", + "supports_prompt_caching", + "supports_assistant_prefill", + "supports_low_reasoning_effort", + "supports_minimal_reasoning_effort", + "supports_max_reasoning_effort", + "supports_xhigh_reasoning_effort", + "supports_none_reasoning_effort", + "supports_adaptive_thinking", + "supports_output_config", + "supports_native_structured_output", +) + +EFFORT_FLAG_MAP = { + "none": "supports_none_reasoning_effort", + "minimal": "supports_minimal_reasoning_effort", + "low": "supports_low_reasoning_effort", + "medium": "supports_low_reasoning_effort", + "high": "supports_max_reasoning_effort", + "xhigh": "supports_xhigh_reasoning_effort", + "max": "supports_max_reasoning_effort", +} + + +def _find_base_model_entry(base_model: str, local_data: dict) -> Optional[str]: + if not base_model: + return None + bm_tail = base_model.split("/")[-1].lower() + if base_model in local_data: + return base_model + for key in local_data: + if key.startswith("sample_spec") or key == "fallback_generalizations": + continue + if key.split("/")[-1].lower() == bm_tail: + return key + return None + + +def _effort_flags(reasoning_options: list) -> dict: + flags: dict[str, bool] = {flag: False for flag in EFFORT_FLAG_MAP.values()} + for opt in reasoning_options or []: + if opt.get("type") == "effort": + for val in opt.get("values", []): + flag = EFFORT_FLAG_MAP.get(val) + if flag: + flags[flag] = True + return flags + + +def _pricing(pricing: dict) -> dict: + out: dict[str, Any] = {} + if not pricing: + return out + if "input" in pricing: + out["input_cost_per_token"] = float(pricing["input"]) + if "output" in pricing: + out["output_cost_per_token"] = float(pricing["output"]) + if "input_cache_read" in pricing and pricing["input_cache_read"] is not None: + out["cache_read_input_token_cost"] = float(pricing["input_cache_read"]) + return out + + +def _modality_flags(input_mods: list) -> dict: + has_image = "image" in (input_mods or []) + return { + "supports_vision": has_image, + "supports_image_input": has_image, + } + + +def transform_friendli_data(data: list, local_data: dict) -> dict: + transformed: dict[str, dict] = {} + for model in data: + model_id = model["id"] + base_model = model.get("base_model") or "" + entry: dict[str, Any] = { + "litellm_provider": FRIENDLI_PROVIDER, + } + + base_key = _find_base_model_entry(base_model, local_data) + if base_key: + base_entry = local_data[base_key] + for k in INHERITABLE_BASE_KEYS: + if k in base_entry: + entry[k] = base_entry[k] + + ctx = model.get("context_length") + if ctx is not None: + entry["max_input_tokens"] = int(ctx) + entry["max_tokens"] = int(ctx) + max_out = model.get("max_completion_tokens") + if max_out is not None: + entry["max_output_tokens"] = int(max_out) + + entry.update(_pricing(model.get("pricing", {}))) + + reasoning = model.get("reasoning") is True + entry["supports_reasoning"] = reasoning + if reasoning: + entry.update(_effort_flags(model.get("reasoning_options", []))) + + func = model.get("functionality", {}) + entry["supports_function_calling"] = func.get("tool_call") is True + entry["supports_parallel_function_calling"] = func.get("parallel_tool_call") is True + is_struct = func.get("structured_output") is True + entry["supports_response_schema"] = is_struct + entry["supports_native_structured_output"] = is_struct + entry["supports_system_messages"] = func.get("system_messages") is True + entry["supports_tool_choice"] = func.get("tool_choice") is True + + entry.update(_modality_flags(model.get("input_modalities", []))) + + entry["mode"] = model.get("mode", "chat") + + desc = model.get("description") + if desc: + entry["comment"] = desc + + dep = model.get("deprecation_date") + if dep: + entry["deprecation_date"] = dep.split("T")[0] + + entry["source"] = FRIENDLI_API_URL + + transformed[f"{FRIENDLI_PROVIDER}/{model_id}"] = entry + return transformed + # Synchronize local data with remote data def sync_local_data_with_remote(local_data, remote_data): # Update existing keys in local_data with values from remote_data @@ -143,9 +283,12 @@ def main(): vercel_data = asyncio.run(fetch_data(vercel_ai_gateway_url)) # Transform the fetched Vercel AI Gateway data vercel_data = transform_vercel_ai_gateway_data(vercel_data) + + friendli_data = asyncio.run(fetch_data(FRIENDLI_API_URL)) + friendli_data = transform_friendli_data(friendli_data, local_data) # Combine both datasets - all_remote_data = {**openrouter_data, **vercel_data} + all_remote_data = {**openrouter_data, **vercel_data, **friendli_data} # If both local and openrouter data are available, synchronize and save if local_data and all_remote_data: diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index dd367e875de..70de4f5934f 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -51736,5 +51736,156 @@ "supports_response_schema": true, "supports_tool_choice": true, "supports_vision": true + }, + "friendliai/LGAI-EXAONE/K-EXAONE-236B-A23B": { + "litellm_provider": "friendliai", + "max_input_tokens": 262144, + "max_tokens": 262144, + "max_output_tokens": 262144, + "input_cost_per_token": 2e-07, + "output_cost_per_token": 8e-07, + "cache_read_input_token_cost": 1e-07, + "supports_reasoning": true, + "supports_function_calling": true, + "supports_parallel_function_calling": true, + "supports_response_schema": true, + "supports_native_structured_output": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "mode": "chat", + "comment": "Open multilingual MoE model for reasoning, agentic tool use, and long-context work with strong Korean capabilities", + "deprecation_date": "2026-08-20", + "source": "https://api.friendli.ai/serverless/v1/models", + "supports_vision": false, + "supports_image_input": false + }, + "friendliai/MiniMaxAI/MiniMax-M2.5": { + "litellm_provider": "friendliai", + "max_input_tokens": 196608, + "max_tokens": 196608, + "max_output_tokens": 196608, + "input_cost_per_token": 3e-07, + "output_cost_per_token": 1.2e-06, + "cache_read_input_token_cost": 6e-08, + "supports_reasoning": true, + "supports_function_calling": true, + "supports_parallel_function_calling": true, + "supports_response_schema": true, + "supports_native_structured_output": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "mode": "chat", + "comment": "Prior MiniMax coding model for agent workflows, office edits, and automation", + "source": "https://api.friendli.ai/serverless/v1/models", + "supports_vision": false, + "supports_image_input": false + }, + "friendliai/deepseek-ai/DeepSeek-V3.2": { + "litellm_provider": "friendliai", + "supports_reasoning": true, + "supports_function_calling": true, + "supports_tool_choice": true, + "supports_prompt_caching": true, + "supports_assistant_prefill": true, + "max_input_tokens": 163840, + "max_tokens": 163840, + "max_output_tokens": 163840, + "input_cost_per_token": 5e-07, + "output_cost_per_token": 1.5e-06, + "cache_read_input_token_cost": 2.5e-07, + "supports_parallel_function_calling": true, + "supports_response_schema": true, + "supports_native_structured_output": true, + "supports_system_messages": true, + "mode": "chat", + "comment": "DeepSeek chat model for instruction following, coding, and analysis", + "source": "https://api.friendli.ai/serverless/v1/models", + "supports_vision": false, + "supports_image_input": false + }, + "friendliai/zai-org/GLM-5.1": { + "litellm_provider": "friendliai", + "supports_reasoning": true, + "supports_function_calling": true, + "supports_tool_choice": true, + "supports_prompt_caching": true, + "max_input_tokens": 202752, + "max_tokens": 202752, + "max_output_tokens": 202752, + "input_cost_per_token": 1.4e-06, + "output_cost_per_token": 4.4e-06, + "cache_read_input_token_cost": 2.6e-07, + "supports_parallel_function_calling": true, + "supports_response_schema": true, + "supports_native_structured_output": true, + "supports_system_messages": true, + "mode": "chat", + "comment": "Strong GLM coding model for agentic engineering, terminals, and repository generation", + "source": "https://api.friendli.ai/serverless/v1/models", + "supports_vision": false, + "supports_image_input": false + }, + "friendliai/google/gemma-4-31B-it": { + "litellm_provider": "friendliai", + "supports_vision": true, + "max_input_tokens": 8192, + "max_tokens": 8192, + "max_output_tokens": 8192, + "input_cost_per_token": 1.4e-07, + "output_cost_per_token": 4e-07, + "supports_reasoning": true, + "supports_function_calling": true, + "supports_parallel_function_calling": true, + "supports_response_schema": true, + "supports_native_structured_output": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_image_input": true, + "mode": "chat", + "comment": "Largest Gemma 4 instruction model for open, self-hosted chat and reasoning", + "source": "https://api.friendli.ai/serverless/v1/models" + }, + "friendliai/zai-org/GLM-5.2": { + "litellm_provider": "friendliai", + "supports_reasoning": true, + "supports_function_calling": true, + "max_input_tokens": 1048576, + "max_tokens": 1048576, + "max_output_tokens": 1048576, + "input_cost_per_token": 1.4e-06, + "output_cost_per_token": 4.4e-06, + "cache_read_input_token_cost": 2.6e-07, + "supports_max_reasoning_effort": true, + "supports_parallel_function_calling": true, + "supports_response_schema": true, + "supports_native_structured_output": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "mode": "chat", + "comment": "Open flagship GLM for long-horizon coding agents and million-token context work", + "source": "https://api.friendli.ai/serverless/v1/models", + "supports_vision": false, + "supports_image_input": false + }, + "friendliai/LGAI-EXAONE/K-EXAONE-2.0-750B-A37B": { + "litellm_provider": "friendliai", + "max_input_tokens": 262144, + "max_tokens": 262144, + "max_output_tokens": 262144, + "input_cost_per_token": 6e-07, + "output_cost_per_token": 2.4e-06, + "cache_read_input_token_cost": 1.2e-07, + "supports_reasoning": true, + "supports_function_calling": true, + "supports_parallel_function_calling": true, + "supports_response_schema": true, + "supports_native_structured_output": true, + "supports_system_messages": true, + "supports_tool_choice": true, + "supports_vision": false, + "supports_image_input": false, + "mode": "chat", + "comment": "Frontier-scale multilingual language model developed by LG AI Research", + "source": "https://api.friendli.ai/serverless/v1/models" } }