LLMConfig - AG2
LLMConfig
autogen.LLMConfig
LLMConfig(*configs, top_p=None, temperature=None, max_tokens=None, check_every_ms=None, allow_format_str_template=None, response_format=None, timeout=None, seed=None, cache_seed=None, parallel_tool_calls=None, tools=(), functions=(), routing_method=None)
Initializes the LLMConfig object.
| PARAMETER | DESCRIPTION |
|---|---|
*configs |
A list of LLM configuration entries or dictionaries. TYPE: ConfigItemDEFAULT:() |
temperature |
The sampling temperature for LLM generation. TYPE:`float |
check_every_ms |
The interval (in milliseconds) to check for updates TYPE:`int |
allow_format_str_template |
Whether to allow format string templates. TYPE:`bool |
response_format |
The format of the response (e.g., JSON, text). TYPE:`str |
timeout |
The timeout for LLM requests in seconds. TYPE:`int |
seed |
The random seed for reproducible results. TYPE:`int |
cache_seed |
The seed for caching LLM responses. TYPE:`int |
parallel_tool_calls |
Whether to enable parallel tool calls. TYPE:`bool |
tools |
A list of tools available for the LLM. TYPE: Iterable[Any]DEFAULT:() |
functions |
A list of functions available for the LLM. TYPE: Iterable[Any]DEFAULT:() |
max_tokens |
The maximum number of tokens to generate. TYPE:`int |
top_p |
The nucleus sampling probability. TYPE:`float |
routing_method |
The method used to route requests (e.g., fixed_order, round_robin). TYPE:`Literal['fixed_order', 'round_robin'] |
Examples:
# Example 1: create config from one model dictionary
config = LLMConfig({
"model": "gpt-5-mini",
"api_key": os.environ["OPENAI_API_KEY"],
})
# Example 2: create config from list of dictionaries
config = LLMConfig(
{
"model": "gpt-5-mini",
"api_key": os.environ["OPENAI_API_KEY"],
},
{
"model": "gpt-4",
"api_key": os.environ["OPENAI_API_KEY"],
},
)
Source code in autogen/llm_config/config.py
``config
t_list`` instance-attribute
config_list
ensure_config classmethod
ensure_config(config)
Transforms passed objects to LLMConfig object.
Method to use for Agent(llm_config={...}) cases.
LLMConfig.ensure_config(LLMConfig(...)) LLMConfig(...)
LLMConfig.ensure_config(LLMConfigEntry(...)) LLMConfig(LLMConfigEntry(...))
LLMConfig.ensure_config({"model": "gpt-o3"}) LLMConfig(OpenAILLMConfigEntry(model="o3"))
LLMConfig.ensure_config([{"model": "gpt-o3"}, ...]) LLMConfig(OpenAILLMConfigEntry(model="o3"), ...)
(deprecated) LLMConfig.ensure_config({"config_list": [{ "model": "gpt-o3" }, ...]}) LLMConfig(OpenAILLMConfigEntry(model="o3"), ...)
Source code in autogen/llm_config/config.py
from_json classmethod
from_json(*, env=None, path=None, file_location=None, filter_dict=None, **kwargs)
Source code in autogen/llm_config/config.py
where
where(*, exclude=False, **kwargs)
Source code in autogen/llm_config/config.py
model_dump
model_dump(*args, exclude_none=True, **kwargs)
Source code in autogen/llm_config/config.py
model_dump_json
model_dump_json(*args, exclude_none=True, **kwargs)
Source code in autogen/llm_config/config.py
model_validate
model_validate(*args, **kwargs)
Source code in autogen/llm_config/config.py
model_validate_json
model_validate_json(*args, **kwargs)
Source code in autogen/llm_config/config.py
model_validate_strings
model_validate_strings(*args, **kwargs)
Source code in autogen/llm_config/config.py
get
get(key, default=None)
Source code in autogen/llm_config/config.py
copy
copy()
Source code in autogen/llm_config/config.py
deepcopy
deepcopy(memo=None)
Source code in autogen/llm_config/config.py
items
items()
Source code in autogen/llm_config/config.py
keys
keys()
Source code in autogen/llm_config/config.py
values
values()
Source code in autogen/llm_config/config.py