Skip to main content

edit

Method
This is a method of the ImageAgent class in the image_agent module.
Edit an existing image with a prompt.

Signature

def edit(image: str, prompt: str, mask: Optional[str], n: int, size: Optional[str]) -> Dict[str, Any]

Parameters

image
str
required
Path or URL to the image to edit
prompt
str
required
Description of the desired edits
mask
Optional
Optional mask image (transparent areas will be edited)
n
int
default:"1"
Number of images to generate
size
Optional
Output image size **kwargs: Additional provider-specific parameters

Returns

Returns
Dict[str, Any]
ImageResponse with edited image(s)

Usage

agent = ImageAgent(llm="openai/dall-e-2")
    result = agent.edit("photo.png", "Add a sunset in the background")