The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
TestPerplexityIntegration
Ishaan Jaffercbadcd4a776a
diff --git a/litellm/llms/__init__.py b/litellm/llms/__init__.pyindex 1676e7bb1ee..44e1fb4eb93 100644--- a/litellm/llms/__init__.py+++ b/litellm/llms/__init__.py@@ -39,6 +39,10 @@ def get_cost_for_web_search_request()return cost_per_web_search_request_vertex_ai(usage=usage, model_info=model_info)+ elif custom_llm_provider == "perplexity":+ # Perplexity handles search costs internally in its own cost calculator+ # Return 0.0 to indicate costs are already accounted for+ return 0.0else:return Nonediff --git a/tests/test_litellm/llms/perplexity/test_perplexity_integration.py b/tests/test_litellm/llms/perplexity/test_perplexity_integration.pyindex ae72b8a9625..a702e9ebc4c 100644--- a/tests/test_litellm/llms/perplexity/test_perplexity_integration.py+++ b/tests/test_litellm/llms/perplexity/test_perplexity_integration.py@@ -20,7 +20,7 @@ import litellmfrom litellm import ModelResponsefrom litellm.cost_calculator import completion_cost, cost_per_tokenfrom litellm.llms.perplexity.chat.transformation import PerplexityChatConfig-from litellm.types.utils import Usage, PromptTokensDetailsWrapper+from litellm.types.utils import PromptTokensDetailsWrapper, Usagefrom litellm.utils import get_model_info@@ -48,10 +48,10 @@ class TestPerplexityIntegration:"output_cost_per_token": 8e-06,"output_cost_per_reasoning_token": 3e-06,"citation_cost_per_token": 2e-06,- "search_queries_cost_per_query": {- "search_queries_size_low": 0.005,- "search_queries_size_medium": 0.005,- "search_queries_size_high": 0.005+ "search_context_cost_per_query": {+ "search_context_size_low": 0.005,+ "search_context_size_medium": 0.005,+ "search_context_size_high": 0.005},"litellm_provider": "perplexity","mode": "chat",