# Flow-Edit

> The model provides you high quality image editing capabilities.


## Overview

- **Endpoint**: `https://fal.run/fal-ai/flowedit`
- **Model ID**: `fal-ai/flowedit`
- **Category**: image-to-image
- **Kind**: inference
**Tags**: editing



## Pricing

- **Price**: $0 per compute seconds

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`image_url`** (`string`, _required_):
  URL of image to be used for relighting
  - Examples: "https://storage.googleapis.com/falserverless/model_tests/FlowEdit/lighthouse.png"

- **`source_prompt`** (`string`, _required_):
  Prompt of the image to be used.
  - Examples: "The image features a tall white lighthouse standing prominently\n      on a hill, with a beautiful blue sky in the background. The lighthouse is illuminated\n      by a bright light, making it a prominent landmark in the scene."

- **`target_prompt`** (`string`, _required_):
  Prompt of the image to be made.
  - Examples: "The image features Big ben clock tower standing prominently\n      on a hill, with a beautiful blue sky in the background. The Big ben clock tower is illuminated\n      by a bright light, making it a prominent landmark in the scene."

- **`seed`** (`integer`, _optional_):
  Random seed for reproducible generation. If set none, a random seed will be used.

- **`num_inference_steps`** (`integer`, _optional_):
  Steps for which the model should run. Default value: `28`
  - Default: `28`
  - Range: `1` to `50`

- **`src_guidance_scale`** (`integer`, _optional_):
  Guidance scale for the source. Default value: `1.5`
  - Default: `1.5`
  - Range: `0` to `30`

- **`tar_guidance_scale`** (`integer`, _optional_):
  Guidance scale for target. Default value: `5.5`
  - Default: `5.5`
  - Range: `0` to `30`

- **`n_avg`** (`integer`, _optional_):
  Average step count Default value: `1`
  - Default: `1`

- **`n_max`** (`integer`, _optional_):
  Control the strength of the edit Default value: `23`
  - Default: `23`

- **`n_min`** (`integer`, _optional_):
  Minimum step for improved style edits
  - Default: `0`



**Required Parameters Example**:

```json
{
  "image_url": "https://storage.googleapis.com/falserverless/model_tests/FlowEdit/lighthouse.png",
  "source_prompt": "The image features a tall white lighthouse standing prominently\n      on a hill, with a beautiful blue sky in the background. The lighthouse is illuminated\n      by a bright light, making it a prominent landmark in the scene.",
  "target_prompt": "The image features Big ben clock tower standing prominently\n      on a hill, with a beautiful blue sky in the background. The Big ben clock tower is illuminated\n      by a bright light, making it a prominent landmark in the scene."
}
```

**Full Example**:

```json
{
  "image_url": "https://storage.googleapis.com/falserverless/model_tests/FlowEdit/lighthouse.png",
  "source_prompt": "The image features a tall white lighthouse standing prominently\n      on a hill, with a beautiful blue sky in the background. The lighthouse is illuminated\n      by a bright light, making it a prominent landmark in the scene.",
  "target_prompt": "The image features Big ben clock tower standing prominently\n      on a hill, with a beautiful blue sky in the background. The Big ben clock tower is illuminated\n      by a bright light, making it a prominent landmark in the scene.",
  "num_inference_steps": 28,
  "src_guidance_scale": 1.5,
  "tar_guidance_scale": 5.5,
  "n_avg": 1,
  "n_max": 23
}
```


### Output Schema

The API returns the following output format:

- **`image`** (`Image`, _required_):
  The generated image file info.
  - Examples: {"file_size":423052,"height":1024,"file_name":"36d3ca4791a647678b2ff01a35c87f5a.png","content_type":"image/png","url":"https://storage.googleapis.com/falserverless/model_tests/FlowEdit/aa5c3d028ad04800a54f70f928198d91.png","width":1024}

- **`seed`** (`integer`, _required_):
  Seed of the generated Image. It will be the same value of the one passed in the
  input or the randomly generated that was used in case none was passed.



**Example Response**:

```json
{
  "image": {
    "file_size": 423052,
    "height": 1024,
    "file_name": "36d3ca4791a647678b2ff01a35c87f5a.png",
    "content_type": "image/png",
    "url": "https://storage.googleapis.com/falserverless/model_tests/FlowEdit/aa5c3d028ad04800a54f70f928198d91.png",
    "width": 1024
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/flowedit \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "image_url": "https://storage.googleapis.com/falserverless/model_tests/FlowEdit/lighthouse.png",
     "source_prompt": "The image features a tall white lighthouse standing prominently\n      on a hill, with a beautiful blue sky in the background. The lighthouse is illuminated\n      by a bright light, making it a prominent landmark in the scene.",
     "target_prompt": "The image features Big ben clock tower standing prominently\n      on a hill, with a beautiful blue sky in the background. The Big ben clock tower is illuminated\n      by a bright light, making it a prominent landmark in the scene."
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "fal-ai/flowedit",
    arguments={
        "image_url": "https://storage.googleapis.com/falserverless/model_tests/FlowEdit/lighthouse.png",
        "source_prompt": "The image features a tall white lighthouse standing prominently
          on a hill, with a beautiful blue sky in the background. The lighthouse is illuminated
          by a bright light, making it a prominent landmark in the scene.",
        "target_prompt": "The image features Big ben clock tower standing prominently
          on a hill, with a beautiful blue sky in the background. The Big ben clock tower is illuminated
          by a bright light, making it a prominent landmark in the scene."
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("fal-ai/flowedit", {
  input: {
    image_url: "https://storage.googleapis.com/falserverless/model_tests/FlowEdit/lighthouse.png",
    source_prompt: "The image features a tall white lighthouse standing prominently
        on a hill, with a beautiful blue sky in the background. The lighthouse is illuminated
        by a bright light, making it a prominent landmark in the scene.",
    target_prompt: "The image features Big ben clock tower standing prominently
        on a hill, with a beautiful blue sky in the background. The Big ben clock tower is illuminated
        by a bright light, making it a prominent landmark in the scene."
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/fal-ai/flowedit)
- [API Documentation](https://fal.ai/models/fal-ai/flowedit/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/flowedit)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
