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

# 在视频中插入物体

> Add an object to the video.
- **With imageMask**: insert at the masked area (white = insertion zone)
- **Without imageMask**: AI automatically determines placement based on prompt

## 概述

在之前生成的视频中添加物体。您可以使用可选的图像蒙版控制放置位置。

### 两种模式

| 模式                | 描述                   |
| ----------------- | -------------------- |
| **有 `imageMask`** | 在蒙版区域插入（白色像素 = 插入区域） |
| **无 `imageMask`** | AI 根据提示词自动确定最佳放置位置   |

<Warning>
  需要来自之前生成视频的有效 `videoId`（mediaId）。
</Warning>

<Tip>
  `imageMask` 应为 base64 编码的 JPEG 图像，其中**白色区域**表示应插入物体的位置。
</Tip>


## OpenAPI

````yaml POST /gemini/video/object/insert
openapi: 3.0.0
info:
  title: Google Gemini - Video, Image & SDK Compat
  description: >-
    Google Gemini services: video generation (Veo 2/3/3.1), image generation
    (Nano Banana), and Gemini Compat API for the official @google/genai SDK.
  version: 2.0.0
  contact: {}
servers:
  - url: https://api.mountsea.ai
    description: API Gateway
security: []
tags:
  - name: gemini
    description: >-
      Video generation (Veo 2/3/3.1) and image generation (Nano Banana)
      endpoints
  - name: gemini-compat
    description: >-
      Gemini Compat API - drop-in replacement for Google's official
      @google/genai SDK. Supports generateContent / streamGenerateContent for
      text and image generation.
paths:
  /gemini/video/object/insert:
    post:
      tags:
        - gemini
      summary: Insert object into video
      description: >-
        Add an object to the video.

        - **With imageMask**: insert at the masked area (white = insertion zone)

        - **Without imageMask**: AI automatically determines placement based on
        prompt
      operationId: ApiPublicController_insertObject
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VideoObjectInsertionDto'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskIdDto'
      security:
        - bearerAuth: []
components:
  schemas:
    VideoObjectInsertionDto:
      type: object
      properties:
        videoId:
          type: string
          description: Video ID (mediaId) from a previously generated video
          example: CAUSJD...
        prompt:
          type: string
          description: Prompt describing what to insert
          example: add a flying pig with black wings
        imageMask:
          type: string
          description: >-
            Base64 encoded JPEG image mask (optional). White areas indicate
            where to insert the object. If not provided, AI auto-determines
            placement.
          example: /9j/4AAQSkZJRg...
      required:
        - videoId
        - prompt
    TaskIdDto:
      type: object
      properties:
        taskId:
          type: string
          description: task id, used to get task result later
      required:
        - taskId
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````