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

# 上傳參考素材

> 上傳參考圖片或影片，並可在 BytePlus Seedance 渠道選擇送審。

請使用正式環境的 DGrid **Model API Key**。若已有符合規格且伺服器可存取的 HTTPS 網址，可略過上傳。

## 上傳檔案

以 multipart 的 `file` 欄位傳送一個圖片或影片檔。伺服器會從檔案內容辨識類型。請讓 cURL 或 HTTP 用戶端自動產生 multipart boundary。

```bash theme={null}
curl -sS --fail-with-body --max-time 120 \
  "$DGRID_BASE_URL/video-assets" \
  --header "Authorization: Bearer $DGRID_API_KEY" \
  --form 'file=@./reference.jpg'
```

| 檔案類型 | 支援格式 | 單檔大小限制 |
| - | - | - |
| 圖片 | JPEG、PNG、WebP、GIF、BMP、TIFF | 小於 30,000,000 位元組。 |
| 影片 | MP4、MOV | 不超過 200,000,000 位元組。 |

對外閘道可能設定較小的請求大小上限。檔案仍須符合模型的尺寸、長度、影格率和輸入組合等要求。

## 上傳並送審

將選用的查詢參數 `submit_for_review` 設為單一 `true` 即可送審。省略此參數或傳入 `false` 時僅上傳。送審影片須在上傳時即可讀取長度。

```bash theme={null}
curl -sS --fail-with-body --max-time 120 \
  "$DGRID_BASE_URL/video-assets?submit_for_review=true" \
  --header "Authorization: Bearer $DGRID_API_KEY" \
  --form 'file=@./reference.mp4'
```

HTTP `201` 表示上傳成功。送審時也會回傳 `asset_id`，可用來查詢審核結果。

```json theme={null}
{
  "url": "https://example.invalid/reference.mp4?X-Amz-Expires=86400&X-Amz-Signature=example",
  "expires_at": "2026-12-01T08:00:00Z",
  "content_type": "video/mp4",
  "size_bytes": 2486109,
  "width": 1280,
  "height": 720,
  "duration_seconds": "5.000000000",
  "fps": "24.000000",
  "asset_id": "asset-example"
}
```

| 欄位 | 類型與說明 |
| - | - |
| `url` | 字串。簽名 HTTPS 網址。請保留完整查詢字串，並限制其公開存取。 |
| `expires_at` | 字串。RFC 3339 格式的到期時間。簽名網址自簽發起有效 24 小時。 |
| `content_type` | 字串。伺服器辨識的 MIME 類型。 |
| `size_bytes` | 整數。檔案大小，以位元組計。 |
| `width`、`height` | 選用整數。已辨識的尺寸，以像素計。 |
| `duration_seconds` | 選用十進位字串。影片長度，以秒計。 |
| `fps` | 選用十進位字串。影片平均影格率。 |
| `asset_id` | 選用字串。送審時回傳的官方素材 ID。 |

若簽名網址已過期，可重新上傳以取得新網址，或依[建立影片](https://docs.dgrid.ai/zh-Hant/api-reference/videos/create-video.md)的說明引用仍為 `Active` 的素材 ID。

## 查詢審核狀態

使用同一 DGrid 使用者的憑證呼叫 `GET /v1/video-assets/{asset_id}`，並填入上傳回應中的 `asset_id`。此請求無須提供內容。

```bash theme={null}
ASSET_ID='replace-with-returned-asset-id'
curl -sS --fail-with-body --max-time 30 \
  "$DGRID_BASE_URL/video-assets/$ASSET_ID" \
  --header "Authorization: Bearer $DGRID_API_KEY"
```

```json theme={null}
{
  "asset_id": "asset-example",
  "status": "Active"
}
```

| 狀態 | 處理方式 |
| - | - |
| `Processing` | 正在審核或預先處理。請設定本機等待上限並繼續輪詢。 |
| `Active` | 可在支援的生成請求中引用素材。 |
| `Failed` | 停止輪詢，並檢查回應中可能提供的 `error_code`。 |

狀態值區分大小寫。若遇到無法辨識的狀態，請保留素材 ID 並查明原因。本機等待逾時後，可用同一 ID 恢復輪詢。

## 上傳與審核錯誤

`409 video_asset_submission_unconfirmed` 表示同一素材正在送審，或上游受理結果未明。若有 `asset_id`，請直接查詢。若無 ID，請等待後用同一個檔案重試送審。若錯誤持續，請聯絡 DGrid 支援。影片生成的冪等鍵僅適用於建立影片的請求。

| HTTP 狀態 | 錯誤或情況 | 處理方式 |
| - | - | - |
| `400` | `invalid_video_asset_upload` | 僅傳送一個 multipart 的 `file` 欄位。 |
| `400` | `invalid_submit_for_review` | 在網址查詢參數中傳送單一的 `true` 或 `false`。 |
| `401` / `403` | 驗證或權限錯誤 | 檢查正式環境金鑰、使用者及權限。 |
| `404` | `video_asset_not_found` | 核對素材 ID 和所屬使用者。 |
| `405` | `unsupported_video_operation` | 使用 `POST` 上傳。 |
| `413` | `video_asset_too_large`、`body_too_large` 或閘道大小限制 | 改用較小的檔案。 |
| `415` | `unsupported_video_asset_type` | 改用支援的圖片或影片格式。 |
| `422` | `input_duration_unavailable` | 提供可讀取長度的影片。 |
| `429` | 速率限制 | 若有 `Retry-After`，請依其指示等待。 |
| `502` | `video_asset_upload_failed` 或 `invalid_video_service_response` | 等待後重試，並保留原檔案及已回傳的 ID。 |
| `502` | `video_asset_submission_rejected` | 檢查回應中的送審拒絕詳情，必要時聯絡支援。 |
| `503` | `video_asset_upload_unavailable`、`video_service_unavailable`、`video_disabled` 或 `video_asset_review_unavailable` | 等待服務恢復。若已取得素材 ID，請重新查詢原素材。 |
| `504` | `video_asset_upload_failed` | 上傳至儲存服務時逾時，請等待後重試。 |


## OpenAPI

````yaml api-reference/openapi.json POST /v1/video-assets
openapi: 3.1.0
info:
  title: DGrid AI Gateway API
  description: >-
    A single, unified API to access 200+ leading AI models. OpenAI-, Claude-,
    and Gemini-compatible endpoints for chat, completions, embeddings, images,
    video, audio, and moderations.
  version: 1.0.0
  contact:
    name: DGrid AI
    url: https://dgrid.ai
servers:
  - url: https://api.dgrid.ai
    description: DGrid AI Gateway
security:
  - bearerAuth: []
paths:
  /v1/video-assets:
    post:
      tags:
        - Videos
      summary: Upload reference asset
      description: >-
        Upload a single reference image or video. You can also submit the file
        for review on the BytePlus Seedance channel.
      operationId: uploadVideoReferenceAsset
      parameters:
        - name: submit_for_review
          in: query
          description: Set to true to submit the file for review as part of the upload.
          required: false
          schema:
            type: boolean
            default: false
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  description: Reference image or video file.
                  format: binary
      responses:
        '201':
          description: Reference asset uploaded.
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                    description: Signed HTTPS URL valid for 24 hours after issuance.
                    format: uri
                  expires_at:
                    type: string
                    description: RFC 3339 timestamp when the signed URL expires.
                    format: date-time
                  content_type:
                    type: string
                    description: MIME type detected from the file.
                  size_bytes:
                    type: integer
                    description: File size in bytes.
                  width:
                    type: integer
                    description: Detected width in pixels, when available.
                  height:
                    type: integer
                    description: Detected height in pixels, when available.
                  duration_seconds:
                    type: string
                    description: >-
                      Video duration in seconds as a decimal string, when
                      available.
                  fps:
                    type: string
                    description: >-
                      Average video frame rate as a decimal string, when
                      available.
                  asset_id:
                    type: string
                    description: >-
                      Official asset ID returned when the file is submitted for
                      review.
              example:
                url: >-
                  https://example.invalid/reference.mp4?X-Amz-Expires=86400&X-Amz-Signature=example
                expires_at: '2026-12-01T08:00:00Z'
                content_type: video/mp4
                size_bytes: 2486109
                width: 1280
                height: 720
                duration_seconds: '5.000000000'
                fps: '24.000000'
                asset_id: asset-example
        '400':
          description: Invalid upload or review query parameter.
        '401':
          description: Unauthorized.
        '403':
          description: Permission denied.
        '405':
          description: Unsupported operation.
        '409':
          description: Asset review submission unconfirmed.
        '413':
          description: File or request body too large.
        '415':
          description: Unsupported asset format.
        '422':
          description: Video duration unavailable.
        '429':
          description: Rate limit exceeded.
        '502':
          description: >-
            Upload failed, service response invalid, or review submission
            rejected.
        '503':
          description: Upload or review service unavailable.
        '504':
          description: Storage upload timed out.
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your DGrid API key. All endpoints use `Authorization: Bearer
        <DGRID_API_KEY>`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.