perplexity

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: BSD-2-Clause Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package perplexity provides Perplexity's LLM service on its Agent API, which answers with web search over the OpenAI Responses protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentConfig added in v0.3.0

type AgentConfig struct {
	// APIKey is the Perplexity API key. Required.
	APIKey string `validate:"required"`
	// BaseURL overrides the API base; empty uses the hosted Agent API.
	BaseURL string
	// Model is the model id, such as "openai/gpt-5.5" or
	// "anthropic/claude-haiku-4-5"; empty uses openai/gpt-5.6-luna. With a
	// Preset, it replaces the preset's own model.
	Model string
	// PresetModel leaves the model to the Preset: the request names none, and
	// Model is ignored. It needs a Preset.
	PresetModel bool
	// Preset is a Perplexity preset that sets the model, its instructions, its
	// search budget and how much it reasons, such as "fast", "low", "medium",
	// "high" or "xhigh". Empty sends none, and a request with no Reasoning
	// either then gets the "fast" preset.
	Preset string
	// NoWebSearch stops the service offering the web_search tool on every
	// request, alongside any tools from the context. A preset searches the web
	// whatever this is set to.
	NoWebSearch bool
	// MaxSteps is the maximum number of search and reasoning steps per
	// response; 0 leaves Perplexity's default.
	MaxSteps int `validate:"gte=0"`
	// Instructions is the system prompt, sent alongside the input rather than as
	// a message. A system message on the context takes precedence.
	Instructions string
	// MaxOutputTokens caps the response length; 0 omits it. Anthropic models
	// need it set.
	MaxOutputTokens int
	// Temperature is the sampling temperature; nil omits it.
	Temperature *float64
	// TopP is the nucleus-sampling parameter; nil omits it.
	TopP *float64
	// Reasoning configures how much the model reasons. Set, it replaces the
	// "fast" preset otherwise sent when there is no Preset.
	Reasoning *responses.ReasoningConfig
	// Extra sets arbitrary additional request fields not modeled above, applied
	// to every request. They override the modeled fields on conflict.
	Extra map[string]any
}

AgentConfig configures the Agent API service. The sampling controls are pointers so a deliberate zero is distinguishable from "unset"; a nil value is omitted from the request, leaving the API default.

func (AgentConfig) Validate added in v0.3.0

func (c AgentConfig) Validate() error

Validate reports whether the configuration is usable.

type AgentLLMService added in v1.0.0

type AgentLLMService struct {
	*responses.HTTPLLMService
}

AgentLLMService is the Perplexity LLM service NewAgentLLM builds.

func NewAgentLLM added in v0.3.0

func NewAgentLLM(cfg AgentConfig) *AgentLLMService

NewAgentLLM builds a service for Perplexity's Agent API.

The Agent API answers questions with web search, using models from Perplexity and other providers. It speaks the OpenAI Responses protocol over HTTP, so function calling and multi-turn context work as they do with the Responses HTTP service.

By default the service uses openai/gpt-5.6-luna with web search on. When neither Preset nor Reasoning is set, it sends Perplexity's "fast" preset, its lowest-latency configuration, with the model in place of the preset's own, and logs that it did for each model. Answers can carry citation markers such as "[1]".

Jump to

Keyboard shortcuts

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