LlmGetTokenUsage Function  
 
BOOL WINAPI LlmGetTokenUsage(
  HCLIENT hClient,  
  LPLLM_TOKEN_USAGE lpUsage  
);

The LlmGetTokenUsage function returns token usage statistics for the client session.

Parameters

hClient
A handle to the client session.
lpUsage
A pointer to an LLM_TOKEN_USAGE structure which receives token usage statistics for the client session. The dwSize member must be initialized to the size of the structure before calling this function.

Return Value

If the function succeeds, the return value is non-zero. If the function fails, the return value is zero. To get extended error information, call LlmGetLastError.

Remarks

The LlmGetTokenUsage function returns token usage statistics for the specified client session. This information includes token counts reported by the provider, as well as values maintained by the library for the current conversation history.

The lpUsage parameter must point to an LLM_TOKEN_USAGE structure initialized by the caller. The dwSize member must be set to the size of the structure. This enables the function to validate the structure version before returning usage information.

Token usage values are intended to help applications monitor request size, response size and context usage. The exact values reported may vary by provider and model, and should be treated as informational rather than as a guarantee of billing or model behavior.

This function returns the usage information currently associated with the client session. The values are updated as messages are sent and responses are received.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csllmv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also

LlmClearHistory, LlmGetHistorySize, LlmResetSession, LlmSendMessage, LLM_TOKEN_USAGE