export type CreateApiV1ImagesEditsArgs = {body: {background?: ('transparent' | 'opaque' | 'auto') | undefined, image?: (string | Array) | undefined, mask?: string | undefined, model?: string | undefined, moderation?: ('low' | 'auto') | undefined, n?: number | undefined, output_format?: ('png' | 'jpeg' | 'webp') | undefined, prompt?: string | undefined, quality?: string | undefined, response_format?: string | undefined, size?: string | undefined, user?: string | undefined}}; export type CreateApiV1ImagesEditsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * OpenAI Images Edit 兼容入口 * * POST /v1/images/edits */ export const createApiV1ImagesEdits = async (args: CreateApiV1ImagesEditsArgs, options: CreateApiV1ImagesEditsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/images/edits${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };