PRODUCTION USE CASE

LLM API for customer support chatbots

A SaaS customer asks why an invoice was charged twice. The support service retrieves the current billing policy and the customer's redacted invoice status, then asks the model either to answer from those sources or return an escalation object.

Support chatbot answering from approved policy content with human escalation
LLM API for customer support chatbots

Production recipe

API, primary model, and failover configuration

Production choiceRecommendationWhy
APIPOST /v1/chat/completionsOpenAI-compatible server-side request
Primary modelgpt-5.4-minigpt-5.4-mini is the default for low-latency, high-volume support turns with a narrow answer and escalation contract.
Fallback modelgemini-2.5-flashGemini 2.5 Flash is the tested economical fallback. Route complex policy conflicts or multi-tool account cases to Terra or a human.
Escalation modelgpt-5.6-terraUse only when the primary route fails the defined quality or complexity boundary
Output contractValidated JSONEither a grounded customer reply with internal source IDs, or a structured escalation reason.
01
Scenario

Customer support chatbots in a production application

A SaaS customer asks why an invoice was charged twice. The support service retrieves the current billing policy and the customer's redacted invoice status, then asks the model either to answer from those sources or return an escalation object.

The model cannot issue refunds or invent account state. If identity is unverified, sources conflict, or a billing tool fails, the conversation moves to a human with a summary and source IDs.

02
Architecture

How the customer support chatbots workflow operates

  • Classify the request and check identity requirements.
  • Retrieve approved policy and redacted account facts.
  • Generate an answer with internal source IDs or an escalation object.
  • Validate that every claim is supported.
  • Escalate before any consequential account action.
03
API request

Call gpt-5.4-mini through LLMFly AI

Send the request from your server. Replace the example content and placeholder tool schema with data and tools from your application.

request.exampleCopy-ready
curl https://app.llmfly.ai/v1/chat/completions \
  -H "Authorization: Bearer $LLMFLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [
      {"role": "system", "content": "Answer only from SOURCES and ACCOUNT_FACTS. If evidence is missing, identity is unverified, or an action requires permission, return ESCALATE with a concise reason."},
      {"role": "user", "content": "The customer says this invoice was charged twice. Explain the status or escalate."}
    ],
    "response_format": {"type": "json_object"}
  }'
04
Model choice

Why gpt-5.4-mini is the primary model

gpt-5.4-mini is the default for low-latency, high-volume support turns with a narrow answer and escalation contract.

Gemini 2.5 Flash is the tested economical fallback. Route complex policy conflicts or multi-tool account cases to Terra or a human.

05
Acceptance

Acceptance checks for customer support chatbots

MetricPass condition
Grounded-answer rateEvery policy or product claim is supported by an approved current source
Correct escalation rateMandatory escalation cases hand off before advice or account action
Time to first useful responseThe first response resolves the question or asks for the one missing detail
Cost per resolved conversationRetrieval, tools, retries, and handoff stay within the resolution budget
06
Failure handling

Failures to handle before deployment

  • Optimizing for containment at any cost
  • Letting the bot invent policy
  • Sending unnecessary sensitive data
  • Measuring single turns only
07
Output

Returned output and run records

Either a grounded customer reply with internal source IDs, or a structured escalation reason.

Record the model ID, request ID, token usage, retries, validation result, and final disposition for every production run.

Frequently asked questions

What makes a support answer trustworthy?

Ground it in approved, current support content and retain the source identifiers used.

When should the chatbot escalate?

Escalate when policy requires it, identity cannot be verified, confidence is low, or a tool fails.

How should cost be measured?

Measure the complete resolved conversation, including retrieval, tools, retries, and escalation.

Test this setup with your own inputs

Compare the primary and fallback models with the same requests, tools, and validation rules.

Compare models