创建任务 stability-ai/stable-diffusion-img2img

POST /replicate/v1/predictions

MethodPOST
Path/replicate/v1/predictions
Typehttp
Status1
Module2102810
Folder62419371

说明

概览

MethodPOST
Path/replicate/v1/predictions
Typehttp
Status1
Module2102810
Folder62419371

参数

{
  "query": [],
  "path": [],
  "cookie": [],
  "header": [
    {
      "required": false,
      "description": "",
      "type": "string",
      "id": "GTujCrB2It",
      "enable": true,
      "name": "Authorization",
      "sampleValue": "Bearer {{YOUR_API_KEY}}"
    }
  ]
}

请求体

{
  "type": "application/json",
  "parameters": [],
  "jsonSchema": {
    "type": "object",
    "properties": {
      "input": {
        "type": "object",
        "properties": {
          "image": {
            "type": "string",
            "description": "生成变化的初始图像。"
          },
          "prompt": {
            "type": "string",
            "description": "输入提示。"
          },
          "scheduler": {
            "type": "string"
          },
          "num_outputs": {
            "type": "integer",
            "description": "输出图像数量。输出数量过多可能会导致内存不足。默认值:1。最小值:1,最大值:8。"
          },
          "guidance_scale": {
            "type": "number",
            "description": "无分类器引导尺度。默认值:7.5。最小值:1,最大值:20。"
          },
          "prompt_strength": {
            "type": "number",
            "description": "提供图像时提示强度。1.0 对应于完全销毁初始图像中的信息。默认值:0.8。"
          },
          "num_inference_steps": {
            "type": "integer",
            "description": "去噪步骤数。默认值:25。最小值:1,最大值:500。"
          }
        },
        "required": [
          "image"
        ],
        "x-apifox-orders": [
          "image",
          "prompt",
          "scheduler",
          "num_outputs",
          "guidance_scale",
          "prompt_strength",
          "num_inference_steps"
        ]
      }
    },
    "x-apifox-orders": [
      "input"
    ]
  },
  "mediaType": "",
  "examples": [
    {
      "value": "{\n      \"version\": \"stability-ai/stable-diffusion-img2img:15a3689ee13b0d2616e98820eca31d4c3abcd36672df6afce5cb6feb1d66087d\",\n    \"input\": {\n      \"image\": \"https://replicate.delivery/pbxt/HtKMvJSvuGWDn2B35mM396QGzcrgCNkcgSko8JxtXux4aX9H/sketch-mountains-input.jpeg\",\n      \"prompt\": \"A fantasy landscape, trending on artstation\",\n      \"scheduler\": \"DPMSolverMultistep\",\n      \"num_outputs\": 1,\n      \"guidance_scale\": 7.5,\n      \"prompt_strength\": 0.8,\n      \"num_inference_steps\": 25\n    }\n  }",
      "mediaType": "application/json",
      "description": ""
    }
  ],
  "oasExtensions": ""
}

响应

[
  {
    "id": 728570704,
    "name": "成功",
    "code": 200,
    "contentType": "json",
    "jsonSchema": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "model": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "input": {
          "type": "object",
          "properties": {
            "aspect_ratio": {
              "type": "string"
            },
            "input_image": {
              "type": "string"
            },
            "output_format": {
              "type": "string"
            },
            "prompt": {
              "type": "string"
            },
            "prompt_upsampling": {
              "type": "boolean"
            },
            "safety_tolerance": {
              "type": "integer"
            }
          },
          "required": [
            "aspect_ratio",
            "input_image",
            "output_format",
            "prompt",
            "prompt_upsampling",
            "safety_tolerance"
          ]
        },
        "logs": {
          "type": "string"
        },
        "output": {
          "type": "null"
        },
        "data_removed": {
          "type": "boolean"
        },
        "error": {
          "type": "null"
        },
        "status": {
          "type": "string"
        },
        "created_at": {
          "type": "string"
        },
        "urls": {
          "type": "object",
          "properties": {
            "cancel": {
              "type": "string"
            },
            "get": {
              "type": "string"
            },
            "stream": {
              "type": "string"
            },
            "web": {
              "type": "string"
            }
          },
          "required": [
            "cancel",
            "get",
            "stream",
            "web"
          ]
        }
      },
      "required": [
        "id",
        "model",
        "version",
        "input",
        "logs",
        "output",
        "data_removed",
        "error",
        "status",
        "created_at",
        "urls"
      ]
    },
    "itemSchema": {},
    "description": "",
    "mediaType": "",
    "headers": [],
    "oasExtensions": ""
  }
]

响应示例

[
  {
    "name": "Create image",
    "responseId": 728570704,
    "data": "{\n    \"created\": 1589478378,\n    \"data\": [\n        {\n            \"url\": \"https://...\"\n        },\n        {\n            \"url\": \"https://...\"\n        }\n    ]\n}",
    "description": "",
    "oasKey": "",
    "oasExtensions": "",
    "id": 648848354
  },
  {
    "name": "成功示例",
    "responseId": 728570704,
    "data": "{\n    \"id\": \"w44zs9cet5rmc0cqzp49gpkhf8\",\n    \"model\": \"black-forest-labs/flux-kontext-dev\",\n    \"version\": \"hidden\",\n    \"input\": {\n        \"aspect_ratio\": \"match_input_image\",\n        \"input_image\": \"https://replicate.delivery/xezq/XfwWjHJ7HfrmXE6ukuLVEpXWfeQ3PQeRI5mApuLXRxST7XMmC/tmpc91tlq20.png\",\n        \"output_format\": \"jpg\",\n        \"prompt\": \"Make the letters 3D, floating in space on a city street\",\n        \"prompt_upsampling\": false,\n        \"safety_tolerance\": 2\n    },\n    \"logs\": \"\",\n    \"output\": null,\n    \"data_removed\": false,\n    \"error\": null,\n    \"status\": \"starting\",\n    \"created_at\": \"2025-07-12T07:27:54.577Z\",\n    \"urls\": {\n        \"cancel\": \"https://api.replicate.com/v1/predictions/w44zs9cet5rmc0cqzp49gpkhf8/cancel\",\n        \"get\": \"https://api.replicate.com/v1/predictions/w44zs9cet5rmc0cqzp49gpkhf8\",\n        \"stream\": \"https://stream.replicate.com/v1/files/bcwr-h7bu76ujftxzwih5u35puoysogps56mqvpvjz4nrxskhfe7ks42a\",\n        \"web\": \"https://replicate.com/p/w44zs9cet5rmc0cqzp49gpkhf8\"\n    }\n}",
    "description": "",
    "oasKey": "",
    "oasExtensions": "",
    "id": 648848355
  }
]