GetNextModel Method  
 

The GetNextModel method retrieves information about the next available model for the current service provider.

Syntax

object.GetNextModel( ModelName, [MaxTokens], [ContextSize], [Flags] )

Parameters

ModelName
A String passed by reference which will contain the name of the first model when the method returns. This parameter cannot be omitted.
MaxTokens
An optional Integer passed by reference. When the method returns, this parameter will contain the maximum number of output tokens that can be generated by the model for a single response.
ContextSize
An optional Integer passed by reference. When the method returns, this parameter will contain the context size supported by the model. This is the maximum number of tokens the model can process in a single request.
Flags
An optional Integer passed by reference. When the method returns, this parameter will specify one or more bitflags that describe the capabilities of the model. If an error occurs, this value will be zero. If this information is not required, the parameter may be omitted.
Constant Value Description
llmModelFlagNone &H0000 No model capabilities defined
llmModelFlagChat &H0001 Supports conversational text generation
llmModelFlagSystemRole &H0002 Accepts a system role message in the input
llmModelFlagStreaming &H0004 Supports streaming responses
llmModelFlagStructured &H0008 Supports structured output (e.g., JSON or schema)
llmModelFlagVision &H0010 Supports image inputs (multimodal)
llmModelFlagTools &H0020 Supports tool or function calling
llmModelFlagReasoning &H0040 Supports reasoning-oriented generation
llmModelFlagResponses &H0080 Supports the Responses API (unified endpoint)
llmModelFlagFunctions &H0100 Supports OpenAI-style function calling with schemas
llmModelFlagAudio &H0200 Supports audio output (text-to-speech)
llmModelFlagImage &H0400 Supports image generation
llmModelFlagVideo &H0800 Supports video generation
llmModelFlagTranscription &H1000 Supports speech-to-text transcription
llmModelFlagInstructions &H2000 Supports a dedicated instruction field outside message lists
llmModelFlagMaxCompletionTokens &H4000 Uses max_completion_tokens instead of max_tokens in requests
llmModelFlagInferred &H80000 Capabilities are inferred rather than explicitly defined

Return Value

A value of True is returned if the method succeeds. If the method fails, it will return False and the LastError property will contain the error code.

Remarks

The GetNextModel method continues enumeration of the models available for the provider associated with the client session. The GetFirstModel method must be called to begin the enumeration prior to calling this method. The values are based on metadata and information returned by the provider in response to a request for a list of supported inference models.

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

The model capabilities reported by this method are intended to help an application select an appropriate model. Providers may change their model availability, capabilities, or status over time.

The presence of a model in the provider's model list does not guarantee that it can be used by the current client. Access to specific models may depend on the provider account, subscription level, region, deployment configuration, or other provider-specific requirements. Applications should use ValidateModel before selecting a model, particularly if the model name was chosen by the user or restored from a saved configuration.

The MaxTokens value returned by this method represents the maximum output token limit reported for the model. This limit only applies to generated content and may be lower than the model's total context window. The client can further restrict the length of generated responses by setting the MaxTokens property to a smaller value. Setting the property does not increase the model's limit; it only places an additional limit on responses generated by the model.

The ContextSize value represents the maximum number of tokens the model can process in a single request, including the system prompt, conversation history, user messages, and generated output. Most cloud-based service providers offer models which support very large context sizes, while limiting the maximum number of tokens that can be generated in a single response.

Example

Dim strModel As String
Dim nMaxTokens As Long
Dim nContextSize As Long
Dim nFlags As Long

If LlmClient1.GetFirstModel(strModel, nMaxTokens, nContextSize, nFlags) Then
    Do
        Debug.Print "Model: " & strModel
        Debug.Print "Max Tokens: " & CStr(nMaxTokens)
        Debug.Print "Context Size: " & CStr(nContextSize)

        If (nFlags And llmModelFlagReasoning) <> 0 Then
            Debug.Print "Supports reasoning"
        End If

        Debug.Print ""

    Loop While LlmClient1.GetNextModel(strModel, nMaxTokens, nContextSize, nFlags)
Else
    MsgBox "Unable to retrieve model list. Error " & _
           CStr(LlmClient1.LastError), vbExclamation
End If

See Also

CacheTime Property, ContextSize Property, DefaultModel Property, MaxTokens Property, GetFirstModel Method, ValidateModel Method