Polyweave

@polyweave/perplexity (1.0.2)

Published 2026-07-10 18:31:37 +00:00 by Dvorak

Installation

@polyweave:registry=https://hub.kl1.tenere.ai/api/packages/Polyweave/npm/
npm install @polyweave/perplexity@1.0.2
"@polyweave/perplexity": "1.0.2"

About this package

Perplexity

Search-grounded AI adapter for Polyweave. Powered by Perplexity's Sonar API.

Published as @polyweave/perplexity.

Synopsis

import { createPerplexityAdapter } from '@polyweave/perplexity';
import { createTextFrame, createFrameSink } from '@polyweave/core';

var adapter = createPerplexityAdapter({ apiKey: process.env.PERPLEXITY_API_KEY, model: 'sonar-pro' });

adapter.source.pipe(createFrameSink(function(frame) {
  if (frame.type === 'TEXT') console.log(frame.content.text);
}));

adapter.sink.write(createTextFrame('What is the latest news about AI?'));

Install

npm install @polyweave/perplexity

Description

Perplexity adapter supporting the full Sonar API: search-grounded chat completions, streaming via SSE, tool/function calling, and vision input. All interaction is via Polyweave's pure push-stream frame protocol — no Promises, no async/await.

Models: sonar, sonar-pro, sonar-reasoning-pro, sonar-deep-research.

API

createPerplexityAdapter(config)

Parameter Type Default Description
config.apiKey string process.env.PERPLEXITY_API_KEY API key
config.baseURL string https://api.perplexity.ai Base URL override
config.model string sonar Default model
config.budget number 0 Budget cap (0 = unlimited)
config.name string null Node name for PARAM targeting
config.timeout number 120000 Request timeout in ms

Returns an IFrameDuplex with source and sink.

Frame Protocol

Inbound Outbound
TEXT, IMAGE TEXT, TOOL_CALL, RECEIPT, ERROR, END
PARAM
COST_CHECK COST
DESCRIBE DESCRIPTION

PARAM Keys

model, max_tokens, temperature, top_p, stream, system, tools, tool_choice, response_format, search_recency_filter, search_domain_filter, budget, apiKey

Tests

npm test

Covers adapter construction, frame passthrough, and PARAM accumulation.

Requirements

Node.js 18 or later. ESM only.

Caveats

Perplexity's search grounding is automatic on Sonar models. The search_recency_filter and search_domain_filter PARAM keys control search behavior. Citation annotations appear inline in output text.

See Also

License

MIT

Dependencies

Development Dependencies

ID Version
@rigor/core *

Peer Dependencies

ID Version
@polyweave/core *
@polyweave/costs *

Keywords

polyweave perplexity llm ai search citations adapter
Details
npm
2026-07-10 18:31:37 +00:00
4
John Dvorak
SEE LICENSE IN LICENSE
6.1 KiB
Assets (1)
Versions (5) View all
1.0.6 2026-07-11
1.0.3 2026-07-11
1.0.2 2026-07-10
1.0.1 2026-07-10
1.0.0 2026-07-10