# Perplexity

Search API retrieval is separate from Sonar and agent-generated answers.

Canonical: https://searchsdk.dev/docs/providers/perplexity
Markdown: https://searchsdk.dev/docs/providers/perplexity.md

<a id="overview"></a>

## Normalized search

> **TypeScript reference**
> The API names, code and policy behavior in this article describe the TypeScript SDK. See [your language guide](https://searchsdk.dev/docs/sdks) for its supported surface and limits.

The normalized adapter targets the Search API and source snippets. It does not convert generated answers into web results. Native clients preserve search filters, answer and agent responses, embeddings, and asynchronous operation data.

**perplexity-search.ts · server**

```typescript
import { createSearch } from '@belweave/search-sdk';
import { perplexity } from '@belweave/search-sdk/perplexity';

const apiKey = process.env.PERPLEXITY_API_KEY;
if (!apiKey) throw new Error('PERPLEXITY_API_KEY is required');

const client = createSearch({ provider: perplexity({ apiKey }) });
const response = await client.web.search({
  query: 'SQLite write concurrency',
  limit: 5,
});
console.log(response.results, response.attempts);
```

Search, Sonar, agent operations, and asynchronous jobs are distinct provider APIs. Select an operation deliberately, preserve citations, and persist remote identifiers before resuming long-running work.

20 include or 20 exclude; both lists cannot be combined.

<a id="native-client"></a>

## Provider-native client

**perplexity-native.ts · server**

```typescript
import { createPerplexityClient } from '@belweave/search-sdk/native-perplexity';

const apiKey = process.env.PERPLEXITY_API_KEY;
if (!apiKey) throw new Error('PERPLEXITY_API_KEY is required');

const client = createPerplexityClient({ apiKey, timeoutMs: 10_000 });
const response = await client.search({ body: { query: 'SQLite write concurrency', max_results: 5 } });
console.log(response.data, response.metadata);
```

Read provider data from `response.data` and sanitized transport details from `response.metadata`. Native TypeScript response types are not runtime schema validation. Preserve the operation's native response and source identities.

<a id="operations"></a>

## Native operation inventory

Methods available on this native client. Paths are relative to each operation's fixed base; a provider may use more than one origin. Eligible operations retry only when you opt into a client retry policy.

| Method | HTTP / relative path | Response / retry eligibility |
| --- | --- | --- |
| `chatCompletions` | `POST /v1/sonar` | json · no automatic retry |
| `chatCompletionsStream` | `POST /v1/sonar` | SSE stream · no automatic retry |
| `search` | `POST /search` | json · no automatic retry |
| `createEmbeddings` | `POST /v1/embeddings` | json · no automatic retry |
| `createContextualizedEmbeddings` | `POST /v1/contextualizedembeddings` | json · no automatic retry |
| `getAsyncChatCompletion` | `GET /v1/async/sonar/{api_request}` | json · eligible |
| `listAsyncChatCompletions` | `GET /v1/async/sonar` | json · eligible |
| `createAsyncChatCompletion` | `POST /v1/async/sonar` | json · no automatic retry |
| `createAgent` | `POST /v1/agent` | json · no automatic retry |
| `createAgentStream` | `POST /v1/agent` | SSE stream · no automatic retry |
| `retrieveAgent` | `GET /v1/agent/{id}` | json · eligible |
| `listAgentFiles` | `GET /v1/agent/{id}/files` | json · eligible |
| `downloadAgentFile` | `GET /v1/agent/{id}/files/{file_id}/content` | bytes · eligible |
| `cancelAgentResponse` | `POST /v1/agent/{id}/cancel` | json · no automatic retry |
| `listModels` | `GET /v1/models` | json · eligible |
| `getComputerUsageAnalytics` | `GET /v1/analytics/computer/usage` | json · eligible |
| `getComputerUsageAnalyticsV2` | `GET /v2/analytics/computer/usage` | json · eligible |
| `listSkills` | `GET /v1/skills` | json · eligible |
| `createSkill` | `POST /v1/skills` | json · no automatic retry |
| `getSkill` | `GET /v1/skills/{skill_id}` | json · eligible |
| `updateSkill` | `PUT /v1/skills/{skill_id}` | json · no automatic retry |
| `deleteSkill` | `DELETE /v1/skills/{skill_id}` | json · no automatic retry |
| `listSkillRevisions` | `GET /v1/skills/{skill_id}/revisions` | json · eligible |
| `downloadSkill` | `GET /v1/skills/{skill_id}/download` | json · eligible |
| `answerQuestions` | `POST /v1/decisions` | json · no automatic retry |
| `routerChatCompletions` | `POST /router/v1/chat/completions` | json · no automatic retry |
| `routerChatCompletionsStream` | `POST /router/v1/chat/completions` | SSE stream · no automatic retry |
| `routerResponses` | `POST /router/v1/responses` | json · no automatic retry |
| `routerResponsesStream` | `POST /router/v1/responses` | SSE stream · no automatic retry |
| `routerMessages` | `POST /router/v1/messages` | json · no automatic retry |
| `routerMessagesStream` | `POST /router/v1/messages` | SSE stream · no automatic retry |
| `listRouterModels` | `GET /router/v1/models` | json · eligible |
| `getRouterModel` | `GET /router/v1/models/{model}` | json · eligible |
| `generateAuthToken` | `POST /generate_auth_token` | json · no automatic retry |
| `revokeAuthToken` | `POST /revoke_auth_token` | text · no automatic retry |

<a id="lifecycle"></a>

## Limits and operation lifecycle

- Pass `signal` and per-call `timeoutMs` on native request input when needed.
- Persist a returned job identifier before explicitly reading or polling the same job. Native clients do not automatically poll.
- SSE data is incremental provider event text. Parse and validate terminal or error events according to the provider contract; there is no reconnect or replay.
- Native operations may create, delete, ingest, or incur charges. A successful HTTP response is not proof that a remote job completed.

<a id="sources"></a>

## Official sources

Use the official reference for current schemas, account access, and operation-specific requirements.

- [Search API reference](https://docs.perplexity.ai/api-reference/search-post)
- [Complete documentation index](https://docs.perplexity.ai/llms.txt)

- [Native request and response reference](https://searchsdk.dev/docs/api/native-transport)
- [All providers](https://searchsdk.dev/docs/providers)
