# Source: https://docs.comfy.org/built-in-nodes/partner-node/video/pika/pika-scenes.md

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.comfy.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Pika 2.2 Scenes - ComfyUI Built-in Node Documentation

> A node that creates coherent scene videos from multiple images using Pika AI

<img src="https://mintcdn.com/dripart/5003JSxULDwNImme/images/built-in-nodes/api_nodes/pika/pika-2-2-scenes.jpg?fit=max&auto=format&n=5003JSxULDwNImme&q=85&s=84326ffddf831516f76705979410d289" alt="ComfyUI Built-in Pika 2.2 Scenes Node" data-og-width="1731" width="1731" data-og-height="2121" height="2121" data-path="images/built-in-nodes/api_nodes/pika/pika-2-2-scenes.jpg" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/dripart/5003JSxULDwNImme/images/built-in-nodes/api_nodes/pika/pika-2-2-scenes.jpg?w=280&fit=max&auto=format&n=5003JSxULDwNImme&q=85&s=0d107ed6ac35bd07543a7fc4149b2bfa 280w, https://mintcdn.com/dripart/5003JSxULDwNImme/images/built-in-nodes/api_nodes/pika/pika-2-2-scenes.jpg?w=560&fit=max&auto=format&n=5003JSxULDwNImme&q=85&s=c68b392aab37de8e75eb0f0edd927dce 560w, https://mintcdn.com/dripart/5003JSxULDwNImme/images/built-in-nodes/api_nodes/pika/pika-2-2-scenes.jpg?w=840&fit=max&auto=format&n=5003JSxULDwNImme&q=85&s=74cf062e793f2b5a11630569501a0c51 840w, https://mintcdn.com/dripart/5003JSxULDwNImme/images/built-in-nodes/api_nodes/pika/pika-2-2-scenes.jpg?w=1100&fit=max&auto=format&n=5003JSxULDwNImme&q=85&s=849a17a65abc8ebcf590cfa44fd957d3 1100w, https://mintcdn.com/dripart/5003JSxULDwNImme/images/built-in-nodes/api_nodes/pika/pika-2-2-scenes.jpg?w=1650&fit=max&auto=format&n=5003JSxULDwNImme&q=85&s=e82e31b75398fa3d05be6f4b109478ed 1650w, https://mintcdn.com/dripart/5003JSxULDwNImme/images/built-in-nodes/api_nodes/pika/pika-2-2-scenes.jpg?w=2500&fit=max&auto=format&n=5003JSxULDwNImme&q=85&s=43ce716712a858cb97a3aacb6021904f 2500w" />

The Pika 2.2 Scenes node allows you to upload multiple images and generate a high-quality video incorporating these elements. It uses Pika's 2.2 API to create smooth scene transitions between the images.

## Parameters

### Required Parameters

| Parameter         | Type    | Default                   | Description                                     |
| ----------------- | ------- | ------------------------- | ----------------------------------------------- |
| prompt\_text      | string  | ""                        | Text prompt describing video content and scenes |
| negative\_prompt  | string  | ""                        | Elements to exclude from the video              |
| seed              | integer | 0                         | Random seed for generation                      |
| ingredients\_mode | select  | "creative"                | Image combination mode                          |
| resolution        | select  | API default               | Output video resolution                         |
| duration          | select  | API default               | Output video length                             |
| aspect\_ratio     | float   | 1.7777777777777777 (16:9) | Video aspect ratio, range 0.4-2.5               |

### Optional Parameters

| Parameter            | Type  | Description        |
| -------------------- | ----- | ------------------ |
| image\_ingredient\_1 | image | First scene image  |
| image\_ingredient\_2 | image | Second scene image |
| image\_ingredient\_3 | image | Third scene image  |
| image\_ingredient\_4 | image | Fourth scene image |
| image\_ingredient\_5 | image | Fifth scene image  |

### Output

| Output | Type  | Description     |
| ------ | ----- | --------------- |
| VIDEO  | video | Generated video |

## How It Works

The Pika 2.2 Scenes node analyzes all input images and creates a video containing these image elements. The node sends the images and parameters to Pika's API server, which processes them and returns the generated video.

Users can guide the video style and content through prompts, and exclude unwanted elements using negative prompts. The node supports up to 5 input images as ingredients and generates the final video based on the specified combination mode, resolution, duration, and aspect ratio.

## Source Code

```python  theme={null}

class PikaScenesV2_2(PikaNodeBase):
    """Pika 2.2 Scenes Node."""

    @classmethod
    def INPUT_TYPES(cls):
        image_ingredient_input = (
            IO.IMAGE,
            {"tooltip": "Image that will be used as ingredient to create a video."},
        )
        return {
            "required": {
                **cls.get_base_inputs_types(
                    PikaBodyGenerate22C2vGenerate22PikascenesPost,
                ),
                "ingredients_mode": model_field_to_node_input(
                    IO.COMBO,
                    PikaBodyGenerate22C2vGenerate22PikascenesPost,
                    "ingredientsMode",
                    enum_type=IngredientsMode,
                    default="creative",
                ),
                "aspect_ratio": model_field_to_node_input(
                    IO.FLOAT,
                    PikaBodyGenerate22C2vGenerate22PikascenesPost,
                    "aspectRatio",
                    step=0.001,
                    min=0.4,
                    max=2.5,
                    default=1.7777777777777777,
                ),
            },
            "optional": {
                "image_ingredient_1": image_ingredient_input,
                "image_ingredient_2": image_ingredient_input,
                "image_ingredient_3": image_ingredient_input,
                "image_ingredient_4": image_ingredient_input,
                "image_ingredient_5": image_ingredient_input,
            },
            "hidden": {
                "auth_token": "AUTH_TOKEN_COMFY_ORG",
            },
        }

    DESCRIPTION = "Combine your images to create a video with the objects in them. Upload multiple images as ingredients and generate a high-quality video that incorporates all of them."
    RETURN_TYPES = ("VIDEO",)

    def api_call(
        self,
        prompt_text: str,
        negative_prompt: str,
        seed: int,
        resolution: str,
        duration: int,
        ingredients_mode: str,
        aspect_ratio: float,
        image_ingredient_1: Optional[torch.Tensor] = None,
        image_ingredient_2: Optional[torch.Tensor] = None,
        image_ingredient_3: Optional[torch.Tensor] = None,
        image_ingredient_4: Optional[torch.Tensor] = None,
        image_ingredient_5: Optional[torch.Tensor] = None,
        auth_token: Optional[str] = None,
    ) -> tuple[VideoFromFile]:
        """API call for Pika Scenes 2.2."""
        all_image_bytes_io = []
        for image in [
            image_ingredient_1,
            image_ingredient_2,
            image_ingredient_3,
            image_ingredient_4,
            image_ingredient_5,
        ]:
            if image is not None:
                image_bytes_io = tensor_to_bytesio(image)
                image_bytes_io.seek(0)
                all_image_bytes_io.append(image_bytes_io)

        # Prepare files data for multipart upload
        pika_files = [
            ("images", (f"image_{i}.png", image_bytes_io, "image/png"))
            for i, image_bytes_io in enumerate(all_image_bytes_io)
        ]

        # Prepare non-file data using the Pydantic model
        pika_request_data = PikaBodyGenerate22C2vGenerate22PikascenesPost(
            ingredientsMode=ingredients_mode,
            promptText=prompt_text,
            negativePrompt=negative_prompt,
            seed=seed,
            resolution=resolution,
            duration=duration,
            aspectRatio=aspect_ratio,
        )

        initial_operation = SynchronousOperation(
            endpoint=ApiEndpoint(
                path=PATH_PIKASCENES,
                method=HttpMethod.POST,
                request_model=PikaBodyGenerate22C2vGenerate22PikascenesPost,
                response_model=PikaGenerateResponse,
            ),
            request=pika_request_data,
            files=pika_files,
            content_type="multipart/form-data",
            auth_token=auth_token,
        )

        return self.execute_task(initial_operation, auth_token)


```