Why one model for every ticket is the expensive default
A support inbox is not one workload. It is at least four: classify the ticket, answer from documented facts, reason across policy and order history, and rewrite an answer into the customer's language and register. Running your strongest model for all four is the easiest design to ship and the most expensive one to operate. Running your cheapest model for all four shows up later, as confidently wrong refund answers and a queue of angry follow-ups.
The workable middle path is boring: a cheap router in front, tiered generation behind it, and a cache in front of both. The nice property is that this design is language-agnostic. Routing decisions depend on intent and risk, not on whether the customer wrote in Spanish, Japanese, or Portuguese, so you build the pipeline once and it serves every locale you support.
Step 1 — Route by language, intent, and risk in one cheap call
Do not bolt on a separate language-detection library and then a classification model. One short call to a fast model reads the original message, returns the language code, the intent, and a risk flag in a single structured response. Because it reads the customer's own words, mixed-script tickets (Japanese with English product names, for example) are handled without a pre-translation step that would double your token spend and mangle idioms.
import json
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ['AICREDITS_API_KEY'],
base_url='https://api.aicreditsapi.com/v1',
)
ROUTER_SYSTEM = '''You triage customer support tickets. Return JSON only, with keys:
"language": ISO 639-1 code of the customer's message,
"intent": billing | refund | technical | account | shipping | other,
"risk": low | medium | high,
"needs_deep_reasoning": true | false.
high risk = legal threat, chargeback, safety issue, account deletion, press inquiry.
needs_deep_reasoning = the answer requires combining several policy rules or order records.
Never answer the customer. Never translate.'''
def route(ticket: str) -> dict:
resp = client.chat.completions.create(
model='deepseek-v4-flash',
messages=[
{'role': 'system', 'content': ROUTER_SYSTEM},
{'role': 'user', 'content': ticket[:2000]},
],
response_format={'type': 'json_object'},
temperature=0,
max_tokens=150,
)
return json.loads(resp.choices[0].message.content)
def pick_model(info: dict) -> str:
if info.get('risk') == 'high' or info.get('needs_deep_reasoning'):
return 'deepseek-v4-pro'
return 'deepseek-v4-flash'
if __name__ == '__main__':
info = route('Me cobraron dos veces y quiero un reembolso o voy a desconocer el cargo.')
print(info)
print(pick_model(info))
High risk → pro plus a human queue. Legal threats, chargebacks, and account-deletion requests are where a fluent but wrong answer becomes expensive. The extra model cost is noise next to the risk.
needs_deep_reasoning → pro. Refund calculations across multiple policy rules, order lookups with exceptions, or anything that requires reconciling two data sources.
Everything else → flash. FAQ answers grounded in retrieved documentation, order-status replies, tone rewrites, and translation of agent drafts.
Unknown language → still flash. Do not fail closed on an unsupported locale; route it normally and flag it so agents can spot-check the first few replies.
Step 2 — Answer in the customer's language, not yours
The instinct to translate the ticket to English, generate, then translate back is a trap. It costs two extra calls, and meaning drifts on each hop: hedging disappears, currency formats get mangled, and polite register collapses into something blunt. Instead, retrieve your documentation in whichever language it is authoritative, then instruct the model to answer in the detected language using only the retrieved facts.
Two guardrails matter more than prompt cleverness. First, a glossary of product names, plan names, and legally reviewed phrases that must never be translated. Second, an explicit permission to escalate: if the retrieved context does not contain the answer, the model should return an empty reply with an escalation flag rather than improvising policy. That single instruction removes most of the hallucinated-refund-policy class of incident.
import json
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ['AICREDITS_API_KEY'],
base_url='https://api.aicreditsapi.com/v1',
)
# Names and legally reviewed phrases that must never be translated.
GLOSSARY = ['Acme Cloud', 'Pro Plan', 'Data Processing Addendum']
REPLY_SYSTEM = '''You are a support agent for Acme Cloud.
Write the reply in {language}. Match the register of the customer's message.
Rules:
- Use only facts contained in CONTEXT. Never invent policy, timelines, or amounts.
- Maximum 120 words, no markdown tables.
- Keep these terms exactly as written: {glossary}
- If CONTEXT is empty or does not answer the question, set escalate to true and leave reply empty.
Return JSON only: {{"reply": "...", "escalate": false, "reason": "short internal note"}}'''
def draft_reply(ticket: str, language: str, context: list, model: str) -> dict:
system = REPLY_SYSTEM.format(language=language, glossary=', '.join(GLOSSARY))
ctx = '\n\n'.join(context) if context else '(none)'
resp = client.chat.completions.create(
model=model,
messages=[
{'role': 'system', 'content': system},
{'role': 'user', 'content': 'CONTEXT:\n' + ctx + '\n\nCUSTOMER MESSAGE:\n' + ticket},
],
response_format={'type': 'json_object'},
temperature=0.3,
max_tokens=400,
)
return json.loads(resp.choices[0].message.content)
if __name__ == '__main__':
out = draft_reply(
ticket='¿Cómo exporto las facturas del último trimestre?',
language='es',
context=['Invoices live under Settings > Billing > Invoices. Quarterly exports download as CSV.'],
model='deepseek-v4-flash',
)
print(out)
Step 3 — Cache before you generate
Support traffic is heavily skewed toward repeats: password resets, invoice copies, where-is-my-order. An exact-match cache keyed on a normalized ticket, the locale, and the tier will absorb a surprising share of volume for a few dozen lines of code. Include the locale in the key so you never serve a Spanish refund answer to a German billing question, and include the tier so a pro-generated policy answer is not served to a flash request with different grounding.
Exact match only gets you the obvious duplicates. For near-duplicates, embed the normalized ticket and use a similarity threshold, but keep a human-reviewed golden answer as the cache value rather than a model generation, so cache hits are your highest-quality replies, not your stalest ones.
import hashlib
import re
import time
from collections import OrderedDict
CACHE_TTL_SECONDS = 60 * 60 * 24
_cache = OrderedDict() # key -> (expires_at, cached_reply)
def normalize(text: str) -> str:
text = text.lower().strip()
text = re.sub(r'\s+', ' ', text)
text = re.sub(r'[^\w\s]', '', text)
return text
def cache_key(ticket: str, language: str, tier: str) -> str:
raw = f'{language}|{tier}|{normalize(ticket)}'
return hashlib.sha256(raw.encode('utf-8')).hexdigest()
def cache_get(key: str):
hit = _cache.get(key)
if not hit:
return None
expires_at, value = hit
if time.time() > expires_at:
_cache.pop(key, None)
return None
_cache.move_to_end(key)
return value
def cache_set(key: str, value: str) -> None:
_cache[key] = (time.time() + CACHE_TTL_SECONDS, value)
_cache.move_to_end(key)
if len(_cache) > 5000:
_cache.popitem(last=False)
# usage
# key = cache_key(ticket, info['language'], model)
# cached = cache_get(key)
A tier map you can copy
Both tiers sit behind the same OpenAI-compatible endpoint, so moving a task between them is a one-line change. At AiCredits you pay by card or PayPal with no Chinese phone number or bank account required, and a single API key covers both models, which keeps the routing string in pick_model() as the only thing that decides your spend. Current rates are listed at aicreditsapi.com/deepseek-prices; in qualitative terms, pro costs more per token than flash, cache hits cost less than fresh generation, and off-peak traffic costs less than peak.
| Task | Model | Why this tier |
|---|---|---|
| Language + intent + risk routing | deepseek-v4-flash | Short structured output; the cheapest reliable step in the pipeline |
| FAQ answer with retrieved context | deepseek-v4-flash | Grounded in context, so it needs fluency more than reasoning |
| Multi-step refund or policy exceptions | deepseek-v4-pro | Must reconcile several rules and dates without drifting |
| High-risk or legal-adjacent replies | deepseek-v4-pro + human review | Errors are costly; model spend is trivial next to the exposure |
| Rewriting an agent draft into another language | deepseek-v4-flash | Translation and tone only; no new facts introduced |
Step 4 — Keep the cheap tiers honest with a regression set
Every time you move a task from pro to flash, you are making a claim about quality. Support that claim with evidence: roughly thirty labeled tickets per locale, each with facts the reply must contain and phrases it must never contain. Run the set on every prompt change and every tier change. This is not a benchmark; it is a smoke alarm, and it catches the failure mode that hurts most, which is a model quietly dropping a required detail like an order number or a cancellation window.
# Reuses draft_reply() from the section above.
CASES = [
{
'ticket': '¿Cómo cancelo mi suscripción?',
'language': 'es',
'context': ['Cancel under Settings > Billing > Cancel plan. Access continues until the paid period ends.'],
'must_include': ['cance'],
'must_not_include': ['http://'],
},
{
'ticket': 'Where is order 1234?',
'language': 'en',
'context': ['Order 1234 shipped on 3 May. The tracking link is in the confirmation email.'],
'must_include': ['1234'],
'must_not_include': ['refund'],
},
]
def run_eval(model, cases=CASES):
passed = 0
for case in cases:
out = draft_reply(case['ticket'], case['language'], case['context'], model)
reply = (out.get('reply') or '').lower()
ok = (
not out.get('escalate')
and all(s in reply for s in case['must_include'])
and not any(s in reply for s in case['must_not_include'])
)
passed += 1 if ok else 0
if not ok:
print('FAIL', case['ticket'][:40], '->', out)
return passed / len(cases)
if __name__ == '__main__':
for m in ('deepseek-v4-flash', 'deepseek-v4-pro'):
print(m, round(run_eval(m), 2))
Escalation, safety, and where cheap tiers stop
Escalate on four triggers: empty retrieval, high risk flag, the customer explicitly asking for a human, and two failed clarification rounds. Cheap models are fine at saying "I don't have that" when you give them permission.
Log model, locale, cache hit, escalation reason, and token counts per ticket. Without this you cannot tell whether your router is saving money or just moving spend around.
Strip personal data before it reaches logs or your cache. Normalize aggressively, but never store a cache key built from an email address or card fragment.
Stream the final answer. First-token latency shapes perceived speed far more than total generation time, and a router call plus a streamed reply feels faster than one slow non-streamed call.
Cost control in support is an architecture decision, not a model choice. Route first, ground second, cache third — then spend on the hard tickets.
FAQ
One short flash call is a real round trip. For most inboxes it is invisible next to human response times. If you need to cut it, apply cheap heuristics first (locale header, keyword lists) and call the router only when the heuristic is unsure. Always stream the final answer so the customer sees text early.
For a small inbox, yes — start with deepseek-v4-flash everywhere, log every ticket that was escalated or corrected by an agent, and move exactly those patterns to deepseek-v4-pro. Tiering should be earned by evidence rather than assumed up front.
Keep the source of truth in your strongest language. Retrieve in that language, then instruct the model to answer in the customer's language using only the retrieved facts. Modern models handle this cross-lingual step well, and it avoids maintaining five out-of-date doc sites.
It handles major languages well and copes with mixed-script tickets without pre-translation. Do not take that on faith: run the eval harness against your top five locales and measure factual accuracy and required-detail retention, not how fluent the output sounds.
Both tiers bill per token on the same key, so a pipeline that routes most tickets to flash costs far less than a single-tier pipeline that runs pro on everything. Pro costs more per token than flash, cache hits are cheaper than fresh generation, and off-peak usage costs less than peak. See aicreditsapi.com/deepseek-prices for current rates, and pay by card or PayPal with no Chinese phone number or bank account needed.