Edit image (image-to-image)
Generate a new image from one or more reference images + a text prompt.
Uses OpenAI-standard multipart/form-data with binary uploads. Multiple
references go in via repeated image[] fields; a single reference can
also use the image field.
Billing matches /v1/images/generations: settles on upstream
usage.input_tokens / output_tokens (reference images are billed as
image input).
Authorization
BearerAuth API key authentication (OpenAI format). Pass in the Authorization header:
Authorization: Bearer tr-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
In: header
Request Body
multipart/form-data
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
curl -X post "https://api.xrtoken.ai/v1/images/edits" \ -F model="gpt-image-2" \ -F prompt="replace the background with cherry blossoms" \ -F image="string"{
"created": 0,
"data": [
{
"url": "http://example.com",
"b64_json": "string"
}
],
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0
}
}{
"error": "model field is required",
"type": "invalid_request_error"
}{
"error": "invalid or missing API key",
"type": "auth_error"
}{
"error": "insufficient balance -- please top up or upgrade your plan",
"type": "billing_error"
}{
"error": "rate limit exceeded",
"type": "rate_limit_error"
}{
"error": "upstream provider error",
"type": "server_error"
}