1

Install TypeScript SDK

npm install athina-logger
2

Set Athina API Key

import { AthinaApiKey, InferenceLogger } from 'athina-logger';

AthinaApiKey.setApiKey(process.env.ATHINA_API_KEY);
3

Log your inference

inference.ts
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.

Logging Attributes

You can find the full list of logging attributes here.