PerplexityProvider

org.llm4s.llmconnect.provider.PerplexityProvider

Registration for Perplexity's Agent API: provider = "perplexity".

The Agent API (POST https://api.perplexity.ai/v1/agent) replaced Sonar Chat Completions, whose support Perplexity ended on 27 September 2026. It speaks the OpenAI Responses format, so it is a client of its own rather than an openai-compatible dialect. A section names an Agent API model in its provider/model form and takes the key as apiKey, or from llm4s.credentials.perplexity.apiKey, which PERPLEXITY_API_KEY binds:

perplexity-main {
 provider = "perplexity"
 model    = "perplexity/sonar"
}

Extras: webSearch (default true) offers the model Perplexity's web_search tool on every request; contextWindow and reserveCompletion override the window, which otherwise comes from the model registry entry of the model's own vendor (anthropic/claude-sonnet-5-5 looks up anthropic's claude-sonnet-5-5), else org.llm4s.llmconnect.config.PerplexityConfig.DEFAULT_CONTEXT_WINDOW.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

Constructs the client for a ProviderConfig this provider produced.

Constructs the client for a ProviderConfig this provider produced.

config is whatever the caller passed, so implementations must check the type rather than cast — ProviderDescriptor.expectConfig does that and produces the standard mismatch error.

A client that sends its own HTTP requests sends them through options.httpClient when it is set, and does not close that client, and declares so with features.customHttpClient = true (it defaults to false, which a provider built on a vendor SDK keeps).

Attributes

def buildConfig(providerName: String, section: NamedProviderConfig)(using resolver: ContextWindowResolver): Result[ProviderConfig]

Turns a validated config section into the runtime ProviderConfig for this provider.

Turns a validated config section into the runtime ProviderConfig for this provider.

The section has already been checked against configSpec, so required fields are present and section.extras holds exactly the declared provider-specific keys that have a value (defaults applied, deprecated aliases resolved). A Left here means something configSpec cannot express (a malformed value, say).

Value parameters

providerName

the user's instance name (llm4s.providers.<name>), for error messages.

Attributes

Inherited methods

def aliases: Set[String]

Alternative spellings accepted in provider = "...", folded onto id.

Alternative spellings accepted in provider = "...", folded onto id.

For example Gemini accepts "google". Aliases are matched after the same trim/lowercase canonicalisation as id itself.

Attributes

Inherited from:
ProviderDescriptor

What this provider's client implements. Defaults to the full interface.

What this provider's client implements. Defaults to the full interface.

Attributes

Inherited from:
ProviderDescriptor

Live model discovery, when the provider's API offers it.

Live model discovery, when the provider's API offers it.

Attributes

Inherited from:
ProviderDescriptor

Concrete fields

val ContextWindowKey: String

The key overriding the model's context window.

The key overriding the model's context window.

Attributes

val ReserveCompletionKey: String

The key overriding the tokens held back for the reply.

The key overriding the tokens held back for the reply.

Attributes

val WebSearchKey: String

The key that turns the web_search tool on or off.

The key that turns the web_search tool on or off.

Attributes

Which config fields this provider requires, its default endpoint, and the provider-specific keys (ProviderConfigSpec.extras) its section accepts.

Which config fields this provider requires, its default endpoint, and the provider-specific keys (ProviderConfigSpec.extras) its section accepts.

Attributes

val id: ProviderId

Canonical id, e.g. ProviderId("openai"). Must be unique within a registry.

Canonical id, e.g. ProviderId("openai"). Must be unique within a registry.

Attributes