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

# Nebius 集成

> 使用 LangChain Python 与 Nebius 集成。

所有与 Nebius Token Factory 相关的功能

> [Nebius Token Factory](https://tokenfactory.nebius.com/) 提供 API 访问，可使用各种用例的最先进大型语言模型和嵌入模型。

## 安装与设置

Nebius 集成可通过 pip 安装：

<CodeGroup>
  ```bash pip theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  pip install langchain-nebius
  ```

  ```bash uv theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  uv add langchain-nebius
  ```
</CodeGroup>

要使用 Nebius Token Factory，您需要一个 API 密钥，可以从 [Nebius Token Factory](https://tokenfactory.nebius.com/) 获取。API 密钥可以作为初始化参数 `api_key` 传递，或设置为环境变量 `NEBIUS_API_KEY`。

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import os
os.environ["NEBIUS_API_KEY"] = "YOUR-NEBIUS-API-KEY"
```

### 可用模型

支持的完整模型列表可在 [Nebius Token Factory 模型页面](https://tokenfactory.nebius/models) 找到。

## 聊天模型

### ChatNebius

`ChatNebius` 类允许您与 Nebius Token Factory 的聊天模型进行交互。

参见 [使用示例](/oss/python/integrations/chat/nebius)。

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_nebius import ChatNebius

# 初始化聊天模型
chat = ChatNebius(
    model="moonshotai/Kimi-K2.5",  # 从可用模型中选择
    temperature=0.6,
    top_p=0.95
)
```

## 嵌入模型

### NebiusEmbeddings

`NebiusEmbeddings` 类允许您使用 Nebius Token Factory 的嵌入模型生成向量嵌入。

参见 [使用示例](/oss/python/integrations/embeddings/nebius)。

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_nebius import NebiusEmbeddings

# 初始化嵌入
embeddings = NebiusEmbeddings(
    model="Qwen/Qwen3-Embedding-8B"  # 默认嵌入模型
)
```

## 检索器

### NebiusRetriever

`NebiusRetriever` 使用来自 Nebius Token Factory 的嵌入实现高效的相似性搜索。它利用高质量的嵌入模型实现文档的语义搜索。

参见 [使用示例](/oss/python/integrations/retrievers/nebius)。

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_core.documents import Document
from langchain_nebius import NebiusEmbeddings, NebiusRetriever

# 创建示例文档
docs = [
    Document(page_content="Paris is the capital of France"),
    Document(page_content="Berlin is the capital of Germany"),
]

# 初始化嵌入
embeddings = NebiusEmbeddings()

# 创建检索器
retriever = NebiusRetriever(
    embeddings=embeddings,
    docs=docs,
    k=2  # 返回的文档数量
)
```

## 工具

### NebiusRetrievalTool

`NebiusRetrievalTool` 允许您基于 NebiusRetriever 为代理创建工具。

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_nebius import NebiusEmbeddings, NebiusRetriever, NebiusRetrievalTool
from langchain_core.documents import Document

# 创建示例文档
docs = [
    Document(page_content="Paris is the capital of France and has the Eiffel Tower"),
    Document(page_content="Berlin is the capital of Germany and has the Brandenburg Gate"),
]

# 创建嵌入和检索器
embeddings = NebiusEmbeddings()
retriever = NebiusRetriever(embeddings=embeddings, docs=docs)

# 创建检索工具
tool = NebiusRetrievalTool(
    retriever=retriever,
    name="nebius_search",
    description="Search for information about European capitals"
)
```

***

<div className="source-links">
  <Callout icon="terminal-2">
    [连接这些文档](/use-these-docs) 到 Claude、VSCode 等，通过 MCP 获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/providers/nebius.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
