import type { Model, ModelListResponse } from '@perplexity-ai/perplexity_ai/resources/models';
const models = await client.models.list();client.models.list() sends GET /v1/models and returns a ModelListResponse
containing the models available for the Agent API.
import type {
DecisionCreateParams,
DecisionCreateResponse,
} from '@perplexity-ai/perplexity_ai/resources/decisions';
const response = await client.decisions.create({
model: 'pplx-decider-v1.1-27b',
state: 'The battery stopped charging.',
questions: { defect: { type: 'noul', instructions: 'Does this report a defect?' } },
});client.decisions.create(...) sends POST /v1/decisions and returns a
DecisionCreateResponse with named noul, choice, or score answers.
Types:
APIPublicSearchResultBrowserSessionResponseChatMessageInputChatMessageOutputChoiceContextualizedEmbeddingObjectEmbeddingObjectEmbeddingsUsageJsonSchemaFormatResponseFormatSearchResultUsageInfoUserLocationWebSearchOptions
Types:
Methods:
client.chat.completions.create({ ...params }) -> StreamChunk
Types:
Methods:
client.search.create({ ...params }) -> SearchCreateResponse
Types:
AnnotationContentPartErrorInfoFunctionCallOutputItemFunctionToolInputItemOutputItemResponseFileResponseFileListResponseStreamChunkResponsesCreateParamsResponsesUsageResponseCreateResponseResponseRetrieveResponseResponseCancelResponse
Methods:
client.responses.create({ ...params }) -> ResponseCreateResponseclient.responses.retrieve(responseID) -> ResponseRetrieveResponseclient.responses.cancel(responseID) -> ResponseCancelResponse
To reconnect to a background response's event stream, supply the last event sequence number received:
const stream = await client.responses.retrieve(responseID, {
stream: true,
starting_after: lastSequenceNumber,
});Streaming retrieval requires starting_after. If the API returns HTTP 400 because
the cursor has expired, call client.responses.retrieve(responseID) without
streaming parameters to obtain the current JSON snapshot.
Methods:
client.responses.files.list(responseID) -> ResponseFileListclient.responses.files.content(fileID, { ...params }) -> Response
Types:
Methods:
client.embeddings.create({ ...params }) -> EmbeddingCreateResponse
Types:
Methods:
client.contextualizedEmbeddings.create({ ...params }) -> ContextualizedEmbeddingCreateResponse
Upload custom Skill ZIP bundles with a File or Blob; toFile normalizes byte
buffers and other supported upload sources. Updates and deletion require
expected_revision set to the Skill's current latest_revision. Pass next_page_token as page_token to fetch another page.
import Perplexity, { toFile } from '@perplexity-ai/perplexity_ai';
const client = new Perplexity();
const file = await toFile(zipBytes, 'bundle.zip', { type: 'application/zip' });
let skill = await client.skills.create({ file });
const page = await client.skills.list({ limit: 20 });
skill = await client.skills.retrieve(skill.skill_id);
if (skill.latest_revision == null) throw new Error('A current revision is required to update');
skill = await client.skills.update(skill.skill_id, { file }, { expected_revision: skill.latest_revision });
if (skill.latest_revision == null) throw new Error('A current revision is required to delete');
const revisions = await client.skills.revisions.list(skill.skill_id);
const download = await client.skills.download(skill.skill_id, { revision: skill.latest_revision });
await client.skills.delete(skill.skill_id, { expected_revision: skill.latest_revision });download returns a signed URL and revision; it does not fetch the ZIP.
Methods:
client.browser.sessions.create() -> BrowserSessionResponseclient.browser.sessions.delete(sessionID) -> void
Types:
Methods: