This will help you get started with Perplexity embedding models using LangChain. For detailed documentation onDocumentation Index
Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
Use this file to discover all available pages before exploring further.
PerplexityEmbeddings features and configuration options, please refer to the API reference.
Overview
Integration details
| Class | Package | Local | Py support | Package downloads | Package latest |
|---|---|---|---|---|---|
PerplexityEmbeddings | langchain-perplexity | ❌ | ✅ |
Setup
To access Perplexity embedding models you’ll need to create a Perplexity account, get an API key, and install thelangchain-perplexity integration package.
Credentials
Head to https://www.perplexity.ai/account/api/keys to sign up for the Perplexity API and generate an API key. Once you’ve done this, set thePPLX_API_KEY (or PERPLEXITY_API_KEY) environment variable:
Installation
The LangChain Perplexity integration lives in thelangchain-perplexity package:
Instantiation
Now we can instantiate our embedding model object and generate embeddings:pplx-embed-v1-4b (default) and pplx-embed-v1-0.6b. See the Perplexity Embeddings API reference for the current list and dimensions.
Indexing and retrieval
Embedding models are often used in retrieval-augmented generation (RAG) flows, both as part of indexing data as well as later retrieving it. For more detailed instructions, please see our RAG tutorials. Below, see how to index and retrieve data using theembeddings object we initialized above. In this example, we will index and retrieve a sample document in the InMemoryVectorStore.
Direct usage
Under the hood, the vectorstore and retriever implementations are callingembeddings.embed_documents(...) and embeddings.embed_query(...) to create embeddings for the text(s) used in from_texts and retrieval invoke operations, respectively.
You can directly call these methods to get embeddings for your own use cases.
Embed single texts
You can embed single texts or documents withembed_query:
Embed multiple texts
You can embed multiple texts withembed_documents:
Async usage
PerplexityEmbeddings also exposes async methods:
Perplexity returns base64-encoded signed int8 embeddings.
PerplexityEmbeddings decodes these into list[float] values in the range [-128, 127]. The magnitude is preserved from the API’s quantized output; cosine similarity is unaffected by the lack of unit-length normalization.API reference
For detailed documentation onPerplexityEmbeddings features and configuration options, please refer to the API reference and the Perplexity Embeddings API documentation.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

