MaxTokens Property  
 

Sets or returns the maximum number of tokens that may be generated for a response.

Syntax

object.MaxTokens [= value ]

Remarks

The MaxTokens property specifies the maximum number of tokens the model may generate in response to a request. This value can be used to limit the length of responses returned by the model.

This property only affects generated output tokens and does not increase the total context window supported by the selected model. Increasing the value of this property cannot force a provider or model to accept larger prompts or additional conversation history beyond the model's supported limits.

Smaller values can reduce response length, improve response times and lower token usage costs. However, values that are too small may cause responses to be truncated or incomplete. If this property is set to zero, the provider or model default will be used. Some providers may also impose their own limits on the maximum number of output tokens that can be generated for a single request.

Data Type

Integer (Int32)

See Also

ContextSize Property, ContextUsed Property, InputTokens Property, OutputTokens Property, TotalTokens Property, EstimateTokens Method, SendMessage Method