Interface defining the parameters for the Perplexity chat model.

interface PerplexityChatInput {
    apiKey?: string;
    cache?: boolean | BaseCache<Generation[]>;
    callbackManager?: CallbackManager;
    callbacks?: Callbacks;
    disableSearch?: boolean;
    disableStreaming?: boolean;
    enableSearchClassifier?: boolean;
    frequencyPenalty?: number;
    lastUpdatedAfterFilter?: string;
    lastUpdatedBeforeFilter?: string;
    maxConcurrency?: number;
    maxRetries?: number;
    maxTokens?: number;
    metadata?: Record<string, unknown>;
    model: string;
    onFailedAttempt?: FailedAttemptHandler;
    presencePenalty?: number;
    reasoningEffort?: "low" | "medium" | "high";
    returnImages?: boolean;
    returnRelatedQuestions?: boolean;
    searchAfterDateFilter?: string;
    searchBeforeDateFilter?: string;
    searchDomainFilter?: any[];
    searchMode?: "academic" | "web";
    searchRecencyFilter?: string;
    streaming?: boolean;
    tags?: string[];
    temperature?: number;
    timeout?: number;
    topK?: number;
    topP?: number;
    verbose?: boolean;
    webSearchOptions?: WebSearchOptions;
}

Hierarchy

  • BaseChatModelParams
    • PerplexityChatInput

Implemented by

Properties

apiKey?: string

API key for Perplexity. Defaults to the value of PERPLEXITY_API_KEY environment variable.

cache?: boolean | BaseCache<Generation[]>
callbackManager?: CallbackManager

Use callbacks instead

callbacks?: Callbacks
disableSearch?: boolean

When set to true, disables web search completely and the model will only use its training data to respond. This is useful when you want deterministic responses without external information.

disableStreaming?: boolean

Whether to disable streaming.

If streaming is bypassed, then stream() will defer to invoke().

  • If true, will always bypass streaming case.
  • If false (default), will always use streaming case if available.
enableSearchClassifier?: boolean

Enables a classifier that decides if web search is needed based on your query.

frequencyPenalty?: number

Frequency penalty greater than 0

lastUpdatedAfterFilter?: string

Filters search results to only include content last updated after this date.

lastUpdatedBeforeFilter?: string

Filters search results to only include content last updated before this date.

maxConcurrency?: number

The maximum number of concurrent calls that can be made. Defaults to Infinity, which means no limit.

maxRetries?: number

The maximum number of retries that can be made for a single call, with an exponential backoff between each attempt. Defaults to 6.

maxTokens?: number

Maximum number of tokens to generate

metadata?: Record<string, unknown>
model: string

Model name to use

onFailedAttempt?: FailedAttemptHandler

Custom handler to handle failed attempts. Takes the originally thrown error object as input, and should itself throw an error if the input error is not retryable.

presencePenalty?: number

Presence penalty between -2 and 2

reasoningEffort?: "low" | "medium" | "high"

Controls how much computational effort the AI dedicates to each query for deep research models. Only applicable for sonar-deep-research.

returnImages?: boolean

Whether to return images

returnRelatedQuestions?: boolean

Determines whether or not a request to an online model should return related questions.

searchAfterDateFilter?: string

Filters search results to only include content published after this date.

searchBeforeDateFilter?: string

Filters search results to only include content published before this date.

searchDomainFilter?: any[]

Search domain filter - limit the citations used by the online model to URLs from the specified domains.

searchMode?: "academic" | "web"

Controls the search mode used for the request. When set to 'academic', results will prioritize scholarly sources.

searchRecencyFilter?: string

Returns search results within the specified time interval - does not apply to images. Values include month, week, day, hour.

streaming?: boolean

Whether to stream the results or not

tags?: string[]
temperature?: number

Temperature parameter between 0 and 2

timeout?: number

Timeout for requests to Perplexity

topK?: number

Top K parameter between 1 and 2048

topP?: number

Top P parameter between 0 and 1

verbose?: boolean
webSearchOptions?: WebSearchOptions

Configuration for using web search in model responses.