Skip to content

Max Tokens Guard

Enforce a maximum token limit on LLM requests.

Enforce a maximum token limit on LLM requests.

This guard ensures that the max_tokens parameter sent to the LLM does not exceed the configured limit. If the parameter is absent, it adds the limit. If it’s present and exceeds the limit, it overwrites it.

  • max_tokens (int, optional): The maximum allowed tokens.
FieldTypeDefaultDescription
max_tokens`integernull`None
# Example 1
type: max_tokens
config:
max_tokens: 1000