Image to Image API
Generate a new image from one to five reference images and a prompt, for example the same character in a new style. By default, Meshy removes the background, so the image is ready to use as the input for Image to 3D.
Moving from v1? The main changes for Image to Image:
remove_backgroundis replaced bybackground. The default istransparent, so Meshy removes the background unless you sendbackground: "opaque". A request withremove_backgroundreturns400.- The images are in
output.image_urls. - The
ai_modelandpromptyou sent are ininput.
This endpoint makes images. To make a 3D model of what's in an image, use Image to 3D. To make an object you can hold or print from a photo, for example a keychain or a figure, use the Creative Lab APIs.
Create an Image to Image task
Creates an Image to Image task and returns the task object. The task runs in the background. To read its result, see Get the result. For how long a task usually takes, see Processing times.

curl https://api.meshy.ai/openapi/v2/image-to-image \
-X POST \
-H "Authorization: Bearer ${MESHY_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"reference_image_urls": [
"https://cdn.meshy.ai/webapp-assets/doc/try-it/v2/inputs/santa.3dbe655f9980.jpg"
],
"ai_model": "nano-banana-2-1",
"prompt": "turn it into a knitted wool toy"
}'Parameters
- Name
- reference_image_urls
- Type
- string[]
- Required
- Description
Required unless you send
input_task_id. One to five images to work from, each a public URL or a data URI (data:image/png;base64,...). An empty array, or more than five images, returns400.Each image must be a JPG, JPEG, PNG, or WebP file of at most 20 MB, and at least 32 pixels on each side.
- Name
- input_task_id
- Type
- string
- Required
- Description
Required unless you send
reference_image_urls. The ID of a Text to Image or Image to Image task whose images to use as the references. The task must be one you created with the API and have the statusSUCCEEDED. If you send bothreference_image_urlsandinput_task_id, Meshy usesinput_task_id.Meshy uses every image the task produced. That's one image, or up to three for a multi-view task.
- Name
- ai_model
- Type
- string
- Required
- Description
The model that generates the image. Prices differ by model. See Pricing.
Try and previewAvailable values:
nano-banananano-banana-2nano-banana-2-litenano-banana-2-1: costs 4 credits per requestnano-banana-pro: needs a Pro plan or higher. On a lower plan, it returns402.gpt-image-2: OpenAI GPT Image 2gpt-image-2-5-flare: OpenAI GPT Image 2.5 (Flare)gpt-image-2-5-sunburst: OpenAI GPT Image 2.5 (Sunburst)gpt-image-2-6-flare: OpenAI GPT Image 2.6 (Flare)gpt-image-2-6-sunburst: OpenAI GPT Image 2.6 (Sunburst)
- Name
- prompt
- Type
- string
- Required
- Description
Text that describes what to make from the reference images, for example
turn it into a clay figurine.Try and preview
- Name
- aspect_ratio
- Type
- string
- default 1:1
- Description
The shape of the image.
Try and previewAvailable values:
1:116:99:164:33:43:2: GPT Image models only2:3: GPT Image models only
With a
nano-bananamodel,3:2and2:3return400. You can't sendaspect_ratiowithgenerate_multi_view: true. Sending both returns400.The result doesn't follow the shape of the reference images. To match them, set
aspect_ratioto their shape.
- Name
- background
- Type
- string
- default transparent
- Description
The background of the image.
Available values:
transparent: Meshy removes the background and returns a transparent PNG.opaque: Meshy returns the image with the background it was generated with.
With
generate_multi_view: true, every view has a transparent background. Sendingopaquewith it returns400.
- Name
- generate_multi_view
- Type
- boolean
- default false
- Description
Whether to generate the subject from the front, the side, and the back.
truereturns each view as a separate image with a transparent background inoutput.image_urls, andfalsereturns one image.Try and preview
Returns
202 Accepted with the task object. The task starts as PENDING, with your request in input and output set to null.
Two response headers help you read the task:
Location: the task's URL on TasksRetry-After: how many seconds to wait before you first read it
Failure modes
- Name
400 - Bad Request- Description
The request can't run. For example:
ai_modelorpromptis missing- Neither
reference_image_urlsnorinput_task_idwas sent - A reference image can't be downloaded or isn't a supported image. The code is
input_download_failedorinput_file_invalid, and the message names the image, for examplereference_image_urls[1], and says why. - The input task hasn't succeeded, or isn't a Text to Image or Image to Image task
ai_modelisn't a supported modelaspect_ratiowas sent withgenerate_multi_view: true(aspect_ratio cannot be set when generate_multi_view is true)background: "opaque"was sent withgenerate_multi_view: true(background cannot be opaque when generate_multi_view is true)3:2or2:3was sent for anano-bananamodel
The error message says which problem it found. See Errors.
- Name
401 - Unauthorized- Description
The API key is missing or invalid. Check the
Authorizationheader.
- Name
402 - Payment Required- Description
One of these applies:
- The account doesn't have enough credits.
- The account reached a credit limit.
- The account is on the free plan.
- The request uses
nano-banana-proon a plan below Pro.
Check your credits and plan, then retry.
- Name
404 - Not Found- Description
input_task_iddoesn't match any of your tasks. The message isinput_task_id does not match any of your tasks. A task you deleted also returns404.For a task past its retention period, the code is
input_task_expired. Create the input task again, and send the new task'sid.
- Name
429 - Too Many Requests- Description
One of these limits was reached:
- You sent too many requests. Wait the number of seconds in
Retry-After, then retry. - Too many of your tasks are queued or running. Wait for some to finish, then retry.
- On an unlimited plan with no credits left, you reached the number of tasks that can run without credits. Wait for a task to finish, or add credits.
- You sent too many requests. Wait the number of seconds in
Get the result
Read Image to Image tasks the same way as every other v2 task, through the Tasks routes. To list only Image to Image tasks, filter by type=image-to-image. The filter includes multi-view tasks.
| To | Call |
|---|---|
| Get one task | GET /openapi/v2/tasks/{id} |
| Wait for updates | GET /openapi/v2/tasks/{id}/stream or a webhook |
| List your tasks | GET /openapi/v2/tasks?type=image-to-image |
| Delete a task | DELETE /openapi/v2/tasks/{id} |
Image to Image output
When the task succeeds, output holds this field. The rest of the task object is the same for every task type. The URLs in output stop working at expires_at.
curl https://api.meshy.ai/openapi/v2/tasks/01a157e1-35e3-7778-9a40-d3618286eb3e \
-H "Authorization: Bearer ${MESHY_API_KEY}"Loading…- Name
- image_urls
- Type
- string[]
- Description
Signed URLs to the generated PNG images:
- A single image: one URL. With
background: "transparent", Meshy removes the image's background. If it can't, the task still succeeds, and the image keeps its background. - With
generate_multi_view: true: one URL per view, usually three, each with a transparent background. If Meshy can't separate every view, it returns fewer, and the task still succeeds.
- A single image: one URL. With
If the model provider's safety check declines the prompt or a reference image, the task fails. Its task_error has the type invalid_input and the code provider_content_refused. Change the prompt or the reference images, then create another task. See Errors.