How to Use Chinese LLMs with LangChain (2026 Guide)

July 2026 | 6 min read | By AI-Token-Hub Team

Chinese LLMs like DeepSeek, Qwen, and GLM offer incredible performance at a fraction of OpenAI's cost. This guide shows you how to integrate them with LangChain in minutes using AI-Token-Hub's unified API.

Why Chinese LLMs + LangChain?

LangChain is the most popular framework for building LLM-powered applications. Combined with Chinese LLMs, you get:

Prerequisites

pip install langchain-openai langchain-core

1 Get your AI-Token-Hub API key

Sign up at /get-started and get 50,000 free tokens.

2 Set up the ChatModel

from langchain_openai import ChatOpenAI

# Initialize with AI-Token-Hub
llm = ChatOpenAI(
    model="deepseek-v4",  # or qwen3.6-flash, glm-4-flash, etc.
    api_key="sk-your-ai-token-hub-key",
    base_url="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1",
    temperature=0.7
)

# Use it like any LangChain model
response = llm.invoke("Explain quantum computing in simple terms")
print(response.content)

3 Build a RAG pipeline with Chinese LLMs

from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser

# Setup
llm = ChatOpenAI(
    model="deepseek-v4",
    api_key="sk-your-key",
    base_url="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1"
)

# Create a chain
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant that answers questions concisely."),
    ("user", "{question}")
])

chain = prompt | llm | StrOutputParser()

# Run it
result = chain.invoke({"question": "What are the advantages of DeepSeek V4?"})
print(result)

4 Multi-model routing (advanced)

Use different models for different tasks to optimize cost and quality:

# Expensive model for complex tasks
complex_llm = ChatOpenAI(
    model="deepseek-r1",
    api_key="sk-your-key",
    base_url="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1"
)

# Cheap model for simple tasks
simple_llm = ChatOpenAI(
    model="deepseek-v4-flash",  # $0.001/M tokens!
    api_key="sk-your-key",
    base_url="https://eaf9553505eeb8f5-115-190-107-107.serveousercontent.com/v1"
)

# Route based on task complexity
def route_query(question):
    if len(question.split()) > 20 or "analyze" in question.lower():
        return complex_llm
    return simple_llm

Model Selection Guide for LangChain

Use CaseRecommended ModelCost/M tokens
Chatbot / Q&Adeepseek-v4-flash$0.001
Content Generationqwen3.6-flash$0.01-0.03
Code Generationdeepseek-v4$0.27/1.10
Complex Reasoningdeepseek-r1$0.50/2.00
Prototyping / Testingglm-4-flashFREE
💡 Pro Tip: Use glm-4-flash for development and testing - it's completely free! Then switch to deepseek-v4 or qwen3.6-flash for production.

Cost Comparison: LangChain + Chinese LLMs vs OpenAI

For a typical RAG application processing 1M tokens/day:

ProviderMonthly Cost
GPT-4o (OpenAI)~$375
Claude 3.5 Sonnet~$540
DeepSeek V4 (via AI-Token-Hub)~$41
Qwen 3.6 Flash (via AI-Token-Hub)~$6

Start Building Today

Get your free API key and start building with Chinese LLMs + LangChain in under 5 minutes.

Get Free API Key → View Full API Docs →

← Back to Blog | Cost Calculator