LlmGetProviderId Function  
 
DWORD WINAPI LlmGetProviderId(
  LPCTSTR lpszProviderName,  
  LPCTSTR lpszBaseUrl,  
  LPCTSTR lpszModelName  
);

The LlmGetProviderId function returns a provider ID based on a provider name, endpoint URL or model name.

Parameters

lpszProviderName
A null-terminated string which specifies the name of the provider. This parameter may be NULL if you do not wish to match against a provider name. At least one parameter must be specified. If a provider name is specified, it is given precedence over the other parameters.
lpszBaseUrl
A null-terminated string which specifies an endpoint URL. This parameter may be NULL if you do not wish to match against an endpoint URL. At least one parameter must be specified. An endpoint URL will only be used if the function is unable to determine the provider ID from the lpszProviderName parameter. If an endpoint URL is specified, it is given precedence over a model name.
lpszModelName
A null-terminated string which specifies a model name. This parameter may be NULL if you do not wish to match against a model name. At least one parameter must be specified. A model name will only be used if the function is unable to determine the provider ID from the lpszProviderName or lpszBaseUrl parameters.

Return Value

If the function succeeds, the return value is the numeric provider ID. If the function fails, it returns LLM_PROVIDER_UNKNOWN. To get extended error information, call LlmGetLastError.

Remarks

The LlmGetProviderId function attempts to determine the provider ID using the parameters 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 function will attempt to determine the provider from the endpoint URL. If the provider cannot be determined from the endpoint URL, the function will attempt to infer the provider from the model name.

The function 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 function 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 function only recognizes well-known providers, endpoint URLs and model families. If the provider cannot be determined, the function will return LLM_PROVIDER_UNKNOWN and the last error code will be set to ST_ERROR_PROVIDER_NOT_FOUND.

The LlmGetClientProvider function can be used to return the provider ID associated with a specific client session.

Example

DWORD dwProviderId;

// Determine the provider based on a model name
dwProviderId = LlmGetProviderId(NULL, NULL, 
                                _T("claude-sonnet-4"));

if (dwProviderId == LLM_PROVIDER_ANTHROPIC)
    _tprintf(_T("Anthropic provider selected\n"));

// Determine the provider using an endpoint URL
dwProviderId = LlmGetProviderId(NULL,
                                _T("https://api.openai.com/v1/"),
                                NULL);

if (dwProviderId == LLM_PROVIDER_OPENAI)
    _tprintf(_T("OpenAI provider selected\n"));

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

LlmGetClientProvider, LlmGetDefaultModelName, LlmEnumProviders, LlmGetProviderFlags, LlmGetProviderName, LlmValidateModel