pyrit.prompt_target.OpenAIVideoTarget#
- class OpenAIVideoTarget(*, resolution_dimensions: Literal['720x1280', '1280x720', '1024x1792', '1792x1024'] = '1280x720', n_seconds: int | Literal['4', '8', '12'] = 4, **kwargs: Any)[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.
Supports three modes: - Text-to-video: Generate video from a text prompt - Text+Image-to-video: Generate video using an image as the first frame (include image_path piece) - Remix: Create variation of existing video (include video_id in prompt_metadata)
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
Supported image formats for text+image-to-video: JPEG, PNG, WEBP
- __init__(*, resolution_dimensions: Literal['720x1280', '1280x720', '1024x1792', '1792x1024'] = '1280x720', n_seconds: int | Literal['4', '8', '12'] = 4, **kwargs: Any) None[source]#
Initialize the OpenAI Video Target.
- Parameters:
model_name (str, Optional) – The video model to use (e.g., “sora-2”, “sora-2-pro”) (or deployment name in Azure). 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 (VideoSize, Optional) – Resolution dimensions for the video. Defaults to “1280x720”. Supported resolutions: - Sora-2: “720x1280”, “1280x720” - Sora-2-Pro: “720x1280”, “1280x720”, “1024x1792”, “1792x1024”
n_seconds (int | VideoSeconds, Optional) – The duration of the generated video. Accepts an int (4, 8, 12) or a VideoSeconds string (“4”, “8”, “12”). Defaults to 4.
**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}
- Remix workflow:
To remix an existing video, set
prompt_metadata={"video_id": "<id>"}on the text MessagePiece. The video_id is returned in the response metadata after any successful generation (response.message_pieces[0].prompt_metadata["video_id"]).
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 the component's identifier, building it lazily on first access.
Check if the target supports JSON response data.
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.
Attributes
ADDITIONAL_REQUEST_HEADERScapabilitiesThe capabilities of this target instance.
supports_multi_turnWhether this target supports multi-turn conversations.
model_name_environment_variableendpoint_environment_variableapi_key_environment_variableunderlying_model_environment_variablesupported_convertersA list of PromptConverters that are supported by the prompt target.
- SUPPORTED_RESOLUTIONS: list[Literal['720x1280', '1280x720', '1024x1792', '1792x1024']] = ['720x1280', '1280x720', '1024x1792', '1792x1024']#