Skip to content

feat(ai-perplexity): add Perplexity Search integration#2232

Draft
jliounis wants to merge 1 commit into
Effect-TS:mainfrom
jliounis:psi/feat/perplexity-search
Draft

feat(ai-perplexity): add Perplexity Search integration#2232
jliounis wants to merge 1 commit into
Effect-TS:mainfrom
jliounis:psi/feat/perplexity-search

Conversation

@jliounis
Copy link
Copy Markdown

@jliounis jliounis commented May 19, 2026

Summary

Adds a new @effect/ai-perplexity package providing Effect v4 bindings for the Perplexity Search API.

Re-opens #6204 against the v4 repo per @IMax153's request.

What's added

  • PerplexityClient — HTTP client wrapper that handles authentication and error mapping (platform HttpClient errors → AiError).
  • PerplexitySearch — service with a search(options) method that returns a typed SearchResponse (results: { title, url, snippet, date? }[]).
  • Supports the documented Search API request fields: max_results, max_tokens_per_page, search_domain_filter, search_recency_filter, search_after_date_filter, search_before_date_filter.
  • Validates that search_domain_filter does not mix allow- and deny-list entries (the API does not accept that), failing fast with an AiError whose reason is InvalidRequestError.
  • API key is read from PERPLEXITY_API_KEY, falling back to PPLX_API_KEY, via Config.redacted. A custom URL can be supplied via PERPLEXITY_API_URL or programmatically.
  • Includes a PerplexityConfig service and withClientTransform helper, mirroring the pattern used by @effect/ai-anthropic.

Tests

Unit tests in packages/ai/perplexity/test/PerplexitySearch.test.ts, using a mocked HttpClient so no network calls are made: request body construction, allowlist/denylist handling (including mixed-mode rejection), success decoding, non-2xx error mapping, malformed JSON handling, and header/URL/method assertions.

Run with:

pnpm --filter @effect/ai-perplexity test
pnpm --filter @effect/ai-perplexity check
pnpm --filter @effect/ai-perplexity build

All three pass locally.

Docs

packages/ai/perplexity/README.md documents installation, authentication, basic usage, available options, and the domain-filter caveat.

References

Original v3 PR (closed per feature freeze): Effect-TS/effect#6204

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

🦋 Changeset detected

Latest commit: 23407a8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 28 packages
Name Type
@effect/ai-perplexity Major
effect Major
@effect/opentelemetry Major
@effect/platform-browser Major
@effect/platform-bun Major
@effect/platform-node-shared Major
@effect/platform-node Major
@effect/vitest Major
@effect/ai-anthropic Major
@effect/ai-openai-compat Major
@effect/ai-openai Major
@effect/ai-openrouter Major
@effect/atom-react Major
@effect/atom-solid Major
@effect/atom-vue Major
@effect/sql-clickhouse Major
@effect/sql-d1 Major
@effect/sql-libsql Major
@effect/sql-mssql Major
@effect/sql-mysql2 Major
@effect/sql-pg Major
@effect/sql-pglite Major
@effect/sql-sqlite-bun Major
@effect/sql-sqlite-do Major
@effect/sql-sqlite-node Major
@effect/sql-sqlite-react-native Major
@effect/sql-sqlite-wasm Major
@effect/openapi-generator Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jliounis
Copy link
Copy Markdown
Author

@IMax153 — opened this against effect-smol as requested. Currently sitting as a draft because GitHub's OAuth restriction on this org blocks me from flipping it from my CLI; I'll mark it ready for review shortly. Tests, typecheck, and build all pass locally (pnpm --filter @effect/ai-perplexity {test,check,build}). Happy to adjust the layout or naming to match wherever you'd like the package to live in the v4 layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant