edit • AI Agent SDK

edit: Edit an existing image with a prompt.

edit

Method

</div>

This is a method of the ImageAgent class in the image_agent module.

Edit an existing image with a prompt.

Signature

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

Parameters

ParamField str

Path or URL to the image to edit

ParamField str

Description of the desired edits

ParamField Optional[str]

Optional mask image (transparent areas will be edited)

ParamField int

Number of images to generate

ParamField Optional[str]

Output image size **kwargs: Additional provider-specific parameters

Returns

ResponseField ImageResult

ImageResponse with edited image(s)

Usage

python
agent = ImageAgent(llm="openai/gpt-image-2.5-flare")
    agent.edit("photo.png", "Add a sunset in the background").save("out.png")

Uses

  • ImageResult
  • litellm.image_edit

Source

View on GitHub

praisonaiagents/agent/image_agent.py at line 266