garak.generators.llm

Wraps Simon Willison’s llm library, which provides a unified interface to many LLM providers (OpenAI, Claude, Gemini, Ollama, etc.) via plugins.

API keys and provider setup are managed by llm directly. Install the base package and any provider plugins you need:

pip install llm llm-claude-3

Then invoke garak with the llm model id:

garak --model_type llm --model_name gpt-4o-mini

LLM generator support

Wraps Simon Willison’s llm library (https://pypi.org/project/llm/), which provides a unified interface to many LLM providers via plugins.

API keys and provider configuration are managed by llm itself (e.g. llm keys set openai). Pass the llm model id or alias as --target_name:

pip install llm llm-claude-3  # install llm + any provider plugins
garak --target_type llm --target_name gpt-4o-mini
class LLMGenerator(name='', config_root=<module 'garak._config' from '/home/docs/checkouts/readthedocs.org/user_builds/garak/checkouts/latest/garak/_config.py'>)Source

Bases: Generator

Interface for llm-managed models.

Supports any model accessible through llm and its provider plugins, including OpenAI, Claude, Gemini, and Ollama models. Provider setup, authentication, and model-specific options are handled by llm.

Configurable parameters:

DEFAULT_PARAMS contents:

  • max_tokens = 150

  • temperature = None

  • top_k = None

  • context_len = None

  • skip_seq_start = None

  • skip_seq_end = None

  • top_p = None

  • stop = []

  • suppressed_params = set()

  • extra_params = {}

Default values are listed

See also Configuring garak for how to set these values.

Other attributes:

active = True
extra_dependency_names = ['llm']
generator_family_name = 'llm'
parallel_capable = False