Skip to main content

Endpoint

POST /api/images/edit
Edit an existing image using a text prompt. The request blocks until the edited image is ready.

Request Parameters

ParameterTypeRequiredDefaultDescription
modelstringyesImage editing model (e.g. qwen-image-edit, nano-banana-2-edit, xai-grok-imagine-image-edit)
promptstringyesDescription of the edit to apply.
input_imagestring (URL)yesURL of the image to edit. Must be publicly accessible.
response_formatstringno"url""url" returns a hosted URL. "b64_json" returns base64-encoded image bytes inline.
target_namespacestringnocurrent userNamespace to save results and bill to. Can be an organization name.

Examples

Basic edit

import requests

response = requests.post(
    "https://hub.oxen.ai/api/images/edit",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
    },
    json={
        "model": "qwen-image-edit",
        "prompt": "Make the background blue",
        "input_image": "https://example.com/my-photo.jpg",
    },
)

data = response.json()
print("Image URL:", data["images"][0]["url"])

Response

Same format as /images/generate:
{
  "model": "qwen-image-edit",
  "created": 1775090400,
  "images": [
    {
      "url": "https://hub.oxen.ai/api/repos/.../files/.../image.png?..."
    }
  ]
}

Errors

ConditionError
Image URL not accessible"... 403 Client Error: Forbidden for url: ..."
Model not found"Model not found: <name>"
The input_image URL must be publicly downloadable. URLs that require authentication or block automated access will fail.