diff --git a/aider/models/openrouter.py b/aider/models/openrouter.py index 6c9eec21e..6271e703f 100644 --- a/aider/models/openrouter.py +++ b/aider/models/openrouter.py @@ -21,13 +21,13 @@ class OpenRouterModel(Model): if cached_model_details is None: cached_model_details = client.models.list().data found = next( - (details for details in cached_model_details if details.get("id") == name), None + (details for details in cached_model_details if details.id == name), None ) if found: - self.max_context_tokens = int(found.get("context_length")) - self.prompt_price = round(float(found.get("pricing").get("prompt")) * 1000, 6) - self.completion_price = round(float(found.get("pricing").get("completion")) * 1000, 6) + self.max_context_tokens = int(found.context_length) + self.prompt_price = round(float(found.pricing.get("prompt")) * 1000, 6) + self.completion_price = round(float(found.pricing.get("completion")) * 1000, 6) else: raise ValueError(f"invalid openrouter model: {name}")