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. Calls are reported under the openai.responses.create event name, with the same metrics as OpenAI. 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.