> ## Documentation Index
> Fetch the complete documentation index at: https://docs.randomseed.co/llms.txt
> Use this file to discover all available pages before exploring further.

# v1/img2img

> Generate an image from an image asynchronously

### API key

Create your account on [RandomSeed](https://randomseed.co/signup) & grab your [api key](https://randomseed.co/api-reference/integrate)

### Headers

<ParamField header="Authorization" type="string">
  Your API key. This is required by most endpoints to access our API programatically. You can get your api key by clicking on 'API reference' tab under your profile icon.
</ParamField>

### Body

<ParamField body="prompt" type="string" required>
  This is the text prompt for the image you want generated. Loras can be used by adding this in the prompt `<lora:LORA_NAME:weight>` where LORA\_NAME is the name of the lora model and weight can be from 0 to 1, with decimal values supported.
</ParamField>

<ParamField body="negative_prompt" type="string" default="">
  This is the text prompt describing what you don't want to see in the image.
</ParamField>

<ParamField body="width" type="string" default="512">
  This is the width of the image
</ParamField>

<ParamField body="height" type="string" default="512">
  This is the height of the image
</ParamField>

<ParamField body="number_of_images" type="string" default="1">
  Number of images you want to generate
</ParamField>

<ParamField body="steps" type="string" default="50">
  This is the number of the denoising steps used by the AI model when generating an image. A higher number results in a longer generation time, and does not necessarily guarantee higher image quality.
</ParamField>

<ParamField body="cfg_scale" type="float" default="7.0">
  This is the number of the number you specify to control how closely AI model should follow the text prompt. 7 or 7.5 usually works best. You can increase the value if the generated image doesn’t match your prompt. Increment it by 0.5.
</ParamField>

<ParamField body="model_name" type="string" required>
  Specify the name of the model you'd like to use. You can find the model names [here](/api-reference/v1/models)
</ParamField>

<ParamField body="sampler_name" type="string" required>
  This is the name of the sampler method you will be using to generate an image. Image output varies slightly depending on the method.
  You can pick one of the [following methods](/documentation/sampler-methods)
</ParamField>

<ParamField body="include_init_images" type="boolean" default="true">
  Set it to true for inpainting or basic img2img generation.
</ParamField>

<ParamField body="image_strength" type="float" default="0.7">
  Determines how close the generated image will be to the provided image.
</ParamField>

<ParamField body="image_url" type="string" required>
  Link to the image url you want modified
</ParamField>

<ParamField body="mask" type="string">
  Link to the image that will be used for inpainting. You need to specify the region of the starting image that you want modified.
</ParamField>

<ParamField body="inpaint_full_res" type="boolean" default="false">
  If set to true, inpaint area will be the same resolution as the provided image. If set to false, inpaint area will stretch to fit the provided image. This parameter is required for inpainting.
</ParamField>

<ParamField body="inpaint_full_res_padding" type="integer" default="32">
  Padding around the masked object to inpaint in full resolution This parameter is required for inpainting.
</ParamField>

<ParamField body="inpainting_fill" type="integer" default="1">
  Determines how masked content should be displayed. It can be either `0`, `1`, `2`, or `3`. `0 -> “fill”`, `1 -> “original”`, `2 -> “latent noise”`, `3 -> “latent nothing”`
  This parameter is required for inpainting.
</ParamField>

<ParamField body="inpainting_mask_invert" type="integer" default="0">
  Determines whether you want to inpaint the masked object or outside of the masked object. 0 will inpaint the masked object. 1 will inpaint the region outside of the masked object. This parameter is required for inpainting.
</ParamField>

<ParamField body="resize_mode" type="integer" default="1">
  It can be either `0`, `1`, `2`, or `3`. `0 -> “just resize”`, `1 -> “crop and resize”`, `2 -> “resize”`, `3 -> “fill”`
  This parameter is required for inpainting.
</ParamField>

<ParamField body="image_cfg_scale" type="float" default="0.7">
  Determines how much the result resembles your starting image, so a lower value means a stronger effect. This is the exact opposite of cfg\_scale.
</ParamField>

<ParamField body="webhook" type="string">
  This is the callback url where you want to receive your response.
</ParamField>

<ParamField body="track_id" type="string">
  You can specify any value here to track the request that's received on your webhook's end.
</ParamField>

<ParamField body="seed" type="string" default="-1">
  This is the value that determines the output of a random number generator. You can get ALMOST the same image if you provide the same parameters and the seed.
</ParamField>

### Response

<ResponseField name="message" type="string">
  image generation in progress
</ResponseField>

<RequestExample>
  ```bash Example Request theme={null}
  curl --location "https://randomseed.lol/v1/sync/img2img" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer $RANDOMSEED_API_KEY" \
    --data '{
      "img2img": {
          "prompt": "Cute cat",
          "negative_prompt": "ugly, out of frame",
          "width": "512",
          "height": "512",
          "number_of_images": "1",
          "steps": "20",
          "cfg_scale": 7,
          "model_name": "realistic_vision_v3_inpainting",
          "sampler_name": "Euler a",
          "include_init_images": true,
          "image_strength": 0.8,
          "image_url": "...",
          "mask": "...",
          "inpaint_full_res": false,
          "inpaint_full_res_padding": 32,
          "inpainting_fill": 0,
          "inpainting_mask_invert": 0,
          "resize_mode": 0,
          "webhook": "...",
          "track_id": 1,
          "seed": "-1"
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "message": "image generation in progress",
    "result": {
      "id": "...", // request id you're going to use for polling if webhook url is not provided
      "status": "IN_QUEUE"
    }
  }
  ```
</ResponseExample>
