We're building a support ticket response generator that reads a customer's issue and drafts a contextual reply. It helps support teams cut first-response time without sounding robotic. We'll wire it to Oxlo.ai's Llama 3.3 70B via the OpenAI-compatible endpoint.
What you'll need
You need Python 3.10 or newer, the OpenAI SDK, and an API key from Oxlo.ai. Grab your key at https://portal.oxlo.ai and install the client.
pip install openai
Step 1: Scaffold the client
First, I'll confirm the environment is wired correctly by sending a smoke-test request. I use the OpenAI SDK pointed at Oxlo.ai's base URL so the rest of the code stays portable.
from openai import OpenAI
client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Reply with 'OK' and nothing else."},
],
)
print(response.choices[0].message.content)
Step 2: Write the system prompt
The system prompt locks in the persona, formatting rules, and escalation policy. Keeping it in a constant makes it easy to iterate without touching business logic.
SYSTEM_PROMPT = """You are a Tier-1 support engineer for a SaaS platform.
Your job is to draft a first reply to the customer ticket below.
Rules:
- Acknowledge the specific issue in one sentence.
- Offer the most likely fix or next troubleshooting step.
- If the issue requires engineering access or account changes, set requires_escalation to true.
- Output valid JSON with keys: subject, body, requires_escalation.
- Keep the body under 150 words."""
Step 3: Generate a single response
Now I'll wrap the API call in a function that accepts a raw ticket string and returns parsed JSON. I set temperature low so the output stays factual and consistent.
import json
def draft_reply(ticket_text: str) -> dict:
user_message = f"Customer ticket:\n{ticket_text}"
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_message},
],
temperature=0.2,
response_format={"type": "json_object"},
)
raw = response.choices[0].message.content
return json.loads(raw)
# Quick test
ticket = "I keep getting a 502 Bad Gateway when I hit the /export endpoint after 10am UTC."
print(draft_reply(ticket))
Step 4: Process a batch of tickets
Support queues never arrive one at a time, so I'll add a small loop that runs tickets sequentially and collects results. Because Oxlo.ai charges a flat rate per request, not per token, long ticket threads do not inflate the cost the way they would on token-based providers.
tickets = [
"I keep getting a 502 Bad Gateway when I hit the /export endpoint after 10am UTC.",
"Can you reset my 2FA? I lost my phone and I am locked out of the dashboard.",
"The webhook payload stopped including the 'created_at' field sometime yesterday.",
]
results = []
for t in tickets:
try:
results.append({"ticket": t, "draft": draft_reply(t)})
except Exception as e:
results.append({"ticket": t, "error": str(e)})
print(json.dumps(results, indent=2))
Run it
Save the full script as support_drafter.py, export your key, and run it.
export OXLO_API_KEY="sk-oxlo.ai-..."
python support_drafter.py
Example output:
{
"subject": "Re: 502 Bad Gateway on /export endpoint",
"body": "Thanks for reporting this. A 502 after 10am UTC usually points to the export worker hitting its memory limit during peak load. Please try adding a ?limit=100 parameter to paginate the request, and let me know if the error persists.",
"requires_escalation": false
}
Wrap-up
From here, you could wire the drafter into a webhook listener so it fires on every new Zendesk or Intercom ticket. You could also swap in deepseek-v3.2 or kimi-k2.6 on Oxlo.ai if you want stronger reasoning for complex troubleshooting workflows. Check out the request-based pricing at https://oxlo.ai/pricing to see how batching long-context tickets stays predictable.
Top comments (0)