> ## Documentation Index
> Fetch the complete documentation index at: https://docs.athina.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Log via TypeScript SDK

<Tabs>
  <Tab title="Non-Streaming">
    <Steps>
      <Step title="Install TypeScript SDK">
        ```
        npm install athina-logger
        ```
      </Step>

      <Step title="Set Athina API Key">
        ```typescript
        import { AthinaApiKey, InferenceLogger } from 'athina-logger';

        AthinaApiKey.setApiKey(process.env.ATHINA_API_KEY);
        ```
      </Step>

      <Step title="Log your inference">
        ```typescript 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);
          }
        }
        ```
      </Step>
    </Steps>

    <Tip>
      Tip: Include your logging code in a try/catch block to ensure that your
      application doesn't crash if the logging request fails.
    </Tip>
  </Tab>
</Tabs>

#### Logging Attributes

You can find the full list of [logging attributes here](/api-reference/logging/logging-attributes).
