编辑图像

在给定原始图像和提示的情况下创建编辑或扩展图像。

POST/v1/images/edits/

编辑图像

在给定原始图像和提示的情况下创建编辑或扩展图像。

鉴权: Bearer

请求体

Content-Type: multipart/form-data

字段类型必填说明
imagestring是要编辑的图像。必须是有效的 PNG 文件,小于 4MB,并且是方形的。如果未提供遮罩,图像必须具有透明度,将用作遮罩。
示例: "cmMtdXBsb2FkLTE2ODc4MzMzNDc3NTEtMjA=/31225951_59371037e9_small.png";格式: binary
maskstring附加图像,其完全透明区域(例如,alpha 为零的区域)指示image应编辑的位置。必须是有效的 PNG 文件,小于 4MB,并且尺寸与原始image相同。
示例: [];格式: binary
promptstring是所需图像的文本描述。最大长度为 1000 个字符。
示例: "A cute baby sea otter wearing a beret."
nstring要生成的图像数。必须介于 1 和 10 之间。
示例: "1"
sizestring生成图像的大小。必须是`256x256`、`512x512`或 `1024x1024`之一。
示例: "1024x1024"
response_formatstring生成的图像返回的格式。必须是`url`或`b64_json`。
示例: "url"
userstring代表您的最终用户的唯一标识符,可以帮助 OpenAI 监控和检测滥用行为。[了解更多](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids)。
示例: ""
modelstring示例: "dall-e-2"

示例代码

curl -X POST "https://api.nodeprice.com/v1/images/edits/" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{
  "image": "string",
  "mask": "string",
  "prompt": "string",
  "n": "string",
  "size": "string",
  "response_format": "string",
  "user": "string",
  "model": "string"
}'
const url = "https://api.nodeprice.com/v1/images/edits/";
const body = {
  "image": "string",
  "mask": "string",
  "prompt": "string",
  "n": "string",
  "size": "string",
  "response_format": "string",
  "user": "string",
  "model": "string"
};

const response = await fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
  },
  body: JSON.stringify(body)
});

console.log(await response.text());
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	url := "https://api.nodeprice.com/v1/images/edits/"
	body := strings.NewReader(`{
  "image": "string",
  "mask": "string",
  "prompt": "string",
  "n": "string",
  "size": "string",
  "response_format": "string",
  "user": "string",
  "model": "string"
}`)
	req, err := http.NewRequest("POST", url, body)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", "Bearer <token>")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	data, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(data))
}
import requests

url = "https://api.nodeprice.com/v1/images/edits/"

body = """{
  "image": "string",
  "mask": "string",
  "prompt": "string",
  "n": "string",
  "size": "string",
  "response_format": "string",
  "user": "string",
  "model": "string"
}"""

response = requests.request("POST", url, data=body, headers={
  "Content-Type": "application/json",
  "Authorization": "Bearer <token>"
})

print(response.text)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n"
    + "  \"image\": \"string\",\n"
    + "  \"mask\": \"string\",\n"
    + "  \"prompt\": \"string\",\n"
    + "  \"n\": \"string\",\n"
    + "  \"size\": \"string\",\n"
    + "  \"response_format\": \"string\",\n"
    + "  \"user\": \"string\",\n"
    + "  \"model\": \"string\"\n"
    + "}");
Request request = new Request.Builder()
    .url("https://api.nodeprice.com/v1/images/edits/")
    .method("POST", body)
    .addHeader("Content-Type", "application/json")
    .addHeader("Authorization", "Bearer <token>")
    .build();

Response response = client.newCall(request).execute();
System.out.println(response.body().string());
#include <stdio.h>
#include <curl/curl.h>

int main(void) {
    CURL *curl = curl_easy_init();
    if (curl == NULL) {
        return 1;
    }

    struct curl_slist *headers = NULL;
    headers = curl_slist_append(headers, "Content-Type: application/json");
    headers = curl_slist_append(headers, "Authorization: Bearer <token>");

    curl_easy_setopt(curl, CURLOPT_URL, "https://api.nodeprice.com/v1/images/edits/");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\n"
        + "  \"image\": \"string\",\n"
        + "  \"mask\": \"string\",\n"
        + "  \"prompt\": \"string\",\n"
        + "  \"n\": \"string\",\n"
        + "  \"size\": \"string\",\n"
        + "  \"response_format\": \"string\",\n"
        + "  \"user\": \"string\",\n"
        + "  \"model\": \"string\"\n"
        + "}");
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

    CURLcode code = curl_easy_perform(curl);
    if (code != CURLE_OK) {
        fprintf(stderr, "%s\n", curl_easy_strerror(code));
    }

    curl_slist_free_all(headers);
    curl_easy_cleanup(curl);
    return 0;
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var client = new HttpClient();
        var request = new HttpRequestMessage(HttpMethod.Post, "https://api.nodeprice.com/v1/images/edits/");
        request.Headers.Add("Authorization", "Bearer <token>");
        request.Content = new StringContent("{\n"
            + "  \"image\": \"string\",\n"
            + "  \"mask\": \"string\",\n"
            + "  \"prompt\": \"string\",\n"
            + "  \"n\": \"string\",\n"
            + "  \"size\": \"string\",\n"
            + "  \"response_format\": \"string\",\n"
            + "  \"user\": \"string\",\n"
            + "  \"model\": \"string\"\n"
            + "}", Encoding.UTF8, "application/json");

        var response = await client.SendAsync(request);
        Console.WriteLine(await response.Content.ReadAsStringAsync());
    }
}

响应

200 Response

Content-Type: application/json

无字段定义。