This repository was archived by the owner on Jul 22, 2025. It is now read-only.
API Pricing - how to tell how many searches a given request incurred #121
Unanswered
ssalbiz-relay
asked this question in
Q&A
Replies: 1 comment 1 reply
-
It's in the usage information in the response object. If you're using Python for instance, you can get it like so: from openai import OpenAI
import os
client = OpenAI(api_key=os.environ.get("PPLX_API_KEY"), base_url="https://api.perplexity.ai")
response = client.chat.completions.create(
model="sonar-pro",
messages=[
{
"role": "user",
"content": "What is the most recent version of Python?"
}
]
)
print(f"Prompt tokens: {response.usage.prompt_tokens}")
print(f"Completion tokens: {response.usage.completion_tokens}")
print(f"Citation tokens: {response.usage.citation_tokens}")
print(f"Number of search queries: {response.usage.num_search_queries}") This gave me:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Based on the pricing documentation, perplexity charges $5/1000 search queries incurred by a the model.
However, I don't see a way to determine based on the model response how many searches were done under the hood - just the token counts are provided, and its implied that in some cases the model will perform multiple searches to produce a result.
Is that something that can be inferred (e.g. by counting citations maybe?) or is it simply not exposed yet please?
Beta Was this translation helpful? Give feedback.
All reactions