The GetProviderId method can be called in two different ways.
If the method is called without any arguments, it will return the
provider ID associated with the current client session. This is
useful when an application supports multiple providers and needs
to adjust its behavior based on the active provider.
Another version of this method attempts to determine the provider ID
using the parameters passed to it in order of precedence. If a provider
name is specified and recognized, that value is considered authoritative
and the remaining parameters are ignored. If the provider name is not
recognized, the method will attempt to determine the provider from the
endpoint URL. If the provider cannot be determined from the endpoint URL,
the method will attempt to infer the provider from the model name.
The method performs normalization on the input values before matching
them against known providers. Leading and trailing whitespace is ignored,
provider names are matched without regard to case and common variations
of provider names are recognized.
When matching against a model name, the method identifies the company
or organization most commonly associated with the model family. This may
not reflect the actual service endpoint hosting the model. For example,
a model hosted by a local inference server or aggregate provider may
still be identified as the company who originally created the model.
This method only recognizes well-known providers, endpoint URLs and
model families. If the provider cannot be determined, the method will
return LLM_PROVIDER_UNKNOWN and the last error code will be
set to ST_ERROR_PROVIDER_NOT_FOUND.
DWORD dwProviderId = llmClient.GetProviderId();
if (dwProviderId != LLM_PROVIDER_UNKNOWN)
{
TCHAR szBaseUrl[128] = {0};
llmClient.GetProviderUrl(szBaseUrl, _countof(szBaseUrl));
_tprintf(_T("Provider ID: %lu\n"), dwProviderId);
_tprintf(_T("Base URL: %s\n"), szBaseUrl);
}
else
{
DWORD dwError = llmClient.GetLastError();
_tprintf(_T("Unable to get provider information, error 0x%08lx\n"), dwError);
}
LPCTSTR lpszUrl = _T("https://api.openai.com/v1/")
dwProviderId = llmClient.GetProviderId(NULL, lpszUrl, NULL);
if (dwProviderId != LLM_PROVIDER_UNKNOWN)
{
TCHAR szName[64] = {0};
llmClient.GetProviderName(dwProviderId, szName, _countof(szName));
_tprintf(_T("The provider for %s is %s\n"), lpszUrl, szName);
}
else
{
DWORD dwError = llmClient.GetLastError();
_tprintf(_T("Unable to get the provider ID, error 0x%08lx\n"), dwError);
}