LLM_MESSAGE  
 

The LLM_MESSAGE structure represents a message sent from the client to the LLM server.

typedef struct _LLM_MESSAGE
{
    DWORD   dwSize;
    DWORD   dwRoleId;
    DWORD   dwFlags;
    DWORD   dwReasoningLevel;
    DWORD   dwMessageId;
    DWORD   dwReserved;
    TIME_T  tTimestamp;
    LONG    nMaxTokens;
    LONG    nInputTokens;
    LONG    nContentLength;
    LPCTSTR lpszContent;
} LLM_MESSAGE, *LPLLM_MESSAGE;

Members

dwSize
The size of this structure, in bytes. This member must be set to sizeof(LLM_MESSAGE) before the structure is used.
dwRoleId
The role associated with the message, such as user, assistant or system. This member should be one of the following values:
Constant Description
LLM_ROLE_UNKNOWN Unknown or invalid role. This value is typically used when a message has not been initialized correctly or could not be classified.
LLM_ROLE_USER A message originating from the end-user. This is the most common role and represents input provided by the application or user interface.
LLM_ROLE_ASSISTANT A response generated by the language model. Messages with this role are typically returned by the library as part of the conversation history.
LLM_ROLE_SYSTEM A system-level instruction that defines how the model should behave. This is typically used to set context, tone, or constraints for the session before user messages are processed.
LLM_ROLE_FUNCTION A legacy role used for function call messages in older APIs. This role is retained for compatibility but is generally not used in new implementations.
LLM_ROLE_TOOL A message generated by an external tool or function invoked by the model. This role is used when integrating tool or function-calling workflows.
LLM_ROLE_TOOLUSER A user message that is specifically intended for processing by a tool or function, rather than direct model interpretation.
LLM_ROLE_DEFAULT The default role assigned to messages. This is equivalent to LLM_ROLE_USER.
dwFlags
A value reserved for future use. This member should always be set to zero or LLM_MESSAGE_FLAG_NONE.
dwReasoningLevel
The reasoning effort level associated with the message. This member may be set to one of the LLM_REASONING constants to control how much reasoning the model should apply when generating a response. A value of LLM_REASONING_DEFAULT uses the provider or model default behavior.
dwMessageId
An identifier assigned to the message. For application-supplied input messages, this value is initially zero. When a message has been added to a session or returned from the message history, this member may contain a unique identifier assigned by the library.
dwReserved
A reserved value for future use. This member should always be zero.
tTimestamp
The timestamp associated with the message. For application-supplied input messages, this value is typically zero. When available, this member contains the time the message was created.
nMaxTokens
The maximum number of output tokens associated with the message. This value is primarily used when submitting a request and may be zero to indicate the session or provider default should be used.
nInputTokens
The number of input tokens associated with the message content. This value is typically provided by the library when token usage information is available.
nContentLength
The length of the message content, in characters, not including the terminating null character. If this value is zero, the content length may be determined from the string.
lpszContent
A pointer to a null-terminated string which contains the message text. This member may be NULL if the message consists only of media content.

Remarks

This structure is used to describe a single message in a conversation with a language model. Messages are typically assigned a role using one of the constants, such as LLM_ROLE_USER for user input, LLM_ROLE_ASSISTANT for a model response, or LLM_ROLE_SYSTEM for an instruction message that defines the behavior of the session. In most applications, those roles are required. Other roles are used for advanced scenarios such as tool integration or legacy compatibility.

The LLM_MESSAGE structure is used for both input and output operations. When passed to functions such as LlmSendMessageEx, it defines a message that will be submitted to the language model. In this case, the application typically initializes only the required members, such as dwSize, dwRoleId, and the content or media fields. When used with functions such as LlmGetFirstMessage and LlmGetNextMessage, this structure is populated by the library to return messages from the current session history. In this case, additional members such as the message identifier, timestamp, and token counts may contain values assigned by the library. Applications should treat values returned by the library as read-only unless otherwise documented.

The lpszContent member specifies the text associated with the message. For the ANSI version of this structure, this string must be UTF-8 encoded. In the Unicode version, the string is specified as UTF-16 using a wide character pointer.

The nContentLength member specifies the content length in characters rather than bytes. If this value is zero, the library may determine the length from the null-terminated string. Applications should not assume that token counts are identical to character counts. The nInputTokens member, when available, reflects the tokenized size of the message content as determined by the model or provider.

The dwReasoningLevel member controls the reasoning effort requested for the message. Higher reasoning levels may improve the quality, accuracy, or depth of responses, particularly when using reasoning-capable models, but they can also increase response time and token usage costs. Lower reasoning levels generally favor faster responses and reduced usage costs. Not all providers or models support configurable reasoning levels, and unsupported values may be ignored by the provider. If this member is set to LLM_REASONING_DEFAULT, the library will use the default reasoning behavior for the current provider or model.

The tTimestamp member is a standard 64-bit Unix time value and 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.

Unless otherwise noted, any reserved members should be set to zero before calling a function which accepts this structure. Applications should also avoid modifying structure members that are returned by the library unless the documentation for a specific function indicates that doing so is supported.

The lpszContent member of this structure is managed by the library. Applications should treat this value as read-only and must not attempt to modify the contents of the string. If the application needs to retain or modify this data, it should create its own copy.

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

LlmSendMessageEx LlmGetMessage, LlmGetMessageById, LlmGetFirstMessage, LlmGetNextMessage, LLM_RESPONSE