> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# edit • AI Agent SDK

> edit: Edit an existing image with a prompt.

# edit

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**ImageAgent**](../classes/ImageAgent) class in the [**image\_agent**](../modules/image_agent) module.

Edit an existing image with a prompt.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def edit(image: str, prompt: str, mask: Optional[str], n: int, size: Optional[str]) -> Dict[str, Any]
```

## Parameters

<ParamField query="image" type="str" required={true}>
  Path or URL to the image to edit
</ParamField>

<ParamField query="prompt" type="str" required={true}>
  Description of the desired edits
</ParamField>

<ParamField query="mask" type="Optional" required={false}>
  Optional mask image (transparent areas will be edited)
</ParamField>

<ParamField query="n" type="int" required={false} default="1">
  Number of images to generate
</ParamField>

<ParamField query="size" type="Optional" required={false}>
  Output image size \*\*kwargs: Additional provider-specific parameters
</ParamField>

### Returns

<ResponseField name="Returns" type="Dict[str, Any]">
  ImageResponse with edited image(s)
</ResponseField>

## Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
agent = ImageAgent(llm="openai/dall-e-2")
    result = agent.edit("photo.png", "Add a sunset in the background")
```

## Uses

* `litellm.image_edit`

## Used By

* [`ImageAgent.aedit`](../functions/ImageAgent-aedit)

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/image_agent.py#L230">
  `praisonaiagents/agent/image_agent.py` at line 230
</Card>
