Real World Example

Two Models in One Support Flow

Helpdesk products like Freshworks Freddy AI and Zoho Zia use different models for different steps. A cheap model reads every incoming ticket; a stronger model only drafts replies for tickets that need one. For ShopEase:

import anthropic

client = anthropic.Anthropic()

def handle(ticket: str) -> str:
    tag = client.messages.create(
        model="claude-haiku-5-5",
        max_tokens=10,
        system="Reply with one word: SPAM, SIMPLE, or COMPLEX.",
        messages=[{"role": "user", "content": ticket}],
    ).content[0].text.strip()

    if tag == "SPAM":
        return "(ignored)"
    model = "claude-sonnet-5-5" if tag == "SIMPLE" else "claude-opus-5-5"
    reply = client.messages.create(
        model=model,
        max_tokens=500,
        system="You are ShopEase support. Draft a short, polite reply for a human agent to review.",
        messages=[{"role": "user", "content": ticket}],
    )
    return f"[{tag} -> {model}] " + reply.content[0].text

print(handle("Do you deliver to Pune?"))

Run it

python route.py

Example output

[SIMPLE -> claude-sonnet-5-5] Yes, ShopEase delivers to Pune! Most orders arrive within 3-5 business days. You can check delivery for your exact pincode on the product page.

Exercise

Exercise: The Haiku call above might return "Simple." instead of SIMPLE. Make the code robust.

Show answer
raw = response.content[0].text
tag = raw.strip().strip(".").upper()
if tag not in {"SPAM", "SIMPLE", "COMPLEX"}:
    tag = "COMPLEX"        # safe default: send unknowns to the stronger model