true로 설정하면 생성된 이미지는 배경이 제거된 투명한 RGBA PNG로 반환되어, 피사체를 원하는 배경에 합성할 수 있습니다.
반환값
응답의 result 속성은 새로 생성된 텍스트로 이미지 작업의 작업 id를 포함합니다.
실패 모드
Name
400 - Bad Request
Description
요청이 수용할 수 없는 상태입니다. 일반적인 원인:
파라미터 누락: 필수 파라미터(예: ai_model, prompt)가 누락되었습니다.
잘못된 파라미터: ai_model 또는 aspect_ratio가 허용된 값 중 하나가 아닙니다.
충돌: generate_multi_view와 aspect_ratio는 동시에 사용할 수 없습니다.
Name
401 - Unauthorized
Description
인증에 실패했습니다. API 키를 확인하세요.
Name
402 - Payment Required
Description
이 작업을 수행하기에 충분한 크레딧이 없습니다.
Name
429 - Too Many Requests
Description
속도 제한을 초과했습니다.
Request
POST
/openapi/v1/text-to-image
# Generate an image from a text promptcurlhttps://api.meshy.ai/openapi/v1/text-to-image \-XPOST \-H"Authorization: Bearer ${YOUR_API_KEY}" \-H'Content-Type: application/json' \-d'{ "ai_model": "nano-banana", "prompt": "A majestic dragon soaring through clouds at sunset", "aspect_ratio": "16:9" }'
{"id":"018a210d-8ba4-705c-b111-1f1776f7f578","type":"text-to-image","ai_model":"nano-banana","prompt":"A majestic dragon soaring through clouds at sunset","status":"SUCCEEDED","progress":100,"created_at":1692771650657,"started_at":1692771667037,"finished_at":1692771669037,"expires_at":1692771679037,"image_urls": ["https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/image.png?Expires=***" ]}
텍스트로 이미지 작업 객체는 텍스트 prompt 입력으로부터 이미지를 생성하기 위해 Meshy가 추적하는 작업 단위입니다.
이 객체는 다음과 같은 속성을 가지고 있습니다:
속성
Name
id
Type
string
Description
작업의 고유 식별자입니다. 우리는 작업 ID에 대해 k-sortable UUID를 구현 세부사항으로 사용하지만, ID의 형식에 대해 어떠한 가정도 하지 않아야 합니다.
Name
type
Type
string
Description
이미지 생성 작업의 유형입니다. 텍스트로 이미지 작업의 경우, 항상 text-to-image가 됩니다.
Name
ai_model
Type
string
Description
이 작업에 사용된 AI 모델입니다. 가능한 값은 nano-banana, nano-banana-2, nano-banana-pro, 또는 gpt-image-2입니다.
Name
prompt
Type
string
Description
이미지를 생성하는 데 사용된 텍스트 prompt입니다.
Name
status
Type
string
Description
작업의 상태입니다. 가능한 값은 PENDING, IN_PROGRESS, SUCCEEDED, FAILED, CANCELED 중 하나입니다.
Name
progress
Type
integer
Description
작업의 진행 상황입니다. 작업이 아직 시작되지 않은 경우, 이 속성은 0이 됩니다. 작업이 성공하면, 이는 100이 됩니다.
Name
created_at
Type
timestamp
Description
작업이 생성된 시각의 타임스탬프입니다. 밀리초 단위입니다.
타임스탬프는 1970년 1월 1일 UTC 이후 경과된 밀리초 수를 나타내며, RFC 3339 표준을 따릅니다.
예를 들어, 2023년 9월 1일 금요일 오후 12:00:00 GMT는 1693569600000으로 표현됩니다. 이는 Meshy API의 모든 타임스탬프에 적용됩니다.
Name
started_at
Type
timestamp
Description
작업이 시작된 시각의 타임스탬프입니다. 밀리초 단위입니다. 작업이 아직 시작되지 않은 경우, 이 속성은 0이 됩니다.
Name
finished_at
Type
timestamp
Description
작업이 완료된 시각의 타임스탬프입니다. 밀리초 단위입니다. 작업이 아직 완료되지 않은 경우, 이 속성은 0이 됩니다.
Name
expires_at
Type
timestamp
Description
작업 결과가 만료되는 시각의 타임스탬프입니다. 밀리초 단위입니다.
Name
preceding_tasks
Type
integer
Description
이전 작업의 수입니다.
이 필드의 값은 작업 상태가 PENDING일 때만 의미가 있습니다.
Name
image_urls
Type
array
Description
생성된 이미지의 다운로드 가능한 URL 배열입니다. generate_multi_view가 활성화된 경우, 이 배열은 서로 다른 시점의 세 가지 이미지 URL을 포함합니다. 그렇지 않으면, 단일 이미지 URL을 포함합니다.
Name
task_error
Type
object
Description
실패한 작업에 대한 오류 세부사항입니다. 전체 task_error 객체 참조는 오류를 참조하세요.
Name
consumed_credits
Type
integer
Description
이 작업에 소비된 크레딧의 수입니다. 작업 상태가 PENDING, IN_PROGRESS, 또는 SUCCEEDED일 때 나타납니다. FAILED 작업의 경우 0을 반환합니다 (실패 시 크레딧이 환불됩니다).
예제 텍스트로 이미지 작업 객체
{"id":"018a210d-8ba4-705c-b111-1f1776f7f578","type":"text-to-image","ai_model":"nano-banana","prompt":"A majestic dragon soaring through clouds at sunset","status":"SUCCEEDED","progress":100,"created_at":1692771650657,"started_at":1692771667037,"finished_at":1692771669037,"expires_at":1692771679037,"preceding_tasks":0,"image_urls": ["https://assets.meshy.ai/***/tasks/018a210d-8ba4-705c-b111-1f1776f7f578/output/image.png?Expires=***" ],"task_error": {"message":"" },"consumed_credits":3}