Files
litellm/tests/test_litellm/llms/perplexity
Cesar Garcia 5262896d62 fix(perplexity): use API-provided cost instead of manual calculation (#17887)
Fixes #15337

Perplexity API returns pre-calculated costs in `usage.cost.total_cost`
that include the `request_cost` (fixed per-request fee). LiteLLM was
ignoring this and calculating costs manually, resulting in ~27x
underreporting (e.g., $0.0002 vs actual $0.006).

Changes:
- Use `usage.cost.total_cost` from Perplexity response when available
- Fall back to manual calculation if cost object not present
- Add tests for both behaviors
2025-12-14 08:24:44 +05:30
..