User Analytics
Attach a user ID to your requests to get detailed analytics about your users.
Just swap out https://api.openai.com
for https://api.openai.withlogging.com
and add X-User-Id
header to your requests.
import { Configuration, OpenAIApi } from "openai";
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
basePath: "https://api.openai.withlogging.com/v1",
baseOptions: {
headers: {
"X-Api-Key": `Bearer ${process.env.LLM_REPORT_API_KEY}`,
"X-User-Id": `[email protected]`,
},
},
});
const openai = new OpenAIApi(configuration);
const completion = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Hello world" },
],
});