Text to Image API
Generate an image from a text prompt. 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 Text 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 a Text to Image task
Creates a Text 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/text-to-image \
-X POST \
-H "Authorization: Bearer ${MESHY_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"prompt": "a stylized cartoon explorer with short brown hair, wearing an orange jacket, beige cargo pants and brown boots, full body, standing",
"ai_model": "nano-banana-2-1"
}'Parameters
- 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 the image to generate.
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.
- 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
- Name
- pose_mode
- Type
- string
- Description
The pose for a standing character,
a-poseort-pose. Leave it out for no pose.With a
nano-bananamodel, a posed image is always3:4, whatever you send asaspect_ratio. The GPT Image models keep youraspect_ratio.With
nano-bananaornano-banana-pro, a pose needs a Pro plan or higher. On a lower plan, the request returns402.
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 missingai_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-pro, orpose_modewithnano-banana, on a plan below Pro.
Check your credits and plan, then retry.
- 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 Text to Image tasks the same way as every other v2 task, through the Tasks routes. To list only Text to Image tasks, filter by type=text-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=text-to-image |
| Delete a task | DELETE /openapi/v2/tasks/{id} |
Text 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/01a15c67-e9da-7034-b4c1-e9608ec9b284 \
-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, the task fails. Its task_error has the type invalid_input and the code provider_content_refused. Change the prompt, then create another task. See Errors.