๐Ÿฆœ๐Ÿ”— LangChain + Chinese LLMs โ€” Complete Integration Guide

Build RAG pipelines, agents, and chains with DeepSeek V4, Qwen3, and GLM-4. Uses ChatOpenAI โ€” no special adapter needed.

Get API Key โ†’

Why LangChain + Chinese LLMs?

Chinese LLMs offer better performance on Chinese language tasks, lower pricing, and no rate limits compared to OpenAI. Combined with LangChain's orchestration layer, you can build production-grade AI applications at a fraction of the cost.

Basic Setup

# pip install langchain langchain-openai

from langchain_openai import ChatOpenAI

# Initialize with Chinese LLM
llm = ChatOpenAI(
    model="deepseek-v4",
    openai_api_key="your-api-key",
    openai_api_base="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1",
    temperature=0.7
)

# Test it
result = llm.invoke("Write a Python function to find prime numbers")
print(result.content)

RAG with Chinese Documents

from langchain_openai import ChatOpenAI, OpenAIEmbeddings
from langchain.chains import RetrievalQA
from langchain.vectorstores import FAISS
from langchain.text_splitter import RecursiveCharacterTextSplitter

# Use Qwen embeddings for Chinese text
embeddings = OpenAIEmbeddings(
    model="qwen3.6-flash",
    openai_api_key="your-api-key",
    openai_api_base="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1"
)

# Load Chinese documents and build vector store
# ... (standard LangChain document loading)

# Create RAG chain with DeepSeek V4
qa_chain = RetrievalQA.from_chain_type(
    llm=ChatOpenAI(
        model="deepseek-v4",
        openai_api_key="your-api-key",
        openai_api_base="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1"
    ),
    retriever=vectorstore.as_retriever(search_kwargs={"k": 4}),
    return_source_documents=True
)

Agent with Tool Use

from langchain.agents import create_openai_tools_agent, AgentExecutor
from langchain import hub

# DeepSeek V4 as agent backbone
agent_llm = ChatOpenAI(
    model="deepseek-v4",
    openai_api_key="your-api-key",
    openai_api_base="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1"
)

prompt = hub.pull("hwchase17/openai-tools-agent")
agent = create_openai_tools_agent(agent_llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
Build with Chinese LLMs Today โ†’