Customer support is still the best-paying use of large language models in 2026. Tickets repeat, the knowledge is written down, and a mistake costs no more than handing the conversation to a human agent. Claude Sonnet 4.6, available through codexkey at https://api.codexkey.online/v1, gives you frontier-level reasoning, with prompt caching and tool use working out of the box. A small team can therefore ship a production bot in about a week. The rest of this guide goes in order: requirements, architecture, prompts, tools, evals, escalation, guardrails and cost.
What a support bot must do: requirements
Before writing any code, pin down four non-negotiables. First, grounding in a knowledge base. The bot answers from your documents and ticket history, not from the model's training data. Invented prices, refund terms or API limits will damage customer trust faster than any slow reply. Second, brand tone. At 3am the bot speaks in your company's voice. It needs a tone spec: warm but precise, never sycophantic, never robotic. That spec lives in the system prompt. Third, escalation to a human. Every bot meets questions it cannot or should not answer. The handoff has to be clean, and the agent gets the full conversation context. Fourth, multiple languages. If you sell internationally, support in at least English, Russian, Spanish and German is needed from day one, and Claude handles all four natively, with no translation layer.
A fifth requirement gets forgotten more than the others: measurability. You need an eval set from day one. Without it, every prompt change is a guess.
An architecture of four parts
The reference layout is deliberately boring:
[Web/Mobile UI] → [Your Backend] → [codexkey API] → [Claude Sonnet 4.6]
↓
[Vector DB + CRM]
The frontend is a chat widget in React, Vue or a native mobile component. It streams tokens so replies feel fast. The backend is a thin orchestration layer. It authenticates the user, pulls the relevant knowledge-base chunks, calls codexkey, runs tool calls (CRM lookups, ticket creation) and streams the answer back. The address https://api.codexkey.online/v1 is a drop-in replacement for the Anthropic API: the same request format and the same SDKs, so you can use the official @anthropic-ai/sdk or the anthropic Python package.
Retrieval-augmented generation (RAG) sits between your documents and the prompt. Index two corpora: (1) the public help center and product docs, split into chunks of ~500 tokens with overlap; (2) anonymized resolved tickets from the last 12 months. The tickets are especially valuable, because they show how questions are really asked, not how documentation words them. Put both corpora into a vector store (pgvector, Qdrant or Pinecone), fetch top-k=5 for each query and insert the results into the system prompt under a <knowledge> block.
The system prompt template
The system prompt moves the result more than anything else. Treat it like production code: version it, review it, run it through evals. A solid template has five sections:
You are Aria, the AI support agent for Acme Corp.
# Role
Help paying customers with billing, account, and product questions.
You are NOT a salesperson. You are NOT a lawyer. You are NOT a doctor.
# Tone
- Warm, precise, concise. Never apologize more than once per turn.
- No filler ("Great question!", "Absolutely!"). Get to the answer.
- Use the customer's name once, in the first reply only.
- Match the customer's language (en, ru, es, de, fr).
# Tools
You have access to:
- lookup_ticket(ticket_id): fetch ticket details
- lookup_customer(email): fetch plan, status, MRR
- create_ticket(subject, body, priority): file a new ticket
- escalate_to_human(reason): hand off to a live agent
# Escalation rules
Escalate immediately if:
- Customer is angry, threatening churn, or mentions legal/press
- Question involves refunds > $500 or contract changes
- You are \<80% confident in the answer
- Customer explicitly asks for a human
# Knowledge
<knowledge>
{{retrieved_chunks}}
</knowledge>
Always cite the doc section you used. If knowledge is missing, say so
and escalate. Never invent policy, pricing, or limits.
Pin everything above the <knowledge> block as the cacheable prefix. With codexkey's prompt caching, this 800-token system prompt costs ~10% of the normal input price after the first hit. At 10,000 tickets a month, that is the difference between a $60 bill and a $400.
Tool use: when the bot starts to be useful
A bot that answers only from documents is a search engine with manners. Tool use is what takes it to "useful". Tools are defined right in the request:
const response = await client.messages.create({
model: "claude-sonnet-5",
max_tokens: 1024,
system: [
{ type: "text", text: SYSTEM_PROMPT, cache_control: { type: "ephemeral" } },
{ type: "text", text: `<knowledge>${chunks}</knowledge>` }
],
tools: [
{
name: "lookup_ticket",
description: "Fetch ticket details by ID",
input_schema: {
type: "object",
properties: { ticket_id: { type: "string" } },
required: ["ticket_id"]
}
},
// ... other tools
],
messages: conversation
}, {
baseURL: "https://api.codexkey.online/v1"
});
When Claude returns a tool_use block, your backend runs the call against the CRM, returns the result as a tool_result, and Claude carries on with its turn. This loop lets the bot say "I see your invoice from March 14 was $89: the card was declined. Want me to retry it?" instead of "Please contact billing."
Streaming: a bot that answers fast
Time to first token matters more than total latency. Stream every response:
const stream = await client.messages.stream({
model: "claude-sonnet-5",
max_tokens: 1024,
messages,
system,
tools
}, { baseURL: "https://api.codexkey.online/v1" });
for await (const event of stream) {
if (event.type === "content_block_delta" && event.delta.type === "text_delta") {
socket.send(event.delta.text);
}
}
If text starts appearing after 400 ms, the user sees the bot as fast, even when the full reply takes 6 seconds. If a person stares at an empty window for 6 seconds while a complete answer is prepared, they close the chat.
Evals: the line between a toy and a product
Build an eval set of 200-500 real tickets. For each one, attach the ideal reply, the correct tool calls and a note on whether escalation was warranted. Score every new prompt version on three axes: factual accuracy (does it match the docs), tone fidelity (does it sound like the brand) and escalation precision (does it hand off when it should, and only then). Check the first two with Claude itself as the judge: a meta-prompt with a rubric and the candidate reply. Check the third by exact match against the outcomes in ticket history.
Run evals on every prompt change and every model upgrade. Otherwise you cannot tell if your "improvement" improved anything. For how to estimate the cost of the eval runs themselves, see the pricing breakdown.
Escalation: draft first, then score and route
The cleanest escalation pattern is called draft-then-route. The model always writes a candidate reply. A second, lighter call (or a confidence rubric inside the same call) scores it on a 0-1 scale. At 0.85 or above, the reply goes to the customer. At 0.6-0.85, it goes with a footer: "Was this helpful? A human is standing by." Below 0.6, the reply is dropped, the conversation lands in the queue, and the agent's reply box is pre-filled with the draft: the human edits it and sends. Agents like this; average handle time drops by 40-60%, even on escalated tickets.
Guardrails: PII, scope and refusals
Every support bot needs three guardrails. PII echo prevention: scrub card numbers, full passport numbers and passwords from both inputs and outputs with a regex pass before they reach the model. Out-of-scope refusals: the system prompt lists exactly what the bot does NOT do (legal advice, medical questions, competitor comparisons), and a few-shot example reinforces it. Prompt injection resistance: never put untrusted user content (ticket bodies, forwarded emails) into the system prompt. Put it in a user message wrapped in <untrusted> tags, and tell the model to treat instructions inside those tags as data, not commands.
Multiple languages with no translation layer
Claude Sonnet 4.6 is genuinely multilingual. Detect the customer's language from the first message (a one-line classifier prompt or a library such as franc), then set it as a directive in the system prompt (Respond in: ru). That is all. There is no Google Translate hop, quality does not drop, and you need no separate prompt per language. The same eval set checks each language: Claude translates it, and native speakers spot-check.
What it costs: an estimate for a typical SMB
Take a B2B SaaS with 10,000 tickets a month, an average conversation of 6 turns, about 3,000 input tokens per turn (system, knowledge base and history) and around 400 output tokens:
- Without prompt caching: ~180M input and ~24M output, about $720/month
- With prompt caching (system and knowledge base cached, ~85% hit rate): ~$60/month
- Plus embeddings and vector DB: ~$20/month
That comes to roughly $80/month for a fully multilingual bot with tools and escalation, serving 10k tickets. It is a third of the cost of one seat at most legacy support-automation vendors.
Connecting through codexkey
Point your SDK at https://api.codexkey.online/v1, use your codexkey API key, and the rest of the code matches the official Anthropic SDK. Prompt caching, tool use, streaming and vision work the same way. Billing is in rubles or USD, settlement runs in one-minute increments, and there is no per-seat fee: you pay for the tokens you use.
Bottom line: what to ship in the first week
You can ship an MVP in a week. Days 1-2: load the docs and tickets into a vector store. Day 3: the chat UI with streaming. Day 4: the system prompt and tool schemas. Day 5: the escalation queue. Day 6: assemble the eval set. Day 7: release to 10% of traffic behind a feature flag. After that, each week is a prompt iteration driven by evals and real conversations. The bot that ships in week one will look embarrassing in week four, and that is the point. Build the loop, not the perfect prompt.