Perplexity
Route your Perplexity API calls through AI SpendOps for automatic usage tracking and cost attribution.
Configuration
| Setting | Value |
|---|---|
| Route | /v1/perplexity/* |
| Upstream | https://api.perplexity.ai |
| Auth header | Authorization: Bearer pplx-... |
| Streaming usage | Auto-injected (stream_options.include_usage) |
SDK base URL
https://proxy.aispendops.com/v1/perplexity/v1
Example
curl https://proxy.aispendops.com/v1/perplexity/v1/chat/completions \
-H "Authorization: Bearer pplx-your-perplexity-key" \
-H "X-ASO-API-Key: aso_k_yourkey.secret" \
-H "Content-Type: application/json" \
-d '{"model":"sonar-pro","messages":[{"role":"user","content":"Hello"}]}'
Usage fields
| Field | Description |
|---|---|
prompt_tokens | Input tokens |
completion_tokens | Output tokens |
Search-augmented cost
Perplexity's Sonar models are different from every other provider in this catalogue: each request runs a live web search before generating, and the retrieved sources are fed back in as input. Two things follow from that.
Your prompt token counts are inflated relative to what you sent. The
retrieved page content is counted as input, so a short question can report a
large prompt_tokens value. That is expected, not a tracking error. It also
means prompt tokens for Sonar models vary between two identical requests,
because the search returns different amounts of content each time.
Per-search fees are not itemised in the response. Where a request-level
search charge applies, Perplexity does not break it out in the usage object,
so AI SpendOps cannot attribute it per request. The token costs you see in AI
SpendOps for Sonar models are therefore a floor rather than the complete
invoice figure. Reconcile the difference against your Perplexity billing page.
If you need per-request web search counts in your usage data, the only provider
that reports them in-band today is Anthropic, via
server_tool_use.web_search_requests.
What AI SpendOps records
| Field | Populated |
|---|---|
cache_read_tokens | No. Perplexity does not expose prompt caching |
cache_write_tokens | No |
reasoning_tokens | Yes for reasoning models that report completion_tokens_details |
web_search_requests | No. Not reported in Perplexity's usage object |
provider_cost | No. Cost is calculated from token counts and the current Perplexity rate card |
Notes
- Citations are returned in the response body and pass through the proxy untouched. AI SpendOps does not store response content, so citations are not retained in usage events.
- The proxy injects
stream_options: { include_usage: true }on streaming requests. See Streaming. - Full field definitions are in the usage event field reference.