from typing import Dict, Any from . import Provider from .. import config class ZenProvider(Provider): name = "zen" base_url = "https://opencode.ai/zen/v1" def is_available(self) -> bool: return True def is_free_model(self, model: Dict[str, Any]) -> bool: model_id = model.get("id", "") if "-free" in model_id: return True if model_id == "big-pickle": return True pricing = model.get("pricing") if pricing: 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" return False 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_zen_api_key() if api_key: headers["Authorization"] = f"Bearer {api_key}" return headers