Skip to main content

Overview

ModelSettings is a configuration class from the agents library that controls LLM behavior including temperature, token limits, and other generation parameters. It’s used with the Agentor class to fine-tune model responses.

Import

Usage

Common Parameters

While ModelSettings is defined in the agents library, here are the commonly used parameters:
temperature
float
default:"1.0"
Controls randomness in outputs. Lower values (0.0-0.3) make outputs more focused and deterministic. Higher values (0.7-1.0) make outputs more creative and varied.
  • 0.0-0.3: Precise, consistent, factual responses
  • 0.4-0.6: Balanced creativity and consistency
  • 0.7-1.0: Creative, diverse, exploratory responses
max_tokens
int
default:"Model-dependent"
Maximum number of tokens to generate in the response. Limits the length of the model’s output.
top_p
float
default:"1.0"
Nucleus sampling parameter. Controls diversity by limiting cumulative probability. Alternative to temperature.
  • 0.1-0.5: More focused, deterministic
  • 0.9-1.0: More diverse outputs
presence_penalty
float
default:"0.0"
Penalizes tokens based on whether they appear in the text so far. Range: -2.0 to 2.0.
  • Positive values encourage new topics
  • Negative values encourage staying on topic
frequency_penalty
float
default:"0.0"
Penalizes tokens based on their frequency in the text. Range: -2.0 to 2.0.
  • Positive values reduce repetition
  • Negative values allow more repetition
stop
List[str]
default:"None"
Sequences where the model will stop generating. Maximum of 4 sequences.

Examples

Creative Writing

Precise Technical Responses

Concise Responses

Reducing Repetition

From Markdown File

You can also specify temperature in markdown frontmatter:

Parameter Selection Guide

By Use Case

Combining Parameters

Notes

  • ModelSettings is imported from the agents library but re-exported by agentor for convenience
  • If not provided, Agentor uses sensible defaults via get_default_model_settings()
  • Temperature and top_p are alternative sampling methods - typically you should adjust one or the other, not both
  • Different models may interpret these parameters differently
  • Some parameters may not be supported by all model providers
  • Agentor - Main agent class that uses ModelSettings
  • LLM - Lightweight LLM client
  • LitellmModel - Custom model wrapper
Last modified on May 5, 2026