// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; export class Uploads extends APIResource { /** * Create a temporary upload URL for a file. Support multipart uploads. Return a * list of URLs for each part of the file. */ create(params: UploadCreateParams, options?: RequestOptions): APIPromise { const { projectId, ...body } = params; return this._client.post('/uploads', { query: { projectId }, body, ...options }); } /** * Get the details of an existing upload */ retrieve( uploadID: string, query: UploadRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get(path`/uploads/${uploadID}`, { query, ...options }); } /** * Trigger an action on upload */ triggerAction( uploadID: string, params: UploadTriggerActionParams, options?: RequestOptions, ): APIPromise { const { projectId, ...body } = params; return this._client.post(path`/uploads/${uploadID}/action`, { query: { projectId }, body, ...options }); } } export interface UploadCreateResponse { upload: UploadCreateResponse.Upload; } export namespace UploadCreateResponse { export interface Upload { id: string; authorId: string; createdAt: string; fileName: string; /** * The kind of the file once validated (example: "model") */ kind: '3d' | 'asset' | 'audio' | 'avatar' | 'image' | 'model' | 'text' | 'video'; ownerId: string; source: 'civitai' | 'huggingface' | 'multipart' | 'other' | 'url'; status: 'complete' | 'failed' | 'imported' | 'pending' | 'validated' | 'validating'; updatedAt: string; assetOptions?: Upload.AssetOptions; config?: unknown; contentType?: string; entityId?: string; errorMessage?: string; fileSize?: number; jobId?: string; originalFileName?: string; parts?: Array; partsCount?: number; provider?: 'civitai' | 'huggingface' | 'other'; url?: string; } export namespace Upload { export interface AssetOptions { /** * The collection ids to add the asset to. */ collectionIds?: Array; /** * Specify if the asset should be hidden from the user. */ hide?: boolean; /** * The parentId of the asset. */ parentId?: string; } export interface Part { expires: string; number: number; url: string; } } } export interface UploadRetrieveResponse { upload: UploadRetrieveResponse.Upload; } export namespace UploadRetrieveResponse { export interface Upload { id: string; authorId: string; createdAt: string; fileName: string; /** * The kind of the file once validated (example: "model") */ kind: '3d' | 'asset' | 'audio' | 'avatar' | 'image' | 'model' | 'text' | 'video'; ownerId: string; source: 'civitai' | 'huggingface' | 'multipart' | 'other' | 'url'; status: 'complete' | 'failed' | 'imported' | 'pending' | 'validated' | 'validating'; updatedAt: string; assetOptions?: Upload.AssetOptions; config?: unknown; contentType?: string; entityId?: string; errorMessage?: string; fileSize?: number; jobId?: string; originalFileName?: string; parts?: Array; partsCount?: number; provider?: 'civitai' | 'huggingface' | 'other'; url?: string; } export namespace Upload { export interface AssetOptions { /** * The collection ids to add the asset to. */ collectionIds?: Array; /** * Specify if the asset should be hidden from the user. */ hide?: boolean; /** * The parentId of the asset. */ parentId?: string; } export interface Part { expires: string; number: number; url: string; } } } export interface UploadTriggerActionResponse { upload: UploadTriggerActionResponse.Upload; } export namespace UploadTriggerActionResponse { export interface Upload { id: string; authorId: string; createdAt: string; fileName: string; /** * The kind of the file once validated (example: "model") */ kind: '3d' | 'asset' | 'audio' | 'avatar' | 'image' | 'model' | 'text' | 'video'; ownerId: string; source: 'civitai' | 'huggingface' | 'multipart' | 'other' | 'url'; status: 'complete' | 'failed' | 'imported' | 'pending' | 'validated' | 'validating'; updatedAt: string; assetOptions?: Upload.AssetOptions; config?: unknown; contentType?: string; entityId?: string; errorMessage?: string; fileSize?: number; jobId?: string; originalFileName?: string; parts?: Array; partsCount?: number; provider?: 'civitai' | 'huggingface' | 'other'; url?: string; } export namespace Upload { export interface AssetOptions { /** * The collection ids to add the asset to. */ collectionIds?: Array; /** * Specify if the asset should be hidden from the user. */ hide?: boolean; /** * The parentId of the asset. */ parentId?: string; } export interface Part { expires: string; number: number; url: string; } } } export interface UploadCreateParams { /** * Query param: The projectId used for ownership resource management. Either to * assert ownership or to set the owner of the resource(s) */ projectId?: string; /** * Body param: Asset extra options. Only available for kinds which produce an * asset. (Not available for model kind) */ assetOptions?: UploadCreateParams.AssetOptions; /** * Body param: The civitai.com url of the model (example: * "https://civitai.com/models/370194/translucent-subsurface-scattering-test?modelVersionId=413566"). */ civitaiModelUrl?: string; /** * Body param: Required for multipart upload. The MIME type of the file (example: * "image/jpeg") */ contentType?: string; /** * Body param: Required for multipart upload. The original file name of the image * (example: "low-res-image.jpg"). It will be ignored if assetId is provided. */ fileName?: string; /** * Body param: Required for multipart upload. The size of the file in bytes */ fileSize?: number; /** * Body param: The huggingface.co modelName (example: * "black-forest-labs/FLUX.1-dev"). No need to setup other fields if you setup * huggingFaceModelName */ huggingFaceModelName?: string; /** * Body param: Required for multipart upload and url. The purpose of the file once * validated (example: "model") */ kind?: '3d' | 'asset' | 'audio' | 'avatar' | 'image' | 'model' | 'text' | 'video'; /** * Body param: Required for multipart upload. The number of parts the file will be * uploaded in */ parts?: number; /** * Body param: The url where to download the file. If you setup url you MUST setup * kind as well. */ url?: string; } export namespace UploadCreateParams { /** * Asset extra options. Only available for kinds which produce an asset. (Not * available for model kind) */ export interface AssetOptions { /** * The collection ids to add the asset to. */ collectionIds?: Array; /** * Specify if the asset should be hidden from the user. */ hide?: boolean; /** * The parentId of the asset. */ parentId?: string; } } export interface UploadRetrieveParams { projectId?: unknown; } export interface UploadTriggerActionParams { /** * Body param: The action to perform on an upload, currently only "upload-complete" * is supported */ action: 'complete'; /** * Query param */ projectId?: unknown; } export declare namespace Uploads { export { type UploadCreateResponse as UploadCreateResponse, type UploadRetrieveResponse as UploadRetrieveResponse, type UploadTriggerActionResponse as UploadTriggerActionResponse, type UploadCreateParams as UploadCreateParams, type UploadRetrieveParams as UploadRetrieveParams, type UploadTriggerActionParams as UploadTriggerActionParams, }; }