Who This Is For
If you're an indie developer or a small team of three to five people preparing to deliver an intelligent customer service solution for e-commerce clients, this article is written for you. We won't discuss grand "LLM strategies" — only an architecture that can be deployed within one or two weeks and won't wake you up in the middle of the night to fight fires.
The Business Pain Points: Four Sins of a Single Model
Most teams' first version of a customer service bot is just a prompt plus a model API, and then problems come one after another:
- Costs out of control. Chit-chat, logistics inquiries, and refund demands all go through the same flagship model, making per-call costs high. During major sales events, inquiry volume increases tenfold — and so does the bill.
- Slow responses, user churn. Flagship models often have 5–10 second first-token latency, which e-commerce users won't tolerate. By the time a lengthy answer to "Where is my package?" finishes generating, the user has already closed the page.
- Capability gaps. For tasks requiring precise reasoning, like explaining refund policies or comparing product specs, cheap small models tend to hallucinate; meanwhile, for abuse detection and intent classification, small models are actually fast and good.
- Vendor lock-in risk. With all logic tied to one vendor's SDK, if they raise prices, throttle your traffic, or change behavior in a release, you're stuck rebuilding overnight.
The core contradiction: no single model wins comprehensively on cost, speed, and accuracy. The answer isn't picking the "best model" — it's multi-model collaboration.
Architecture Design: Three-Tier Routing + Unified Gateway
The overall architecture has four layers:
User message → Access layer → Intent routing layer → Model execution layer → Response aggregation layer1. Access layer: Connects to the store's Wangwang/WeCom/web plugin, handling session management, deduplication, and sensitive-word pre-filtering.
2. Intent routing layer (the brain): Uses a lightweight, fast classification model (e.g., a 7B-class open-source small model or an inexpensive commercial small model) to categorize messages into:
- Category A · High-frequency simple: logistics inquiries, order status, sizing questions
- Category B · Knowledge Q&A: return/exchange policies, after-sales procedures — handled via RAG
- Category C · Complex decisions: dispute mediation, discount calculations, emotionally charged complaints
- Category D · Risky content: abuse, manipulation, compliance-sensitive content
3. Model execution layer (division of labor):
| Intent category | Model choice | Rationale |
|---|---|---|
| A | Small model + business API | Structured queries, no heavy reasoning needed |
| B | Mid-tier model + vector retrieval | Accuracy first, moderate cost |
| C | Flagship model + long prompt | Complex reasoning, typically <15% of traffic |
| D | Small classification model | Millisecond-level interception, direct handoff to human agents |
4. Unified AI API gateway: All model calls don't go directly through vendor SDKs but through a single unified gateway. This is the cost control point and stabilizer of the entire architecture — detailed separately below.
Why a Unified AI API Gateway Significantly Reduces Maintenance Costs
This is the part small teams most easily overlook, yet it delivers the biggest payoff:
- One codebase to integrate all models. No need to stuff four or five vendors' SDKs into your project, or handle authentication, retries, and streaming format differences separately for each. Model calls are unified into a single request format; switching models = changing one parameter.
- Multi-key auto-rotation and failover. When one vendor throttles, the gateway automatically switches to a backup model — your service never notices. This is worth its weight in gold on the night of Double 11.
- Cost and usage visibility. Track token consumption by store and by intent, so you can prove to clients "how much this system saved them" — this is also the basis for your pricing.
- Consolidated degradation paths. Flagship model times out → automatically degrade to mid-tier model → fall back to FAQ scripts. Degradation logic lives in gateway configuration, not scattered across business code.
- Swap models without touching business logic. Model iteration is extremely fast — today's best model may be surpassed in three months. With a gateway, switching cost drops from a full iteration cycle to a one-line config change.
The maintenance cost math is straightforward: without a gateway, adding or swapping each model requires code changes, testing, and deployment; with a gateway, these become ops tasks. For a three-to-five-person team, what you save is the most expensive resource — engineering hours.
Key Implementation Steps
# Pseudocode: intent routing + tiered dispatch
INTENT_MODEL = "fast-classifier" # Intent classification: fast and cheap
MODELS = {
"simple": "lite-model",
"rag": "standard-model",
"complex": "flagship-model",
}
def handle_message(msg, session):
intent = gateway.chat(
model=INTENT_MODEL,
prompt=f"分类以下电商客服消息: {msg.text}",
timeout=1.5, # 超时直接降级
fallback="simple",
)
if intent == "risk":
return route_to_human(msg) # 转人工
if intent == "simple":
data = order_api.query(msg.order_id)
return gateway.chat(
model=MODELS["simple"],
prompt=render("logistics.tpl", data),
)
if intent == "rag":
ctx = vector_db.search(msg.text, top_k=3)
return gateway.chat(model=MODELS["rag"], context=ctx)
# complex:旗舰模型 + 会话历史
return gateway.chat(
model=MODELS["complex"],
messages=session.history + [msg],
stream=True,
)Deployment checklist:
- Week 1: Catalog the store's high-frequency questions, label 200 samples for intent classification evaluation; integrate the unified gateway and get one model's pipeline working end to end.
- Week 2: Integrate order/logistics APIs so Category A queries hit business data directly; build the knowledge base vector retrieval and launch Category B.
- Week 3: Configure Category C flagship model scripts and human-handoff thresholds; configure gateway degradation, rate limiting, and multi-key rotation.
- After launch: Review misrouted cases weekly and feed insights back into the classification prompt; optimize model allocation ratios based on gateway usage reports.
Expected Results
Based on typical e-commerce scenarios (not specific client data): roughly 70% of inquiries fall into the Category A small-model path, 20% go through RAG, and 10% require the flagship model. Compared to routing everything through a flagship model, combined token costs can drop by an order of magnitude, and average response time shrinks to under 2 seconds. That's the essence of multi-model collaboration — trading routing precision for cost and speed.
The architecture doesn't need to be perfect on day one. Start by getting "gateway + two-tier routing" working, then refine gradually. If you want to get hands-on, start by signing up for a unified gateway service like https://api.thistoken.ai/register — one key gives you access to multiple mainstream models, freeing you from the SDK swamp so you can focus on polishing routing and user experience — that's your real competitive moat.
---
Want to run the example right away? Visit https://api.thistoken.ai/register to sign up for ThisToken.AI, get your API key, and start building.
Vous voulez essayer Token.AI ?
Créez une API Key au niveau du projet, activez les canaux dans la console et configurez le routage, les budgets et les journaux d'audit.
注册 ThisToken.AI 并获取 API Key