跳转到主要内容
POST
/
v1
/
images
/
edits
编辑图片
curl --request POST \
  --url https://smew.ai/v1/images/edits \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gpt-image-2",
  "prompt": "<string>",
  "images": [
    {
      "image_url": "<string>"
    }
  ],
  "size": "1024x1024",
  "response_format": "url"
}
'
import requests

url = "https://smew.ai/v1/images/edits"

payload = {
    "model": "gpt-image-2",
    "prompt": "<string>",
    "images": [{ "image_url": "<string>" }],
    "size": "1024x1024",
    "response_format": "url"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    model: 'gpt-image-2',
    prompt: '<string>',
    images: [{image_url: '<string>'}],
    size: '1024x1024',
    response_format: 'url'
  })
};

fetch('https://smew.ai/v1/images/edits', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://smew.ai/v1/images/edits",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'model' => 'gpt-image-2',
    'prompt' => '<string>',
    'images' => [
        [
                'image_url' => '<string>'
        ]
    ],
    'size' => '1024x1024',
    'response_format' => 'url'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

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

func main() {

	url := "https://smew.ai/v1/images/edits"

	payload := strings.NewReader("{\n  \"model\": \"gpt-image-2\",\n  \"prompt\": \"<string>\",\n  \"images\": [\n    {\n      \"image_url\": \"<string>\"\n    }\n  ],\n  \"size\": \"1024x1024\",\n  \"response_format\": \"url\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://smew.ai/v1/images/edits")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"gpt-image-2\",\n  \"prompt\": \"<string>\",\n  \"images\": [\n    {\n      \"image_url\": \"<string>\"\n    }\n  ],\n  \"size\": \"1024x1024\",\n  \"response_format\": \"url\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://smew.ai/v1/images/edits")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"gpt-image-2\",\n  \"prompt\": \"<string>\",\n  \"images\": [\n    {\n      \"image_url\": \"<string>\"\n    }\n  ],\n  \"size\": \"1024x1024\",\n  \"response_format\": \"url\"\n}"

response = http.request(request)
puts response.read_body
{
  "created": 1712345678,
  "data": [
    {
      "b64_json": "iVBORw0KGgo..."
    }
  ]
}
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "Invalid request body."
  }
}
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "Invalid request body."
  }
}

授权

Authorization
string
header
必填

Paste your SmewAI API key as a Bearer token.

请求体

model
enum<string>
必填
可用选项:
gpt-image-2
prompt
string
必填
images
object[]
必填
mask
object
size
string
示例:

"1024x1024"

response_format
enum<string>
默认值:url
可用选项:
url,
b64_json

响应

Edit accepted

created
integer
data
object[]