The EnumProviders method returns information about the LLM
service providers supported by the library. This includes the provider
identifier, provider name, host name, default model name, protocol, port
number, and capability flags.
To determine how many providers are available, call this method with the
lpProviderList parameter set to NULL and the nMaxProviders
parameter set to zero. If the method succeeds, the return value is the
number of providers. You can then allocate an array of LLM_PROVIDER_INFO
structures and call the method again to retrieve the provider information.
Each LLM_PROVIDER_INFO structure should have its dwSize member initialized
to the size of the structure before calling this method. This enables the
library to validate the structure version and maintain compatibility with
future releases.
The list returned by this method only identifies providers that are known
to the library. It does not verify that the provider is currently reachable,
that an account is active, or that a valid API key has been configured.
LONG nProviders = llmClient.EnumProviders();
if (nProviders > 0)
{
LPLLM_PROVIDER_INFO lpProviderList;
lpProviderList = (LPLLM_PROVIDER_INFO)calloc(nProviders, sizeof(LLM_PROVIDER_INFO));
if (lpProviderList != NULL)
{
for (LONG nIndex = 0; nIndex < nProviders; nIndex++)
lpProviderList[nIndex].dwSize = sizeof(LLM_PROVIDER_INFO);
nProviders = llmClient.EnumProviders(lpProviderList, nProviders);
if (nProviders != LLM_ERROR)
{
for (LONG nIndex = 0; nIndex < nProviders; nIndex++)
_tprintf(_T("%s\n"), lpProviderList[nIndex].szDisplayName);
}
free(lpProviderList);
}
}
else if (nProviders == LLM_ERROR)
{
DWORD dwError = LlmGetLastError();
_tprintf(_T("Unable to enumerate providers, error 0x%08lx\n"), dwError);
}