Integrating Domestic Models via LangChain: A Unified Gateway Approach for Small Teams
Anyone who has led a small team knows that what truly drains energy is often not the technology itself, but the process. On a three-developer team, each person registers their own model account, writes their own call wrapper, and scatters their keys across different codebases—when something goes wrong, you spend an entire afternoon figuring out "whose credentials this code uses, which model, and through which path."
This article addresses exactly that: how to integrate domestic (Chinese) models into LangChain using an OpenAI-compatible endpoint plus a unified gateway (ThisToken.AI), converging the integration process into a single team standard. The focus isn't tuning a particular model's parameters, but ensuring that four questions always have answers: "who is calling, what are they calling, how much does it cost, and who to contact when something breaks."
Why Managers Should Care About Integration Approach
A solo developer's common practice is to use each vendor's official SDK separately. As soon as the team grows even slightly, problems emerge:
- Key management gets out of control. Each member and each project has its own keys, and any personnel change requires a full sweep of code repositories.
- Duplicated wrappers. DeepSeek, Qwen, and GLM each have their own SDK with different interface styles, so team members each write their own adapter layers, and code can't be reused.
- Vendor lock-in. Switching models means changing business code—high review cost, difficult rollbacks.
The solution is to route all model calls through a single OpenAI-compatible endpoint. LangChain's support for the OpenAI interface is the most mature; as long as a domestic model is compatible with this protocol, integration becomes a configuration change rather than a code refactor. ThisToken.AI is exactly such an aggregation gateway: register once, get a single key, and you can switch between different domestic models within its coverage, with costs settled uniformly—see the official pricing page for details.
Step 1: Register and Obtain a Key (Preferably Managed by One Person)
The process is simple and can be completed in five minutes:
- Visit the ThisToken.AI registration page and sign up with your email;
- Go to the console and create an API Key;
- Recommendation: The team should create only one or two keys (e.g., split by "production environment / development environment"), kept by the team lead. Members obtain them via environment variables—the keys themselves never enter code repositories or chat logs.
This step matters from a management perspective: the fewer the keys, the easier the audit. The console shows the call activity for each key, making it easy to answer "which project's consumption is rising" during monthly reviews.
Step 2: Get Your First Piece of Code Running
Environment setup:
pip install langchain langchain-openaiConfigure the key as an environment variable:
export THISTOKEN_API_KEY="你的密钥"The following code can be copied and run directly—note the base_url:
import os
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
# 关键:所有模型统一走同一个 OpenAI 兼容端点
llm = ChatOpenAI(
model="deepseek-chat", # 换模型只改这一行
api_key=os.environ["THISTOKEN_API_KEY"],
base_url="https://api.thistoken.ai/v1",
temperature=0.3,
)
prompt = ChatPromptTemplate.from_messages([
("system", "你是一个简洁的中文技术助手。"),
("human", "{question}"),
])
chain = prompt | llm | StrOutputParser()
print(chain.invoke({"question": "用一句话解释什么是向量数据库"}))If the console outputs a response, the pipeline is working. What managers should really pay attention to are the three things this code demonstrates:
First, switching models is configuration, not engineering. To swap deepseek-chat for another compatible model, you only change the model parameter. The team can decide in review "which model to use at which stage," with minimal implementation cost.
Second, LangChain's abstraction is reused at the team level. The prompt | llm | parser chain can be packaged as a shared team module, so members no longer rebuild adapter layers when integrating into their own business code.
Third, keys appear only in environment variables. Code can go straight into the repository, and Code Review requires no sanitization.
Three Management Recommendations for the Team
Getting it running is only the starting point. To manage this properly, implement three standards:
1. Route all integration through a single document. Maintain an internal "model integration guide" page specifying the endpoint address, how to obtain keys, and recommended models and their uses. New hires can get a demo running on day one without needing verbal handover from senior members.
2. Divide budgets by key. Use different keys for production and development, so the console distinguishes the two consumption pools. When investigating budget overruns, first see which environment and which key is rising, then trace it to the specific project. See the official pricing page for billing details.
3. Keep a record of changes. Even "seemingly trivial" changes like switching models or adjusting parameters should be announced in the group chat or noted in commit messages. Problems caused by behavioral differences between models often appear late—a record is what enables quick retrospection.
Conclusion
A small team's advantage is agility, but only if the process itself is clean enough. Once you converge model integration into one compatible endpoint, one standards document, and one key management policy, you'll find that switching models, adding members, or controlling budgets afterwards are all just small adjustments within an established framework.
If you're about to set up this workflow for your team, start by registering an account and running the code above yourself, then turn it into team documentation: https://api.thistoken.ai/register
---
Every example in this post runs with a single API key — get yours at https://api.thistoken.ai/register and start in minutes.
Хотите попробовать Token.AI?
Создайте API Key уровня проекта, включите каналы в консоли и настройте маршрутизацию, бюджеты и журналы аудита.
注册 ThisToken.AI 并获取 API Key