# Hidream O1 Image

> Unified image generation with HiDream-O1-Image. Create, edit, and personalize high-resolution images up to 2K—single native model handles text-to-image, editing, and custom subjects without external components.


## Overview

- **Endpoint**: `https://fal.run/fal-ai/hidream-o1-image/dev/edit`
- **Model ID**: `fal-ai/hidream-o1-image/dev/edit`
- **Category**: image-to-image
- **Kind**: inference


## Pricing

- **Price**: $0.005 per megapixels

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:


- **`prompt`** (`string`, _required_):
  Text prompt for image generation, editing, or subject-driven personalization.
  - Examples: "A cinematic product photo of a ceramic mug on a marble counter with the words \"fal loves HiDream\" printed on the mug."

- **`reference_image_urls`** (`list<string>`, _required_):
  Reference images for image editing or subject-driven personalization.
  - Array of string
  - Examples: ["https://storage.googleapis.com/falserverless/model_tests/hidream/woman.png"]

- **`image_size`** (`ImageSize | Enum`, _optional_):
  Requested output image size. The model snaps this to the closest supported resolution up to about 2048x2048 pixels.
  - Default: `{"height":2048,"width":2048}`
  - One of: ImageSize | Enum

- **`num_inference_steps`** (`integer`, _optional_):
  Number of denoising steps. The dev model is distilled for 28 steps. Default value: `28`
  - Default: `28`
  - Range: `1` to `28`

- **`guidance_scale`** (`float`, _optional_):
  Classifier-free guidance scale. The dev model uses 0.0 by default.
  - Default: `0`
  - Range: `0` to `20`

- **`seed`** (`integer`, _optional_):
  Random seed for reproducible generation.

- **`num_images`** (`integer`, _optional_):
  Number of images to generate. Default value: `1`
  - Default: `1`
  - Range: `1` to `4`

- **`output_format`** (`OutputFormatEnum`, _optional_):
  The format of the generated image. Default value: `"png"`
  - Default: `"png"`
  - Options: `"jpeg"`, `"png"`, `"webp"`

- **`sync_mode`** (`boolean`, _optional_):
  If `True`, the media will be returned as a data URI and the output data won't be available in the request history.
  - Default: `false`

- **`enable_safety_checker`** (`boolean`, _optional_):
  Enable the safety checker on generated images. Default value: `true`
  - Default: `true`

- **`keep_original_aspect`** (`boolean`, _optional_):
  When exactly one reference image is provided, preserve its aspect ratio for the output image.
  - Default: `false`



**Required Parameters Example**:

```json
{
  "prompt": "A cinematic product photo of a ceramic mug on a marble counter with the words \"fal loves HiDream\" printed on the mug.",
  "reference_image_urls": [
    "https://storage.googleapis.com/falserverless/model_tests/hidream/woman.png"
  ]
}
```

**Full Example**:

```json
{
  "prompt": "A cinematic product photo of a ceramic mug on a marble counter with the words \"fal loves HiDream\" printed on the mug.",
  "reference_image_urls": [
    "https://storage.googleapis.com/falserverless/model_tests/hidream/woman.png"
  ],
  "image_size": {
    "height": 2048,
    "width": 2048
  },
  "num_inference_steps": 28,
  "num_images": 1,
  "output_format": "png",
  "enable_safety_checker": true
}
```


### Output Schema

The API returns the following output format:

- **`images`** (`list<ImageFile>`, _required_):
  Generated images.
  - Array of ImageFile

- **`seed`** (`integer`, _required_):
  The seed used for generation.

- **`has_nsfw_concepts`** (`list<boolean>`, _required_):
  Whether each generated image was flagged by the safety checker.
  - Array of boolean

- **`prompt`** (`string`, _required_):
  The prompt used for generation.

- **`timings`** (`Timings`, _required_):
  Generation timings.



**Example Response**:

```json
{
  "images": [
    {
      "url": "",
      "content_type": "image/png",
      "file_name": "z9RV14K95DvU.png",
      "file_size": 4404019
    }
  ],
  "prompt": ""
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/hidream-o1-image/dev/edit \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "prompt": "A cinematic product photo of a ceramic mug on a marble counter with the words \"fal loves HiDream\" printed on the mug.",
     "reference_image_urls": [
       "https://storage.googleapis.com/falserverless/model_tests/hidream/woman.png"
     ]
   }'
```

### 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/hidream-o1-image/dev/edit",
    arguments={
        "prompt": "A cinematic product photo of a ceramic mug on a marble counter with the words \"fal loves HiDream\" printed on the mug.",
        "reference_image_urls": ["https://storage.googleapis.com/falserverless/model_tests/hidream/woman.png"]
    },
    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/hidream-o1-image/dev/edit", {
  input: {
    prompt: "A cinematic product photo of a ceramic mug on a marble counter with the words \"fal loves HiDream\" printed on the mug.",
    reference_image_urls: ["https://storage.googleapis.com/falserverless/model_tests/hidream/woman.png"]
  },
  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/hidream-o1-image/dev/edit)
- [API Documentation](https://fal.ai/models/fal-ai/hidream-o1-image/dev/edit/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/hidream-o1-image/dev/edit)

### 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)
