LLM_RESPONSE  
 

The LLM_RESPONSE structure represents the response returned by a language model.

typedef struct _LLM_RESPONSE
{
    DWORD   dwSize;
    DWORD   dwRoleId;
    DWORD   dwFlags;
    DWORD   dwMessageId;
    DWORD   dwStatus;
    DWORD   dwElapsed;
    DWORD   dwReserved;
    TIME_T  tTimestamp;
    LONG    nOutputTokens;
    LONG    nContentLength;
    LPCTSTR lpszResponseId;
    LPCTSTR lpszModelName;
    LPCTSTR lpszStatusText;
    LPCTSTR lpszContent;
} LLM_RESPONSE, *LPLLM_RESPONSE;

Members

dwSize
The size of this structure, in bytes. This member must be set to sizeof(LLM_RESPONSE) before the structure is used.
dwRoleId
The role associated with the response. This member will typically be set to LLM_ROLE_ASSISTANT, but may vary depending on the type of response returned.
dwFlags
Response flags. This member is reserved for future use and should typically be set to LLM_RESPONSE_FLAG_NONE.
dwMessageId
The identifier of the originating request message. This value corresponds to the dwMessageId member of the LLM_MESSAGE structure that initiated the request.
dwStatus
The response status code. This member should be one of the LLM_RESPONSE values, indicating how the request completed.
dwElapsed
The elapsed time, in milliseconds, required to process the request and generate the response.
dwReserved
A reserved value for future use. This member should always be zero.
tTimestamp
A 64-bit integer timestamp associated by the response. This member specifies when the response was received and the value is represented as the number of seconds from January 1, 1970 UTC.
nOutputTokens
The number of tokens generated in the response. This value is provided when token usage information is available.
nContentLength
The length of the response content, in characters, not including the terminating null character.
lpszResponseId
A null-terminated string which specifies a provider-defined identifier for the response. This value may be NULL.
lpszModelName
A null-terminated string which specifies the name of the model used to generate the response. This value may be NULL.
lpszStatusText
A null-terminated string which specifies a provider-specific status or diagnostic message. This value may be NULL.
lpszContent
A null-terminated string which specifies the response text returned by the model.

Remarks

The LLM_RESPONSE structure represents the result of a request submitted to a language model. It is typically returned by functions such as LlmSendMessageEx and provides both the generated response content and additional metadata describing how the request was processed.

This structure is logically paired with the LLM_MESSAGE structure. While the LLM_MESSAGE structure defines the input provided to the model, the LLM_RESPONSE structure contains the output generated by the model along with status and diagnostic information. The dwMessageId member may be used to associate the response with the originating request message.

The lpszContent member points to a null-terminated string buffer which contains the response from the model. The nContentLength member specifies how many characters are in the response, not including the terminating null character. Line feed and carriage return characters are converted to the standard Windows CRLF end-of-line sequence, ensuring consistent formatting across different providers and applications. This also helps ensure compatibility with Windows common controls and other user interface components.

The ANSI version of this structure uses UTF-8 encoded strings, while the Unicode version uses UTF-16 encoded strings. Response text returned by a provider may contain Unicode characters, including international text, typographical symbols, emoji, mathematical symbols, or other non-ASCII characters. Applications should ensure that any user interface controls, files, or other components used to display or process response text are capable of handling Unicode text correctly.

Applications which cannot process Unicode text in the response can provide a system prompt requesting that the model limit its output to ASCII characters. However, because model output is non-deterministic, applications should not assume that non-ASCII characters will never be returned.

The dwStatus member indicates how the request completed. A value of LLM_RESPONSE_COMPLETE indicates that the response was generated normally, while other values may indicate that the response was truncated due to token limits, cancelled, timed out, or failed due to an error. Applications should always check this value before processing the response content.

The dwElapsed member provides the total time required to process the request, which can be useful for performance monitoring or diagnostics. The nOutputTokens member, when available, indicates the number of tokens generated by the model, which may be useful for usage tracking or cost estimation.

The tTimestamp member is a standard 64-bit Unix time value which indicates when the response was received from the service provider. It can be used interchangeably with functions in the C standard library such as gmtime or localtime. Because it is a 64-bit integer, it is not impacted by the Year 2038 problem. Timestamps can be converted into a local date and time using the LlmConvertTimestamp function.

The string members, such as lpszContent, lpszResponseId, lpszModelName, and lpszStatusText, are managed by the library. Applications should treat these pointers as read-only and must not attempt to modify the contents of the referenced strings. If an application needs to retain or modify this data, it should create its own copy.

Calling the LlmClearHistory or LlmResetSession functions will invalidate these string pointers. Applications must not reference these values after the session history has been cleared.

Unless otherwise documented, reserved members should be set to zero before calling a function which accepts this structure.

Requirements

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

See Also

LlmGetFirstMessage, LlmGetMessage, LlmGetMessageById, LlmGetNextMessage, LlmSendMessageEx, LLM_MESSAGE