Skip to main content
Perplexity’s Agent API combines models with built-in web search. Its API follows OpenAI’s format, so you wrap it with the OpenAI client and the SDK meters it with the OpenAI recipe.

Set up

Point the OpenAI client’s baseURL at Perplexity and wrap it:
Perplexity’s Agent API follows OpenAI’s Responses format, so call 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 a usage 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.