@@ -51,6 +51,7 @@ const _SUPPORTED_PROVIDERS = [
5151 "cerebras" ,
5252 "deepseek" ,
5353 "xai" ,
54+ "perplexity" ,
5455] as const ;
5556
5657export type ChatModelProvider = ( typeof _SUPPORTED_PROVIDERS ) [ number ] ;
@@ -166,6 +167,19 @@ async function _initChatModelHelper(
166167 ) ;
167168 return new ChatTogetherAI ( { model, ...passedParams } ) ;
168169 }
170+ case "perplexity" : {
171+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
172+ // @ts -ignore - Can not install as a proper dependency due to circular dependency
173+ const { ChatPerplexity } = await import (
174+ // We can not 'expect-error' because if you explicitly build `@langchain/community`
175+ // this import will be able to be resolved, thus there will be no error. However
176+ // this will never be the case in CI.
177+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
178+ // @ts -ignore - Can not install as a proper dependency due to circular dependency
179+ "@langchain/community/chat_models/perplexity"
180+ ) ;
181+ return new ChatPerplexity ( { model, ...passedParams } ) ;
182+ }
169183 default : {
170184 const supported = _SUPPORTED_PROVIDERS . join ( ", " ) ;
171185 throw new Error (
@@ -220,6 +234,8 @@ export function _inferModelProvider(modelName: string): string | undefined {
220234 return "bedrock" ;
221235 } else if ( modelName . startsWith ( "mistral" ) ) {
222236 return "mistralai" ;
237+ } else if ( modelName . startsWith ( "sonar" ) || modelName . startsWith ( "pplx" ) ) {
238+ return "perplexity" ;
223239 } else {
224240 return undefined ;
225241 }
@@ -638,6 +654,7 @@ export async function initChatModel<
638654 * - mistralai (@langchain/mistralai)
639655 * - groq (@langchain/groq)
640656 * - ollama (@langchain/ollama)
657+ * - perplexity (@langchain/community/chat_models/perplexity)
641658 * - cerebras (@langchain/cerebras)
642659 * - deepseek (@langchain/deepseek)
643660 * - xai (@langchain/xai)
0 commit comments