> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-docs-zh.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Pinecone 集成

> 使用 LangChain Python 集成 Pinecone 嵌入模型。

Pinecone的推理API可通过`PineconeEmbeddings`访问。通过Pinecone服务提供文本嵌入。我们首先安装必要的依赖库：

```python theme={null}
!pip install -qU "langchain-pinecone>=0.2.0"
```

接下来我们[注册/登录Pinecone](https://app.pinecone.io)获取API密钥：

```python theme={null}
import os
from getpass import getpass

os.environ["PINECONE_API_KEY"] = os.getenv("PINECONE_API_KEY") or getpass(
    "Enter your Pinecone API key: "
)
```

查阅文档获取可用的[模型](https://docs.pinecone.io/models/overview)。现在我们这样初始化嵌入模型：

```python theme={null}
from langchain_pinecone import PineconeEmbeddings

embeddings = PineconeEmbeddings(model="multilingual-e5-large")
```

从这里我们可以同步或异步创建嵌入，先从同步开始！我们使用`embed_query`将单段文本嵌入为查询嵌入（即RAG中用于搜索的内容）：

```python theme={null}
docs = [
    "Apple is a popular fruit known for its sweetness and crisp texture.",
    "The tech company Apple is known for its innovative products like the iPhone.",
    "Many people enjoy eating apples as a healthy snack.",
    "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces.",
    "An apple a day keeps the doctor away, as the saying goes.",
]
```

```python theme={null}
doc_embeds = embeddings.embed_documents(docs)
doc_embeds
```

```python theme={null}
query = "Tell me about the tech company known as Apple"
query_embed = embeddings.embed_query(query)
query_embed
```

***

> 官方原文：[src/oss/python/integrations/embeddings/pinecone.mdx](https://github.com/langchain-ai/docs/blob/main/src/oss/python/integrations/embeddings/pinecone.mdx) · 非官方翻译，译文由 AI 生成，以英文原文为准。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.