> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-feat-openapi-i18n.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 上传新资产

> 向系统上传带有相关元数据的新资产。
支持两种上传方式：
1. 直接文件上传（multipart/form-data）
2. 基于URL的上传（application/json，source: "url"）

如果具有相同哈希的资产已存在，则返回现有资产。




## OpenAPI

````yaml /openapi/cloud.zh.yaml post /api/assets
openapi: 3.0.3
info:
  title: Comfy Cloud API
  description: >
    <警告>

    **实验性API：** 此API是实验性的，可能会更改。

    端点、请求/响应格式和行为可能在未经通知的情况下修改。

    </警告>


    用于Comfy Cloud的API - 在云基础设施上运行ComfyUI工作流。


    此API允许您以编程方式与Comfy Cloud交互，包括：

    - 提交和管理工作流

    - 上传和下载文件

    - 监控作业状态和进度


    ## 云端与OSS ComfyUI兼容性


    Comfy Cloud实现了与OSS ComfyUI相同的API接口以实现最大兼容性，

    但某些字段为了兼容性被接受，但处理方式不同或被忽略：


    | 字段 | 端点 | 云端行为 |

    |-------|-----------|----------------|

    | `subfolder` | `/api/view`, `/api/upload/*` | **忽略** -
    云端使用内容寻址存储（基于哈希）。在响应中返回用于客户端组织。 |

    | `type` (input/output/temp) | `/api/view`, `/api/upload/*` | 部分使用 -
    所有文件使用基于标签的组织存储，而非目录结构。 |

    | `overwrite` | `/api/upload/*` | **忽略** - 内容寻址存储意味着相同内容始终具有相同哈希。 |

    | `number`, `front` | `/api/prompt` | **忽略** - 云端使用自己的每个用户公平队列调度。 |

    | `split`, `full_info` | `/api/userdata` | **忽略** - 云端始终返回完整文件元数据。 |


    这些字段保留在API模式中，以便与现有ComfyUI客户端和工作流进行即插即用兼容。
  version: 1.0.0
  license:
    name: GNU General Public License v3.0
    url: https://github.com/Comfy-Org/ComfyUI/blob/master/LICENSE
servers:
  - url: https://cloud.comfy.org
    description: Comfy Cloud API
security:
  - ApiKeyAuth: []
tags:
  - name: workflow
    description: |
      提交工作流执行并管理执行队列。
      这是在云端运行ComfyUI工作流的主要方式。
  - name: job
    description: |
      监控任务状态、查看执行历史和管理运行中的任务。
      任务通过POST /api/prompt提交工作流时创建。
  - name: asset
    description: |
      上传、下载和管理持久资产（图像、模型、输出）。
      资产提供持久存储，支持标签和元数据。
  - name: file
    description: |
      与传统本地ComfyUI兼容的传统文件上传和下载端点。
      对于新的集成，请考虑使用资产API。
  - name: model
    description: |
      浏览可用的AI模型。模型已预加载到云端基础设施上。
  - name: node
    description: |
      获取可用ComfyUI节点及其输入/输出的信息。
      对构建动态工作流界面很有用。
  - name: user
    description: |
      用户账户信息和个人数据存储。
  - name: system
    description: |
      服务器状态、健康检查和系统信息。
paths:
  /api/assets:
    post:
      tags:
        - asset
      summary: 上传新资产
      description: |
        向系统上传带有相关元数据的新资产。
        支持两种上传方式：
        1. 直接文件上传（multipart/form-data）
        2. 基于URL的上传（application/json，source: "url"）

        如果具有相同哈希的资产已存在，则返回现有资产。
      operationId: uploadAsset
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: 要上传的资产文件
                tags:
                  type: array
                  items:
                    type: string
                  description: >-
                    资产的自由格式标签。常见类型包括"models"、"input"、"output"和"temp"，但任何标签都可以任意顺序使用。
                id:
                  type: string
                  format: uuid
                  description: 用于幂等创建的可选资产ID。如果提供且资产已存在，则返回现有资产。
                preview_id:
                  type: string
                  format: uuid
                  description: 可选预览资产ID。如果未提供，图像将使用自己的ID作为预览。
                name:
                  type: string
                  description: 资产的显示名称
                mime_type:
                  type: string
                  description: 资产的MIME类型（例如"image/png"、"video/mp4"）
                user_metadata:
                  type: string
                  description: 作为字符串的自定义JSON元数据
          application/json:
            schema:
              type: object
              required:
                - url
                - name
              properties:
                url:
                  type: string
                  format: uri
                  description: 用于下载资产的HTTP/HTTPS URL
                name:
                  type: string
                  description: 资产的显示名称（用于确定文件扩展名）
                tags:
                  type: array
                  items:
                    type: string
                  description: >-
                    资产的自由格式标签。常见类型包括"models"、"input"、"output"和"temp"，但任何标签都可以任意顺序使用。
                user_metadata:
                  type: object
                  additionalProperties: true
                  description: 与资产一起存储的自定义元数据
                preview_id:
                  type: string
                  format: uuid
                  description: 可选的预览资产ID
      responses:
        '200':
          description: 资产已存在（返回现有资产）
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AssetCreated'
        '201':
          description: 资产创建成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AssetCreated'
        '400':
          description: 无效的请求（文件错误、URL无效、内容类型无效等）
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 未授权
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: 来源URL需要认证或访问被拒绝
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: 来源URL未找到
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '413':
          description: 文件过大
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '415':
          description: 不支持的媒体类型
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: 由于网络错误或超时导致下载失败
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: 内部服务器错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    AssetCreated:
      allOf:
        - $ref: '#/components/schemas/Asset'
        - type: object
          required:
            - created_new
          properties:
            created_new:
              type: boolean
              description: 这是否为新资产创建（是）或返回已有（否）
    ErrorResponse:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
        message:
          type: string
    Asset:
      type: object
      required:
        - id
        - name
        - size
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
          description: 资产的唯一标识符
        name:
          type: string
          description: 资产文件的名称
        asset_hash:
          type: string
          description: 资产内容的 Blake3 哈希
          pattern: ^blake3:[a-f0-9]{64}$
        size:
          type: integer
          format: int64
          description: 资产的字节大小
        mime_type:
          type: string
          description: 资产的 MIME 类型
        tags:
          type: array
          items:
            type: string
          description: 与资产关联的标签
        user_metadata:
          type: object
          description: 资产的自定义用户元数据
          additionalProperties: true
        preview_url:
          type: string
          format: uri
          description: 资产预览/缩略图的 URL
        preview_id:
          type: string
          format: uuid
          description: 预览资产的 ID（如有）
          nullable: true
        prompt_id:
          type: string
          format: uuid
          description: 创建此资产的任务/提示的 ID（如有）
          nullable: true
        created_at:
          type: string
          format: date-time
          description: 资产创建的时间戳
        updated_at:
          type: string
          format: date-time
          description: 资产最后更新的时间戳
        last_access_time:
          type: string
          format: date-time
          description: 资产最后访问的时间戳
        is_immutable:
          type: boolean
          description: 此资产是否为不可变（不能修改或删除）
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: |
        API密钥认证。从您的用户设置中生成API密钥
        位于https://platform.comfy.org/profile/api-keys。在X-API-Key头中传递密钥。

````