Interface EditImageOptions

Options for an editImage call.

Example

const result = await editImage({
provider: 'openai',
image: 'data:image/png;base64,...',
prompt: 'Add a rainbow in the sky.',
mode: 'img2img',
strength: 0.6,
});
interface EditImageOptions {
    provider?: string;
    model?: string;
    image: string | Buffer<ArrayBufferLike>;
    prompt: string;
    mask?: string | Buffer<ArrayBufferLike>;
    mode?: ImageEditMode;
    strength?: number;
    negativePrompt?: string;
    size?: string;
    seed?: number;
    n?: number;
    apiKey?: string;
    baseUrl?: string;
    providerOptions?: Record<string, unknown> | ImageProviderOptionBag;
    usageLedger?: AgentOSUsageLedgerOptions;
}

Properties

provider?: string

Provider name (e.g. "openai", "stability", "stable-diffusion-local"). When omitted, auto-detection via env vars is attempted.

model?: string

Model in provider:model format (legacy) or plain model name when provider is set.

Example

`"openai:gpt-image-1"`, `"stability:sd3-medium"`
image: string | Buffer<ArrayBufferLike>

Source image as a base64 data URL, raw base64 string, Buffer, local file path, or HTTP/HTTPS URL.

prompt: string

Text prompt describing the desired changes.

mask?: string | Buffer<ArrayBufferLike>

Optional mask for inpainting. White pixels mark regions to be edited; black pixels mark regions to keep. Accepts the same formats as image.

Edit mode.

  • 'img2img' (default) — prompt-guided transformation.
  • 'inpaint' — mask-guided regional editing.
  • 'outpaint' — extend image borders.
strength?: number

How much to deviate from the source image. 0 = identical, 1 = completely new. Default 0.75.

negativePrompt?: string

Negative prompt describing content to avoid.

size?: string

Output size (e.g. "1024x1024").

seed?: number

Seed for reproducibility (provider-dependent support).

n?: number

Number of output images.

apiKey?: string

Override the provider API key instead of reading from env vars.

baseUrl?: string

Override the provider base URL.

providerOptions?: Record<string, unknown> | ImageProviderOptionBag

Arbitrary provider-specific options.

Optional usage ledger configuration.