perplexity

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package perplexity wires Perplexity's Search API into web.Searcher.

Endpoint

POST https://api.perplexity.ai/search

Authentication is a bearer token in the Authorization header.

Parameter mapping

web.SearchRequest → Perplexity request:

  • Query → query (required)
  • MaxResults → max_results (omitted when unset)
  • AllowedDomains → search_domain_filter (capped at 20 entries)
  • BlockedDomains → search_domain_filter with "-" prefix (capped at 20 entries). The allow- and block-list share the same field; if both are set the caller-validated mutual exclusion makes this a non-issue.
  • Recency → search_recency_filter: hour/day/week/month/year

Response mapping

Perplexity result → web.SearchResult:

  • title → Title
  • url → URL
  • snippet → Snippet
  • date → PublishedTime (parsed as time.DateOnly)

Perplexity does not echo the original query; the tool forwards what the caller supplied so web.SearchResponse.Query stays meaningful.

Perplexity's transport DTOs stay private to keep the provider boundary normalized and self-contained.

Reference

https://docs.perplexity.ai/api-reference/search-post

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements web.Searcher against Perplexity's Search API and normalizes its link results into the shared web contract.

func NewClient

func NewClient(config Config) (*Client, error)

NewClient requires the API key at construction so a missing credential fails at wiring rather than as an authorization error on a model's first search.

func (*Client) Search

func (c *Client) Search(ctx context.Context, request *web.SearchRequest) (*web.SearchResponse, error)

type Config

type Config struct {
	APIKey     string
	BaseURL    string
	HTTPClient *http.Client
}

Config takes an optional http.Client so the host keeps ownership of timeouts, proxying, and transport instrumentation instead of inheriting whatever this package would otherwise choose.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL