We are going to build a working customer support agent that classifies user issues and drafts contextual replies. It runs against Oxlo.ai's API using the OpenAI SDK, so you can prototype locally and deploy without changing your integration code. By the end you will have a single Python file you can run from the terminal.
What you'll need
- Python 3.10 or newer
- The OpenAI SDK:
pip install openai - An Oxlo.ai API key from https://portal.oxlo.ai
Oxlo.ai uses request-based pricing, so iterating on prompts and agent loops does not balloon your bill as context grows. You can see the details at https://oxlo.ai/pricing.
Step 1: Configure the client
First, instantiate the OpenAI client pointing at Oxlo.ai. I will use Llama 3.3 70B because it follows instructions reliably and handles multi-turn conversations well.
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": "user", "content": "Hello, can you help me?"},
],
)
print(response.choices[0].message.content)
Step 2: Define the system prompt
The system prompt constrains the model to a specific role and output format. Keeping it in its own variable makes it easy to iterate without touching business logic.
SYSTEM_PROMPT = """You are a support agent for TaskFlow, a project management SaaS.
Your job is to classify the user's issue and draft a helpful response.
Rules:
- Always be polite and concise.
- Classify the issue as one of: Billing, Technical, Account.
- Include the classification at the start of your response in brackets, like [Billing].
- If you need more information, ask one specific follow-up question."""
Step 3: Build the agent class
Next, wrap the client in a small Python class that maintains conversation history. This lets the model reference earlier messages without manual bookkeeping.
class SupportAgent:
def __init__(self, client, model="llama-3.3-70b"):
self.client = client
self.model = model
self.history = [{"role": "system", "content": SYSTEM_PROMPT}]
def chat(self, user_message):
self.history.append({"role": "user", "content": user_message})
response = self.client.chat.completions.create(
model=self.model,
messages=self.history,
)
assistant_message = response.choices[0].message.content
self.history.append({"role": "assistant", "content": assistant_message})
return assistant_message
Step 4: Run the conversation
Now wire up a short script to simulate a customer thread. Each call appends to the history, so the agent remembers the invoice number from the first message when it sees the second.
if __name__ == "__main__":
agent = SupportAgent(client)
messages = [
"I was charged twice on April 14th. I need a refund.",
"The invoice number is 4922 and my account email is user@example.com.",
]
for msg in messages:
print(f"User: {msg}")
reply = agent.chat(msg)
print(f"Agent: {reply}\n")
Run it
Save the file as support_agent.py, replace YOUR_OXLO_API_KEY, and run python support_agent.py. You should see output similar to this:
User: I was charged twice on April 14th. I need a refund.
Agent: [Billing] I am sorry to hear about the duplicate charge. To help you, could you please provide your invoice number and the email address associated with your account?
User: The invoice number is 4922 and my account email is user@example.com.
Agent: [Billing] Thank you for the details. I have located invoice 4922 and initiated a refund to your original payment method. You should see the credit within 5 to 7 business days.
Next steps
Replace Llama 3.3 70B with Qwen 3 32B if you need multilingual support, or with Kimi K2.6 for longer document analysis. You could also add function calling by defining a lookup_invoice tool and passing it to Oxlo.ai's tools parameter, which is fully compatible with the OpenAI SDK format.
Top comments (0)