export type GetApiApiExperimentModelsPreviewFolderPathIndexFilenameArgs = {folder: string, path_index: number, filename: string}; export type GetApiApiExperimentModelsPreviewFolderPathIndexFilenameOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get model preview image * * GET /api/experiment/models/preview/{folder}/{path_index}/{filename} */ export const getApiApiExperimentModelsPreviewFolderPathIndexFilename = async (args: GetApiApiExperimentModelsPreviewFolderPathIndexFilenameArgs, options?: GetApiApiExperimentModelsPreviewFolderPathIndexFilenameOptions) => { const {baseUrl = "https://api.comfy.org", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/webp") const url = `${baseUrl.replace(/\/+$/, '')}/api/experiment/models/preview/${encodeURIComponent(String(args.folder))}/${encodeURIComponent(String(args.path_index))}/${encodeURIComponent(String(args.filename))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };