Install TypeScript SDK
npm install athina-logger
Set Athina API Key
import { AthinaApiKey, InferenceLogger } from 'athina-logger';
AthinaApiKey.setApiKey(process.env.ATHINA_API_KEY);
Log your inference
try {
InferenceLogger.logInference({
promptSlug: "sdk_test",
prompt: messages,
languageModelId: "gpt-4-1106-preview",
response: response,
externalReferenceId: "abc",
cost: 0.0123,
customAttributes: {
name: "John Doe"
// Your custom attributes
}
})
} catch (err: any) {
if (err instanceof CustomException) {
console.log(err.statusCode);
console.log(err.message);
} else {
console.error(err);
}
}
Tip: Include your logging code in a try/catch block to ensure that your
application doesn’t crash if the logging request fails.