OpenAI client and the SDK meters it with the OpenAI recipe.
Set up
Point theOpenAI client’s baseURL at Perplexity and wrap it:
responses.create. Use the base URL with /v1.
Perplexity ended support for Sonar Chat Completions on September 27, 2026. Use the Responses format shown above.
What is reported
Perplexity returns ausage object in OpenAI’s format with the number of tokens each call consumed. The calls go through the OpenAI client, so they are reported under OpenAI event names. The wrapper reads the counts and reports them to Stigg as the metrics below.
Responses
total_tokens includes the other token counts, so price the total or the parts, never both. To tell Perplexity apart from other vendors on the same event name, add a dimension such as provider to the stiggContext.
Perplexity’s usage object also includes a breakdown of what the call cost, including search and tool costs. Those fields are included under the raw. prefix, so you can build a meter on them.
Every usage field the provider returns is also included, with a raw. prefix. See How usage is reported.
For details on Perplexity’s API, see Perplexity’s OpenAI compatibility docs.