import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.ORQ_API_KEY,
baseURL: "https://api.orq.ai/v3/router",
});
// Initialize conversation
const userId = "user-123";
const sessionId = crypto.randomUUID();
const threadId = `user-${userId}-${sessionId}`;
const response = await client.chat.completions.create({
model: "openai/gpt-4o",
messages: [{ role: "user", content: "How do I reset my password?" }],
orq: {
thread: {
id: threadId,
tags: ["support", "password-reset", `user-${userId}`],
},
},
});
// Continue conversation
const followUp = await client.chat.completions.create({
model: "openai/gpt-4o",
messages: [
{ role: "user", content: "How do I reset my password?" },
{ role: "assistant", content: response.choices[0].message.content },
{ role: "user", content: "I didn't receive the reset email" },
],
orq: {
thread: {
id: threadId, // Same thread ID
tags: ["support", "email-issue", `user-${userId}`],
},
},
});