OpenAI Model Target#
The following target references the GPT 4o model from OpenAI API endpoints.
Refer to garak.generators.openai.OpenAIGenerator for the parameters to specify in the options.openai field.
The options override the default values from the DEFAULT_PARAMS in the API reference.
Set the NMP_BASE_URL environment variable to the NeMo Auditor service endpoint.
Refer to Accessing the Microservice for more information.
With NeMo Platform running, follow the model provider instructions to set up a model provider that points at OpenAI and the model to audit. Create the provider in the default workspace and name it openai-provider.
import os
from nemo_platform import NeMoPlatform
client = NeMoPlatform(
base_url=os.environ.get("NMP_BASE_URL", "http://localhost:8080"),
workspace="default",
)
target = client.audit.targets.create(
workspace="default",
name="demo-openai-target",
type="openai.OpenAIGenerator",
model="gpt-4o",
options={
"openai": {
"nmp_uri_spec": {"inference_gateway": { "workspace": "default", "provider": "openai-provider" }},
"max_tokens": 1024,
"seed": 42
}
}
)
print(target.model_dump_json(indent=2))
nmp audit targets create --workspace "default" \
--name "demo-openai-target" \
--type "openai.OpenAIGenerator" \
--model "gpt-4o" \
--options '{"openai": { nmp_uri_spec": {"inference_gateway": { "workspace": "default", "provider": "openai-provider" }, "max_tokens": 1024, "seed": 42}}' \
-f json
Example Output
{
"id": "audit-target-RRvrfVbe6DyMu4Mco2V46k",
"created_at": "2026-03-24T22:16:15.366656",
"created_by": "service:platform",
"entity_id": "audit-target-RRvrfVbe6DyMu4Mco2V46k",
"model": "gpt-4o",
"parent": null,
"type": "openai.OpenAIGenerator",
"updated_at": "2026-03-24T22:16:15.366661",
"updated_by": "service:platform",
"workspace": "default",
"description": null,
"name": "demo-openai-target",
"options": {
"openai": {
"uri": "https://api.openai.com/v1/",
"max_tokens": 1024,
"seed": 42
}
},
"project": null
}