We are going to build a few-shot support ticket priority classifier that learns from five examples instead of a fine-tuning pipeline. This pattern is useful when you need custom classification logic but do not have a labeled dataset or GPU budget. I will walk through the complete script, from formatting examples to sending requests through Oxlo.ai.
What you'll need
You will need Python 3.10 or newer, the OpenAI SDK, and an Oxlo.ai API key.
pip install openai
Create your API key at https://portal.oxlo.ai.
Step 1: Write the system prompt
I started by writing a strict system prompt that defines the labels and output format. This prevents the model from adding conversational filler so the response is easy to parse.
SYSTEM_PROMPT = """You are a support ticket classifier. Given a ticket title and body, assign exactly one priority: Critical, High, or Low.
Rules:
- Critical: production outage, security breach, or data loss.
- High: major feature broken, or significant performance degradation.
- Low: general questions, feature requests, or cosmetic issues.
Respond with only the priority label, no explanation."""
Step 2: Collect few-shot examples
Next I gathered five representative ticket pairs. These prime the model to map language patterns to our taxonomy without any gradient updates.
FEW_SHOT_EXAMPLES = [
{"role": "user", "content": "Title: Database connection timeout\nBody: All users seeing 504 errors since 09:00 UTC."},
{"role": "assistant", "content": "Critical"},
{"role": "user", "content": "Title: Export CSV button not working\nBody: The export button on the reports page returns an empty file."},
{"role": "assistant", "content": "High"},
{"role": "user", "content": "Title: Dark mode request\nBody: Can we get a dark theme for the dashboard?"},
{"role": "assistant", "content": "Low"},
]
Step 3: Initialize the Oxlo.ai client
I use the OpenAI SDK pointed at Oxlo.ai so the code stays portable if I swap models later. Because Oxlo.ai charges per request rather than per token, adding long few-shot examples does not inflate the cost.
from openai import OpenAI
client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")
Step 4: Build the classifier function
The function assembles the message list by sandwiching the few-shot examples between the system prompt and the unseen ticket. I use Llama 3.3 70B because it follows formatting instructions reliably, but you can swap in Qwen 3 32B or DeepSeek V3.2 without changing any logic.
def classify_ticket(title: str, body: str) -> str:
user_message = f"Title: {title}\nBody: {body}"
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
]
messages.extend(FEW_SHOT_EXAMPLES)
messages.append({"role": "user", "content": user_message})
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=messages,
)
return response.choices[0].message.content.strip()
Step 5: Test against unseen tickets
I keep a short list of new tickets to evaluate. Reusing the same few-shot prefix for every call is where Oxlo.ai's flat request pricing shines: the prompt can grow with detailed examples, yet the cost stays predictable.
TEST_TICKETS = [
{"title": "Payment gateway returning 500s", "body": "Customers cannot complete checkout. Error rate is 100% since 14:00."},
{"title": "Typo in footer copyright", "body": "The footer says 2023 instead of 2025."},
{"title": "API latency spike", "body": "P95 latency jumped from 120ms to 4s on the search endpoint."},
]
for ticket in TEST_TICKETS:
label = classify_ticket(ticket["title"], ticket["body"])
print(f"{ticket['title']}: {label}")
Run it
Save the script as classify.py, set your API key, and run the file.
export OXLO_API_KEY="sk-oxlo.ai-..."
python classify.py
When I ran this against Llama 3.3 70B on Oxlo.ai, the output matched the expected labels:
Payment gateway returning 500s: Critical
Typo in footer copyright: Low
API latency spike: High
Next steps
Swap the model to kimi-k2.6 or deepseek-v3.2 to see if a reasoning-focused model handles ambiguous tickets more accurately. You can also move the examples into a JSON file and load them at runtime so product managers can tune the taxonomy without touching code.
Top comments (0)