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

# getLLMTokenUsageForSession

## Syntax

`getLLMTokenUsageForSession()`

## Description

Retrieves the token usage information for the current session.

**Returns:** `TSessionUsageInformation | null` — the number of input and output tokens used, or `null` if the data is unavailable.

<Accordion title="TSessionUsageInformation object">
  ```js theme={null}
  type TSessionUsageInformation = {
      [key: string]: {
          llmDisplayName: string;
          providerType: string;
          modelType: string;
          usage: {
              inputTokens: number;
              outputTokens: number;
          }
      }
  };
  ```
</Accordion>

## Example

```js theme={null}
const usage = getLLMTokenUsageForSession();

if (usage) {
  Object.entries(usage).forEach(([key, info]) => {
    console.log(`Model: ${info.llmDisplayName}`);
    console.log(`Provider: ${info.providerType}`);
    console.log(`Type: ${info.modelType}`);
    console.log(`Input tokens: ${info.usage.inputTokens}`);
    console.log(`Output tokens: ${info.usage.outputTokens}`);
    console.log('---');
  });
} else {
  console.log('Token usage data not available for this session.');
}
```
