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: model=”sora-2”, 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”). Defaults to “sora-2”.
endpoint (str, Optional) – The target URL for the OpenAI service.
api_key (str, Optional) – The API key for accessing the service. Uses OPENAI_VIDEO_KEY environment variable by default.
headers (str, Optional) – Extra headers of the endpoint (JSON).
use_entra_auth (bool, Optional) – When set to True, user authentication is used instead of API Key.
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.
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()Check if the target supports JSON response data.
is_response_format_json(message_piece)Checks if the response format is JSON and ensures the target supports it.
send_prompt_async(**kwargs)Sends 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, ...[, ...])Sets the system prompt for the prompt target.
Attributes
ADDITIONAL_REQUEST_HEADERS- 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)#
Sends a normalized prompt async to the prompt target.