> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stigg.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Perplexity

> Wrap Perplexity's OpenAI-compatible API to meter and gate calls with Stigg.

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:

```typescript theme={null}
import OpenAI from 'openai';

const perplexity = stigg.wrap(
  new OpenAI({ baseURL: 'https://api.perplexity.ai/v1', apiKey: process.env.PERPLEXITY_API_KEY }),
);

const response = await perplexity.responses.create({
  model,
  input,
  stiggContext: { customerId: 'customer-acme', entitlement: { currencyId: 'credits' } },
});
```

Perplexity's Agent API follows OpenAI's **Responses** format, so call `responses.create`. Use the base URL with `/v1`.

<Note>
  Perplexity ended support for Sonar Chat Completions on September 27, 2026. Use the Responses format shown above.
</Note>

## 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](/documentation/ai-agents/llm-wrappers/providers/openai#what-is-reported).

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](/documentation/ai-agents/llm-wrappers/supported-providers#how-usage-is-reported).

For details on Perplexity's API, see Perplexity's [OpenAI compatibility docs](https://docs.perplexity.ai/docs/agent-api/openai-compatibility).


## Related topics

- [OpenAI-compatible endpoints](/documentation/ai-agents/llm-wrappers/providers/openai-compatible.md)
- [Supported providers and gateways](/documentation/ai-agents/llm-wrappers/supported-providers.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.