# stepfun-ai/step1x-edit API

This document introduces the input and output parameters of the `stepfun-ai/step1x-edit` model API, for referencing field meanings during interface use.

---

## Request Parameters

### Request Body

| Field Name      | Type   | Required | Default Value | Description                                                                                                                   |
| --------------- | ------ | -------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| prompt          | string | Yes      | -             | Prompt word                                                                                                                   |
| model           | string | Yes      | -             | The model name used for this request, which here is `stepfun-ai/step1x-edit`.                                                 |
| image           | string | Yes      | -             | Base64 data or image link http://xxx                                                                                          |
| n               | int    | Optional | 1             | The number of images generated, ranging from 1 to 4                                                                           |
| strength        | float  | Optional | 0.8           | The degree of transformation referenced by the image, ranging from 0 to 1                                                     |
| seed            | int    | Optional | -1            | Random seed, used to control the randomness of the model's generated content. For consistent content, use the same seed value. |
| steps           | int    | Optional | 20            | Number of inference steps, ranging from 1 to 50                                                                               |
| guidance_scale  | float  | Optional | 2.5           | The consistency between the model output and the prompt, i.e., the degree of freedom of the generated image; the larger the value, the lower the degree of freedom, and the stronger the correlation with the user's prompt. <br> Range [1, 10].  |
| negative_prompt | string | Optional | -             | Negative prompt word, used to specify content you do not wish to appear in the generated image                                |
| response_format | string | Optional | "url"         | Specify the format for returning the generated image, default is `url`, options include `b64_json`                            |

## Response Parameters

| Field Name      | Type      | Description                                                                                                                                                                               |
| --------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| created         | `integer` | Unix timestamp (in seconds) of when the request was created.                                                                                                                               |
| data            | `array`   | Information about the output image, including the URL for downloading the image or Base64. <br>• If the format is specified as url, subfield is url; <br>• If the format is specified as b64_json, subfield is b64_json. <br>Note: The link will expire 7 days after generation, so be sure to save the image promptly. |
| 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-us-ca.umodelverse.ai/v1/images/generations`

#### Synchronous Request

```bash
curl --location 'https://api-us-ca.umodelverse.ai/v1/images/generations' \
--header "Authorization: Bearer $MODELVERSE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
    "model": "stepfun-ai/step1x-edit",
    "prompt": "Convert to quick pencil sketch",
    "image": "data:image/png;base64,{image_base64_string}",
    "negative_prompt": "blurry, low quality"
}'
```

```python
import os
from openai import OpenAI

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

response = client.images.generate(
    model="stepfun-ai/step1x-edit",
    prompt="Convert to quick pencil sketch",
    extra_body={
        "image": "data:image/png;base64,{image_base64_string}",
        "negative_prompt": "blurry, low quality"
    }
)

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

``` -->