from typing import Dict, Any from . import Provider from .. import config class KiloProvider(Provider): name = "kilo" base_url = "https://api.kilo.ai/api/gateway" def is_available(self) -> bool: return True def is_free_model(self, model: Dict[str, Any]) -> bool: if model.get("isFree", False): return True model_id = model.get("id", "") if ":free" in model_id: return True if model.get("isFree") is False: return False pricing = model.get("pricing") or {} prompt_price = str(pricing.get("prompt", "0")) completion_price = str(pricing.get("completion", "0")) request_price = str(pricing.get("request", "0")) return (prompt_price == "0" and completion_price == "0" and request_price == "0") def get_chat_url(self) -> str: return f"{self.base_url}/chat/completions" def get_headers(self, model_id: str) -> Dict[str, str]: headers = {"Content-Type": "application/json"} api_key = config.get_kilo_api_key() if api_key: headers["Authorization"] = f"Bearer {api_key}" return headers