# Edit Image

**Action ID:** `pml_edit_image`

## Description

Edit an image using a prompt.

## Connection

| Name               | Description                                       | Required | Category |
| ------------------ | ------------------------------------------------- | -------- | -------- |
| PixelML Connection | The PixelML connection to use for the edit image. | True     | pixelml  |

## Input Parameters

| Name        | Type    | Required | Default | Description                                                    |
| ----------- | ------- | :------: | ------- | -------------------------------------------------------------- |
| prompt      | string  |     ✓    | -       | The prompt to edit the image                                   |
| images      | array   |     ✓    | -       | The images to use for the edit (JPG/PNG)                       |
| temperature | number  |     -    | 0.9     | Controls randomness (0-1). Lower values are more deterministic |
| max\_tokens | integer |     -    | 2048    | Maximum tokens to generate (2048-4096)                         |
| top\_p      | number  |     -    | 1       | Nucleus sampling parameter for token selection                 |

<details>

<summary>View JSON Schema</summary>

```json
{
  "description": "Edit Image action input.",
  "properties": {
    "prompt": {
      "description": "The prompt to edit the image.",
      "title": "Prompt",
      "type": "string"
    },
    "images": {
      "description": "The images to use for the chat.",
      "items": {
        "type": "string"
      },
      "title": "Images",
      "type": "array"
    },
    "temperature": {
      "default": 0.9,
      "description": "Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.",
      "maximum": 1,
      "minimum": 0,
      "title": "Temperature",
      "type": "number"
    },
    "max_tokens": {
      "default": 2048,
      "description": "The maximum number of tokens to generate. Requests can use up to 2,048 or 4,096 tokens shared between prompt and completion depending on the model.",
      "title": "Maximum Tokens",
      "type": "integer"
    },
    "top_p": {
      "default": 1,
      "description": "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass.",
      "title": "Top P",
      "type": "number"
    }
  },
  "required": [
    "prompt",
    "images"
  ],
  "title": "PMLEditImageActionInput",
  "type": "object"
}
```

</details>

## Output Parameters

| Name    | Type | Description                                       |
| ------- | ---- | ------------------------------------------------- |
| content | any  | The edited image or response content from PixelML |

<details>

<summary>View JSON Schema</summary>

```json
{
  "description": "Edit Image action output.",
  "properties": {
    "content": {
      "title": "Content"
    }
  },
  "required": [
    "content"
  ],
  "title": "PMLEditImageActionOutput",
  "type": "object"
}
```

</details>

## How It Works

This node uses PixelML's AI-powered image editing capabilities to modify images based on text prompts. You provide one or more source images along with a descriptive prompt explaining the desired edits. The AI model processes the prompt and images, applying transformations such as style changes, object additions/removals, color adjustments, or content modifications. The temperature and token parameters control the creativity and output length of the generation process.

## Usage Examples

### Example 1: Change Image Style

**Input:**

```
prompt: "Make this image look like a watercolor painting"
images: ["https://example.com/photo.jpg"]
temperature: 0.7
max_tokens: 2048
```

**Output:**

```
content: {
  "url": "https://pixelml.com/edited/watercolor-image.png",
  "format": "png"
}
```

### Example 2: Remove Background Objects

**Input:**

```
prompt: "Remove all people from this street scene"
images: ["https://example.com/street.jpg"]
temperature: 0.3
max_tokens: 2048
```

**Output:**

```
content: {
  "url": "https://pixelml.com/edited/empty-street.png"
}
```

### Example 3: Add Creative Elements

**Input:**

```
prompt: "Add autumn leaves falling in the background"
images: ["https://example.com/portrait.jpg"]
temperature: 0.9
max_tokens: 3000
```

**Output:**

```
content: {
  "url": "https://pixelml.com/edited/autumn-portrait.png"
}
```

## Common Use Cases

* **Product Photography**: Modify product images by changing backgrounds, colors, or adding props
* **Photo Retouching**: Remove unwanted objects, blemishes, or people from photographs
* **Creative Transformations**: Apply artistic styles like oil painting, sketch, or cartoon effects
* **Image Composition**: Add or modify elements within existing images based on text descriptions
* **Background Replacement**: Change or enhance backgrounds while preserving foreground subjects
* **Color Grading**: Adjust mood, tone, and color palette of images using natural language descriptions
* **Fashion and Design**: Visualize clothing or design changes on existing product photos

## Error Handling

| Error Type           | Cause                                             | Solution                                                                         |
| -------------------- | ------------------------------------------------- | -------------------------------------------------------------------------------- |
| Connection Failed    | Invalid or missing PixelML connection credentials | Verify your PixelML connection is properly configured with valid API credentials |
| Invalid Image URL    | Image URL is not accessible or invalid format     | Ensure image URLs are publicly accessible and in JPG or PNG format               |
| Prompt Too Vague     | Editing prompt is unclear or ambiguous            | Provide specific, descriptive prompts with clear editing instructions            |
| Token Limit Exceeded | max\_tokens set too high for the model            | Reduce max\_tokens to 2048 or check model limits                                 |
| Unsupported Format   | Image format not supported by PixelML             | Convert images to JPG or PNG format before processing                            |
| Rate Limit Exceeded  | Too many API requests in short period             | Implement delays between requests or upgrade your PixelML plan                   |
| Processing Timeout   | Complex edits taking too long to process          | Simplify the editing prompt or reduce image resolution                           |

## Notes

* **Image Formats**: Only JPG and PNG image formats are supported. Ensure your images are in one of these formats before processing.
* **Temperature Control**: Lower temperature (0.0-0.3) produces more consistent, predictable edits. Higher temperature (0.7-1.0) generates more creative and varied results.
* **Prompt Specificity**: The more specific and detailed your prompt, the better the results. Include information about style, mood, colors, and specific changes desired.
* **Image URLs**: All image URLs must be publicly accessible. The PixelML service needs to download them for processing.
* **Token Management**: Higher max\_tokens allows for more complex edits but increases processing time and cost. Start with the default 2048 for most tasks.
* **Multiple Images**: You can provide multiple images in the array, useful for batch processing or providing reference images for the editing style.
* **API Costs**: Each edit operation consumes PixelML API credits. Monitor your usage to avoid unexpected costs.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.agenticflow.ai/reference/nodes/pml_edit_image.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
