LlmEnumModels Function  
 
LONG WINAPI LlmEnumModels(
  HCLIENT hClient,  
  LPLLM_MODEL_INFO lpModelList,  
  LONG nMaxModels,  
  DWORD dwOptions  
);

The LlmEnumModels function returns a list of available models which match the provided options.

Parameters

hClient
A handle to the client session.
lpModelList
A pointer to an array of LLM_MODEL_INFO structures that will receive information about the models which match the specified options. This parameter may be NULL, in which case the function only returns the number of matching models.
nMaxModels
The maximum number of LLM_MODEL_INFO structures in the array specified by the lpModelList parameter. If lpModelList is NULL, this value should be zero.
dwOptions
An unsigned integer that specifies one or more options. This parameter is constructed by using a bitwise operator with any of the following values:
Value Description
LLM_MODEL_OPTION_DEFAULT Returns the default list of chat models for the connected provider.
LLM_MODEL_OPTION_PREVIEW Include preview or experimental models.
LLM_MODEL_OPTION_STREAMING Include models that support streaming responses.
LLM_MODEL_OPTION_STRUCTURED Include models that support structured output, such as JSON mode or schema-constrained responses.
LLM_MODEL_OPTION_REASONING Include models that support reasoning-oriented generation.
LLM_MODEL_OPTION_VISION Include models that support image input.
LLM_MODEL_OPTION_AUDIO Include models that support audio output, such as text-to-speech.
LLM_MODEL_OPTION_IMAGE Include models that support image generation.
LLM_MODEL_OPTION_VIDEO Include models that support video generation.
LLM_MODEL_OPTION_TRANSCRIPTION Include models that support audio transcription, such as speech-to-text.
LLM_MODEL_OPTION_DEPRECATED Include deprecated, retired, or legacy models that are not normally returned.
LLM_MODEL_OPTION_ALL_MODELS Include all known model types for the connected provider.

Return Value

If the function succeeds, the return value is the number of models which match the specified options. If the function fails, the return value is LLM_ERROR. To get extended error information, call LlmGetLastError.

Remarks

The LlmEnumModels function enumerates the models available for the provider associated with the client session. The client must have been successfully connected before calling this function. The returned list is based on the provider metadata available to the library and, when supported by the provider, information returned by the provider itself.

To determine how many models match the specified options, call this function with the lpModelList parameter set to NULL and the nMaxModels parameter set to zero. If the function succeeds, the return value is the number of matching models. You can then allocate an array of LLM_MODEL_INFO structures and call the function again to retrieve the model information.

Each LLM_MODEL_INFO structure should have its dwSize member initialized to the size of the structure before calling this function. This enables the library to validate the structure version and maintain compatibility with future releases.

The model list may be cached for a limited period of time to avoid unnecessary requests to the provider. Use LlmGetCacheTime and LlmSetCacheTime to determine or change the cache lifetime for the client session.

The model capabilities reported by this function are intended to help an application select an appropriate model. Providers may change their model availability, capabilities, or status over time, and the provider remains the final authority on whether a specific model can be used for a request.

Example

LONG nModels = LlmEnumModels(hClient, NULL, 0, LLM_MODEL_OPTION_DEFAULT);

if (nModels > 0)
{
    LPLLM_MODEL_INFO lpModelList;

    lpModelList = (LPLLM_MODEL_INFO)calloc(nModels, sizeof(LLM_MODEL_INFO));

    if (lpModelList != NULL)
    {
        for (LONG nIndex = 0; nIndex < nModels; nIndex++)
            lpModelList[nIndex].dwSize = sizeof(LLM_MODEL_INFO);

        nModels = LlmEnumModels(hClient, lpModelList, nModels, LLM_MODEL_OPTION_DEFAULT);

        if (nModels != LLM_ERROR)
        {
            for (LONG nIndex = 0; nIndex < nModels; nIndex++)
                _tprintf(_T("%s\n"), lpModelList[nIndex].szName);
        }

        free(lpModelList);
    }
}
else if (nModels == LLM_ERROR)
{
    DWORD dwError = LlmGetLastError();
    _tprintf(_T("Unable to enumerate models, error 0x%08lx\n"), dwError);
}

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

LlmGetCacheTime, LlmGetDefaultModelName, LlmGetModelInfo, LlmSetCacheTime, LlmValidateModel, LLM_MODEL_INFO