pyrit.prompt_target.OpenAIVideoTarget#
- class OpenAIVideoTarget(*, resolution_dimensions: str = '1280x720', n_seconds: int = 4, **kwargs)[source]#
Bases:
OpenAITargetOpenAI Video Target using the OpenAI SDK for video generation.
Supports Sora-2 and Sora-2-Pro models via the OpenAI videos API.
Supported resolutions: - Sora-2: 720x1280, 1280x720 - Sora-2-Pro: 720x1280, 1280x720, 1024x1792, 1792x1024
Supported durations: 4, 8, or 12 seconds
Default: resolution=”1280x720”, duration=4 seconds
- __init__(*, resolution_dimensions: str = '1280x720', n_seconds: int = 4, **kwargs)[source]#
Initialize the OpenAI Video Target.
- Parameters:
model_name (str, Optional) – The video model to use (e.g., “sora-2”, “sora-2-pro”). If no value is provided, the OPENAI_VIDEO_MODEL environment variable will be used.
endpoint (str, Optional) – The target URL for the OpenAI service.
api_key (str | Callable[[], str], Optional) – The API key for accessing the OpenAI service, or a callable that returns an access token. For Azure endpoints with Entra authentication, pass a token provider from pyrit.auth (e.g., get_azure_openai_auth(endpoint)). Uses OPENAI_VIDEO_KEY environment variable by default.
headers (str, Optional) – Extra headers of the endpoint (JSON).
max_requests_per_minute (int, Optional) – Number of requests the target can handle per minute before hitting a rate limit.
resolution_dimensions (str, Optional) – Resolution dimensions for the video in WIDTHxHEIGHT format. Defaults to “1280x720”. Supported resolutions: - Sora-2: “720x1280”, “1280x720” - Sora-2-Pro: “720x1280”, “1280x720”, “1024x1792”, “1792x1024”
n_seconds (int, Optional) – The duration of the generated video (in seconds). Defaults to 4. Supported values: 4, 8, or 12 seconds.
**kwargs – Additional keyword arguments passed to the parent OpenAITarget class.
httpx_client_kwargs (dict, Optional) – Additional kwargs to be passed to the
httpx.AsyncClient()constructor. For example, to specify a 3 minute timeout:httpx_client_kwargs={"timeout": 180}
Methods
__init__(*[, resolution_dimensions, n_seconds])Initialize the OpenAI Video Target.
dispose_db_engine()Dispose database engine to release database connections and resources.
get_identifier()Get an identifier dictionary for this prompt target.
Check if the target supports JSON response data.
is_response_format_json(message_piece)Check if the response format is JSON and ensure the target supports it.
send_prompt_async(**kwargs)Send a normalized prompt async to the prompt target.
set_model_name(*, model_name)Set the model name for this target.
set_system_prompt(*, system_prompt, ...[, ...])Set the system prompt for the prompt target.
Attributes
ADDITIONAL_REQUEST_HEADERSA list of PromptConverters that are supported by the prompt target.
- SUPPORTED_DURATIONS = [4, 8, 12]#
- SUPPORTED_RESOLUTIONS = ['720x1280', '1280x720', '1024x1792', '1792x1024']#
- is_json_response_supported() bool[source]#
Check if the target supports JSON response data.
- Returns:
False, as video generation doesn’t return JSON content.
- Return type:
- async send_prompt_async(**kwargs)#
Send a normalized prompt async to the prompt target.