garak.generators.openai
OpenAI API Compatible generators
Supports chat + chatcompletion models. Put your API key in an environment variable documented in the selected generator. Put the name of the model you want in either the –target_name command line parameter, or pass it as an argument to the Generator constructor.
Sources:
https://platform.openai.com/docs/models/model-endpoint-compatibility
https://platform.openai.com/docs/model-index-for-researchers
- class OpenAICompatible(name='', config_root=<module 'garak._config' from '/home/docs/checkouts/readthedocs.org/user_builds/garak/checkouts/latest/docs/source/../../garak/_config.py'>)Source
Bases:
GeneratorGenerator base class for OpenAI compatible text2text restful API. Implements shared initialization and execution methods.
Configurable parameters:
DEFAULT_PARAMScontents:max_tokens=150temperature=0.7top_k=Nonecontext_len=Noneskip_seq_start=Noneskip_seq_end=Nonetop_p=1.0uri='http://localhost:8000/v1/'frequency_penalty=0.0presence_penalty=0.0seed=Nonestop=['#', ';']suppressed_params=set()retry_json=Trueextra_params={}
Default values are listed
See also Configuring garak for how to set these values.
Other attributes:
- ENV_VAR = 'OPENAICOMPATIBLE_API_KEY'
- active = True
- generator_family_name = 'OpenAICompatible'
- supports_multiple_generations = False
- class OpenAIGenerator(name='', config_root=<module 'garak._config' from '/home/docs/checkouts/readthedocs.org/user_builds/garak/checkouts/latest/docs/source/../../garak/_config.py'>)Source
Bases:
OpenAICompatibleGenerator wrapper for OpenAI text2text models. Expects API key in the OPENAI_API_KEY environment variable
Configurable parameters:
DEFAULT_PARAMScontents:max_tokens=150temperature=0.7top_k=Nonecontext_len=Noneskip_seq_start=Noneskip_seq_end=Nonetop_p=1.0frequency_penalty=0.0presence_penalty=0.0seed=Nonestop=['#', ';']suppressed_params=set()retry_json=Trueextra_params={}
Default values are listed
See also Configuring garak for how to set these values.
Other attributes:
- ENV_VAR = 'OPENAI_API_KEY'
- active = True
- generator_family_name = 'OpenAI'
- supports_multiple_generations = True
- class OpenAIReasoningGenerator(name='', config_root=<module 'garak._config' from '/home/docs/checkouts/readthedocs.org/user_builds/garak/checkouts/latest/docs/source/../../garak/_config.py'>)Source
Bases:
OpenAIGeneratorGenerator wrapper for OpenAI reasoning models, e.g. o1 family.
Configurable parameters:
DEFAULT_PARAMScontents:max_tokens=150temperature=Nonetop_k=Nonecontext_len=Noneskip_seq_start=Noneskip_seq_end=Nonetop_p=1.0frequency_penalty=0.0presence_penalty=0.0seed=Nonestop=['#', ';']suppressed_params={'max_tokens', 'stop', 'temperature', 'n'}retry_json=Truemax_completion_tokens=1500
Default values are listed
See also Configuring garak for how to set these values.
Other attributes:
- supports_multiple_generations = False