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
..
chat Revert "Update perplexity cost tracking (#15743)" (#16345) 2025-11-06 19:00:45 -08:00
test_perplexity.py [Bug Fix] Perplexity - LiteLLM doesn't support 'web_search_options' for Perplexity' Sonar Pro model (#11983) 2025-06-23 10:21:50 -07:00
test_perplexity_cost_calculator.py fix(perplexity): use API-provided cost instead of manual calculation (#17887) 2025-12-14 08:24:44 +05:30
test_perplexity_integration.py Revert "Update perplexity cost tracking (#15743)" (#16345) 2025-11-06 19:00:45 -08:00