langchain.js
    Preparing search index...

    Wrapper around Perplexity large language models that use the Chat endpoint.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    apiKey?: string

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

    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.

    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.

    maxTokens?: number

    Maximum number of tokens to generate

    model: string

    Model name to use

    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

    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

    webSearchOptions?: WebSearchOptions

    Configuration for using web search in model responses.

    Methods

    • Parameters

      • messages: BaseMessage[]
      • options: unknown
      • OptionalrunManager: any

      Returns Promise<ChatResult>

    • Returns string

    • Parameters

      • messages: BaseMessage[]
      • options: unknown
      • OptionalrunManager: any

      Returns AsyncGenerator<ChatGenerationChunk>

    • Get the parameters used to invoke the model

      Parameters

      • Optionaloptions: unknown

      Returns {
          disable_search: undefined | boolean;
          enable_search_classifier: undefined | boolean;
          frequency_penalty: undefined | number;
          last_updated_after_filter: undefined | string;
          last_updated_before_filter: undefined | string;
          max_tokens: undefined | number;
          model: string;
          presence_penalty: undefined | number;
          reasoning_effort: undefined | "low" | "medium" | "high";
          response_format: any;
          return_images: undefined | boolean;
          return_related_questions: undefined | boolean;
          search_after_date_filter: undefined | string;
          search_before_date_filter: undefined | string;
          search_domain_filter: undefined | any[];
          search_mode: undefined | "academic" | "web";
          search_recency_filter: undefined | string;
          stream: undefined | boolean;
          temperature: undefined | number;
          top_k: undefined | number;
          top_p: undefined | number;
          web_search_options: Record<string, unknown>;
      }

    • Type Parameters

      • RunOutput extends Record<string, any> = Record<string, any>

      Parameters

      • outputSchema: any
      • Optionalconfig: any

      Returns Runnable<BaseLanguageModelInput, RunOutput>

    • Type Parameters

      • RunOutput extends Record<string, any> = Record<string, any>

      Parameters

      • outputSchema: any
      • Optionalconfig: any

      Returns Runnable<BaseLanguageModelInput, { parsed: RunOutput; raw: BaseMessage }>

    • Returns string