Skip to article

Perplexity

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

On this page

Normalized search

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
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.

Provider-native client

perplexity-native.ts · server
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.

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.

35 / 35
MethodHTTP / relative pathResponse / retry eligibility
chatCompletionsPOST /v1/sonarjson · no automatic retry
chatCompletionsStreamPOST /v1/sonarSSE stream · no automatic retry
searchPOST /searchjson · no automatic retry
createEmbeddingsPOST /v1/embeddingsjson · no automatic retry
createContextualizedEmbeddingsPOST /v1/contextualizedembeddingsjson · no automatic retry
getAsyncChatCompletionGET /v1/async/sonar/{api_request}json · eligible
listAsyncChatCompletionsGET /v1/async/sonarjson · eligible
createAsyncChatCompletionPOST /v1/async/sonarjson · no automatic retry
createAgentPOST /v1/agentjson · no automatic retry
createAgentStreamPOST /v1/agentSSE stream · no automatic retry
retrieveAgentGET /v1/agent/{id}json · eligible
listAgentFilesGET /v1/agent/{id}/filesjson · eligible
downloadAgentFileGET /v1/agent/{id}/files/{file_id}/contentbytes · eligible
cancelAgentResponsePOST /v1/agent/{id}/canceljson · no automatic retry
listModelsGET /v1/modelsjson · eligible
getComputerUsageAnalyticsGET /v1/analytics/computer/usagejson · eligible
getComputerUsageAnalyticsV2GET /v2/analytics/computer/usagejson · eligible
listSkillsGET /v1/skillsjson · eligible
createSkillPOST /v1/skillsjson · no automatic retry
getSkillGET /v1/skills/{skill_id}json · eligible
updateSkillPUT /v1/skills/{skill_id}json · no automatic retry
deleteSkillDELETE /v1/skills/{skill_id}json · no automatic retry
listSkillRevisionsGET /v1/skills/{skill_id}/revisionsjson · eligible
downloadSkillGET /v1/skills/{skill_id}/downloadjson · eligible
answerQuestionsPOST /v1/decisionsjson · no automatic retry
routerChatCompletionsPOST /router/v1/chat/completionsjson · no automatic retry
routerChatCompletionsStreamPOST /router/v1/chat/completionsSSE stream · no automatic retry
routerResponsesPOST /router/v1/responsesjson · no automatic retry
routerResponsesStreamPOST /router/v1/responsesSSE stream · no automatic retry
routerMessagesPOST /router/v1/messagesjson · no automatic retry
routerMessagesStreamPOST /router/v1/messagesSSE stream · no automatic retry
listRouterModelsGET /router/v1/modelsjson · eligible
getRouterModelGET /router/v1/models/{model}json · eligible
generateAuthTokenPOST /generate_auth_tokenjson · no automatic retry
revokeAuthTokenPOST /revoke_auth_tokentext · no automatic retry

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.

Official sources

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