Skip to content
中文

Create image edit

POST/model/v1/images/edits● Supported

Official docs ↗

Request body

  • modelstringrequired

    Image model id; list candidates with listModels?type=image. Router support (supported): Verified to take effect.

    Verified to take effect.

  • promptstringrequired

    Text description of the desired edit. Router support (supported): Verified to take effect.

    Verified to take effect.

  • imagearrayrequired

    Source images as base64 data URLs.

  • maskstringoptional○ Unsupported

    Mask that marks the region to edit, as a base64 data URL or multipart file. Router support (unsupported): The tested PNG mask returns 400 and is currently unusable.

    The tested PNG mask returns 400 and is currently unusable.

  • nnumberoptional

    Number of edited images to generate. Router support (supported): Verified to take effect.

    Verified to take effect.

  • sizestringoptional

    Size of the edited images. Router support (supported): Verified to take effect.

    Verified to take effect.

  • image[]arrayoptional

    Source images, uploaded as multipart files. Router support (supported): Accepts multipart files or JSON data URLs.

    Accepts multipart files or JSON data URLs.

Returns

200

Platform errors (auth, rate limits, validation) and OCR errors use problem+json; other model call errors follow the endpoint's own format (OpenAI or Anthropic) — see error codes

Request

curl
curl https://api.deepraxis.com/model/v1/images/edits \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-image-2","prompt":"给这只猫戴一顶帽子","image":["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="],"quality":"low"}'
Python
import requests

opts = dict(
    base_url="https://api.deepraxis.com/model/v1",
    api_key="$PRAXIS_API_KEY",
)

# 官方 SDK 的 images.edit 只收文件上传;这里用 JSON 体(图像为 data URL)直接调用
resp = requests.post(
    f"{opts['base_url']}/images/edits",
    headers={"Authorization": f"Bearer {opts['api_key']}"},
    json={
        "model": "gpt-image-2",
        "prompt": "给这只猫戴一顶帽子",
        "image": ["data:image/png;base64,iVBORw0KGgo..."],
        "quality": "low",
    },
)
print(resp.json())
TypeScript
const opts = {
  baseURL: "https://api.deepraxis.com/model/v1",
  apiKey: "$PRAXIS_API_KEY",
};

// 官方 SDK 的 images.edit 只收文件上传;这里用 JSON 体(图像为 data URL)直接调用
const resp = await fetch(`${opts.baseURL}/images/edits`, {
  method: "POST",
  headers: { Authorization: `Bearer ${opts.apiKey}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    model: "gpt-image-2",
    prompt: "给这只猫戴一顶帽子",
    image: ["data:image/png;base64,iVBORw0KGgo..."],
    quality: "low",
  }),
});
console.log(await resp.json());

Response 200

{
  "created": 1790305663,
  "background": "opaque",
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAABOYAAATmCAIAAAAKnjl9AABJ+mNhQlgAAEn6anVt…(采样时截断:原图 base64 共 3434532 字符,此处保留前 64)"
    }
  ],
  "output_format": "png",
  "quality": "low",
  "size": "1254x1254",
  "usage": {
    "input_tokens": 17,
    "input_tokens_details": {
      "image_tokens": 1,
      "text_tokens": 16
    },
    "output_tokens": 229,
    "output_tokens_details": {
      "image_tokens": 229,
      "text_tokens": 0
    },
    "total_tokens": 246
  }
}

Response

HTTP 200

Edited images

application/json

Name Type Description
created number Unix time in seconds at which the images were created.
data array<object> Edited images.
data[].url string URL of the image; present when response_format is url.
data[].b64_json string Base64-encoded image; present when response_format is b64_json.