garak.generators.azure

Azure OpenAI generator

Supports chat + chatcompletion models. Put your API key in the AZURE_API_KEY environment variable, the azure openai endpoint in the AZURE_ENDPOINT environment variable and the azure openai model name in AZURE_MODEL_NAME environment variable.

Put the deployment name in either the –target_name command line parameter, or pass it as an argument to the Generator constructor.

class AzureOpenAIGenerator(name='', config_root=<module 'garak._config' from '/home/docs/checkouts/readthedocs.org/user_builds/garak/checkouts/stable/garak/_config.py'>)Source

Bases: OpenAICompatible

Wrapper for Azure Open AI. Expects AZURE_API_KEY, AZURE_ENDPOINT and AZURE_MODEL_NAME environment variables.

Uses the OpenAI-compatible API via direct HTTP request.

To get started with this generator:

  1. Visit https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models and find the LLM you’d like to use.

  2. Deploy a model and copy the model and deployment names.

  3. On the Azure portal page for the Azure OpenAI you want to use click “Resource Management -> Keys and Endpoint” and copy the API Key and endpoint.

  4. In your console, Set the AZURE_API_KEY, AZURE_ENDPOINT and AZURE_MODEL_NAME variables.

  5. Run garak, setting --target_type to azure and --target_name to the name of the deployment. - e.g. gpt-4o.

Configurable parameters:

DEFAULT_PARAMS contents:

  • max_tokens = 150

  • temperature = 0.7

  • top_k = None

  • context_len = None

  • skip_seq_start = None

  • skip_seq_end = None

  • top_p = 1.0

  • uri = None

  • frequency_penalty = 0.0

  • presence_penalty = 0.0

  • seed = None

  • stop = ['#', ';']

  • suppressed_params = set()

  • retry_json = True

  • extra_params = {}

  • target_name = None

Default values are listed

See also Configuring garak for how to set these values.

Other attributes:

ENDPOINT_ENV_VAR = 'AZURE_ENDPOINT'
ENV_VAR = 'AZURE_API_KEY'
MODEL_NAME_ENV_VAR = 'AZURE_MODEL_NAME'
active = True
api_version = '2024-06-01'
generator_family_name = 'Azure'