Skip to main content
与 Nebius AI Studio 相关的所有功能
Nebius AI Studio 提供对多种最先进大语言模型和嵌入模型的 API 访问,适用于各种使用场景。

安装与设置

可通过 pip 安装 Nebius 集成:
pip install langchain-nebius
要使用 Nebius AI Studio,您需要一个 API 密钥,可从 Nebius AI Studio 获取。API 密钥可以作为初始化参数 api_key 传入,也可以设置为环境变量 NEBIUS_API_KEY
import os
os.environ["NEBIUS_API_KEY"] = "YOUR-NEBIUS-API-KEY"

可用模型

支持的模型完整列表请参阅 Nebius AI Studio 文档

对话模型

ChatNebius

ChatNebius 类允许您与 Nebius AI Studio 的对话模型进行交互。 查看使用示例
from langchain_nebius import ChatNebius

# Initialize the chat model
chat = ChatNebius(
    model="Qwen/Qwen3-30B-A3B-fast",  # Choose from available models
    temperature=0.6,
    top_p=0.95
)

嵌入模型

NebiusEmbeddings

NebiusEmbeddings 类允许您使用 Nebius AI Studio 的嵌入模型生成向量嵌入。 查看使用示例
from langchain_nebius import NebiusEmbeddings

# Initialize embeddings
embeddings = NebiusEmbeddings(
    model="BAAI/bge-en-icl"  # Default embedding model
)

检索器

NebiusRetriever

NebiusRetriever 使用 Nebius AI Studio 的嵌入实现高效的相似度搜索。它利用高质量的嵌入模型在文档上进行语义搜索。 查看使用示例
from langchain_core.documents import Document
from langchain_nebius import NebiusEmbeddings, NebiusRetriever

# Create sample documents
docs = [
    Document(page_content="Paris is the capital of France"),
    Document(page_content="Berlin is the capital of Germany"),
]

# Initialize embeddings
embeddings = NebiusEmbeddings()

# Create retriever
retriever = NebiusRetriever(
    embeddings=embeddings,
    docs=docs,
    k=2  # Number of documents to return
)

工具

NebiusRetrievalTool

NebiusRetrievalTool 允许您基于 NebiusRetriever 为 Agent 创建工具。
from langchain_nebius import NebiusEmbeddings, NebiusRetriever, NebiusRetrievalTool
from langchain_core.documents import Document

# Create sample documents
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"),
]

# Create embeddings and retriever
embeddings = NebiusEmbeddings()
retriever = NebiusRetriever(embeddings=embeddings, docs=docs)

# Create retrieval tool
tool = NebiusRetrievalTool(
    retriever=retriever,
    name="nebius_search",
    description="Search for information about European capitals"
)