diff --git a/agent_cost_estimator/cli.py b/agent_cost_estimator/cli.py index 7c1da31..0617fe9 100644 --- a/agent_cost_estimator/cli.py +++ b/agent_cost_estimator/cli.py @@ -273,8 +273,8 @@ allowlist = ["agent-cost-estimator"] def effective_rates(args, pricing, meta): """Return (rates, key, currency, is_default) after table lookup and CLI overrides.""" - result = get_model_prices(pricing, args.model or meta.model_name, - meta.alias) + result = get_model_prices(pricing, args.model or meta.alias, + meta.model_name) # Handle different return value counts for backward compatibility if len(result) == 4: rates, key, currency, is_default = result diff --git a/agent_cost_estimator/pricing.py b/agent_cost_estimator/pricing.py index 07958fc..22210f0 100644 --- a/agent_cost_estimator/pricing.py +++ b/agent_cost_estimator/pricing.py @@ -194,12 +194,15 @@ def _lookup_in_providers(data: dict, provider: str | None, model_name: str, alia def get_model_prices(pricing, model_name=None, alias=None, provider=None): """Return (rates dict, matched key, currency, is_default) for the model. - Lookup order: + Lookup order (prioritizes the actual running model): 1. If provider specified: provider.model_name, provider.alias, provider.default 2. If provider not specified: - a. Search all providers for model_name or alias + a. Search all providers for model_name (passed as active_model) or alias (passed as model_name) b. Fall back to first provider's default model + Note: Callers should pass the actual model as model_name and the internal + alias as the alias parameter to prioritize the real running model. + Raises ValueError when nothing matches and there is no "default".