# black-forest-labs/flux.1-dev API

This document describes the input and output parameters of the `black-forest-labs/flux.1-dev` model API for your reference when using the interface.

---

## Request Parameters

### Request Body

| Field Name     | Type   | Required | Default Value | Description                                                                                                                  |
| -------------- | ------ | -------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| prompt         | string | Required | -             | Prompt                                                                                                                       |
| model          | string | Required | -             | The name of the model used for this request, here it is `black-forest-labs/flux.1-dev`.                                       |
| image          | string | Optional | -             | Base64 data or image link http://xxx                                                                                         |
| n              | int    | Optional | 1             | Number of images to generate, with a range of 1~4                                                                            |
| size           | string | Optional | "1024x1024"   | Resolution                                                                                                                   |
| strength       | float  | Optional | 0.8           | Degree to which the reference image is transformed, ranging from 0~1                                                        |
| seed           | int    | Optional | -1            | Random seed used to control the randomness of the model's generated content. To keep the content consistent, use the same seed value.  |
| steps          | int    | Optional | 20            | Number of inferences, ranging from 1~50                                                                                      |
| guidance_scale | float  | Optional | 2.5           | Degree of consistency between the model's output and the prompt, i.e., the freedom of generated images; the larger the value, the less freedom, and the stronger the correlation with the user's prompt.<br>Value range [1, 10]. |
| negative_prompt| string | Optional | -             | Negative prompt used to specify content you do not want to appear in the generated image                                      |
| response_format| string | Optional | "url"         | Specifies the format in which to return the generated image, default is `url`, optional `b64_json`                           |

## Response Parameters

| Field Name     | Type      | Description                                                                                                                                                                                                                                                |
| -------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| created        | `integer` | Unix timestamp (seconds) of this request creation time.                                                                                                                                                                                                     |
| data           | `array`   | Output image information, including the URL or Base64 of the image.<br>• When specified to return the generated image format as url, the subfield of the parameter is url;<br>• When specified to return the generated image format as b64_json, the subfield of the parameter is b64_json.<br>Note: The link will expire 7 days after generation, please be sure to save the image in time. |
| error          | `Object`  | Error information object                                                                                                                                                                                                                                    |
| error.code     | `string`  | Error code                                                                                                                                                                                                                                                  |
| error.message  | `string`  | Error message                                                                                                                                                                                                                                               |
| error.param    | `string`  | Request id                                                                                                                                                                                                                                                  |

## Example

### OPENAI Compatible Interface

`POST https://api.umodelverse.ai/v1/images/generations`

#### Synchronous Request

```bash
curl --location 'https://api.umodelverse.ai/v1/images/generations' \
--header "Authorization: Bearer $MODELVERSE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
    "model": "black-forest-labs/flux.1-dev",
    "prompt": "Convert to quick pencil sketch",
    "n": 1,
    "size": "1024x1024"
}'
```

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url=os.getenv("BASE_URL", "https://api.umodelverse.ai/v1"),
    api_key=os.getenv("API_KEY", "$MODELVERSE_API_KEY")
)

response = client.images.generate(
    model="black-forest-labs/flux.1-dev",
    prompt="Convert to quick pencil sketch",
    n=1,
    size="1024x1024"
)

print(response.data[0].url)
```

### Response

```json
{
  "created": 1750667997,
  "data": [
    {
      "url": "https://xxxxx/xxxx.png",
      "b64_json": "data:image/png;base64,{image_base64_string}"
    }
  ],
  "usage": {
    "input_tokens_details": {}
  }
}
```

```json
{
  "error": {
    "message": "error_message",
    "type": "error_type",
    "param": "request_id",
    "code": "error_code"
  }
}
```

<!--
TODO: Asynchronous Request
### Asynchronous Request

``` -->