텍스트로 이미지 API
Meshy의 AI 모델을 사용하여 텍스트 prompt로부터 이미지를 생성하세요.
텍스트로 이미지는 이미지를 만듭니다. 이미지에 담긴 내용을 3D 모델로 만들려면 이미지로 3D를 사용하세요. 손에 들거나 출력할 수 있는 객체를 사진으로부터 만들려면 Creative Lab API를 사용하세요. 이 API는 먼저 프로토타입 이미지를 만든 다음, 이를 기반으로 3D 모델을 빌드합니다. 예를 들어 키링, 냉장고 자석, 피규어, 램프, 또는 키캡 등이 있습니다.
텍스트로 이미지 작업 생성
텍스트로 이미지 작업을 생성합니다. 이 작업은 백그라운드에서 실행됩니다. 작업이 일반적으로 걸리는 시간에 대해서는 처리 시간을 참고하세요.
Request
# Generate an image from a text prompt
curl https://api.meshy.ai/openapi/v1/text-to-image \
-X POST \
-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"
}'
Response
{
"result": "018a210d-8ba4-705c-b111-1f1776f7f578"
}
파라미터
- Name
- ai_model
- Type
- string
- 필수
- Description
이미지를 생성하는 AI 모델입니다. 모델에 따라 가격이 다릅니다. 가격은 요금을 참고하세요.
사용 가능한 값:
nano-banana: 표준 모델nano-banana-2:nano-banana보다 더 강력한 모델nano-banana-2-lite:nano-banana-2의 라이트 버전nano-banana-2-1: Nano Banana 2.1nano-banana-pro: 더 높은 품질의 Pro 모델입니다. Pro 플랜 이상이 필요합니다. 더 낮은 플랜에서는402를 반환합니다.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)
- Name
- prompt
- Type
- string
- 필수
- Description
생성할 이미지를 설명하는 텍스트입니다. 자세한 설명일수록 더 좋은 결과를 얻을 수 있습니다.
- Name
- generate_multi_view
- Type
- boolean
- 기본값 false
- Description
여러 각도에서 피사체를 보여주는 멀티뷰 이미지를 생성할지 여부입니다. 이 값이
true이면aspect_ratio를 보낼 수 없습니다. 둘 다 보내면400을 반환합니다.
- Name
- pose_mode
- Type
- string
- Description
캐릭터의 포즈로,
a-pose또는t-pose입니다. 포즈를 지정하지 않으려면 생략하세요.포즈가 작동하는 방식은
ai_model에 따라 다릅니다:nano-banana-2,nano-banana-2-lite,nano-banana-2-1: Meshy는 선택한 모델을 그대로 사용합니다. 이미지는 항상3:4이며, Meshy는aspect_ratio를 무시합니다.nano-banana,nano-banana-pro: Meshy는nano-banana-pro로 이미지를 생성하므로, 작업의ai_model은nano-banana-pro로 반환됩니다. 이 경우 Pro 플랜 이상이 필요합니다. 이미지는 항상3:4이며, Meshy는aspect_ratio를 무시합니다.- GPT Image 모델(
gpt-image-2,gpt-image-2-5-flare,gpt-image-2-5-sunburst): Meshy는 선택한 모델과aspect_ratio를 그대로 사용합니다.
- Name
- aspect_ratio
- Type
- string
- 기본값 1:1
- Description
이미지의 형태입니다. 보낼 수 있는 값은
ai_model에 따라 다릅니다.사용 가능한 값:
1:1: 정사각형16:9: 와이드스크린 가로형9:16: 와이드스크린 세로형4:3: 표준 가로형3:4: 표준 세로형3:2: 가로형, GPT Image 모델 전용2:3: 세로형, GPT Image 모델 전용
nano-banana계열 모델(nano-banana,nano-banana-2,nano-banana-2-lite,nano-banana-2-1,nano-banana-pro)은3:2와2:3에 대해400을 반환합니다.
- Name
- remove_background
- Type
- boolean
- 기본값 false
- Description
이미지의 배경을 제거할지 여부입니다.
true이면 투명한 RGBA PNG를 반환하므로, 피사체를 원하는 배경 위에 배치할 수 있습니다.
반환 값
응답의 result 필드에는 새로 생성된 텍스트로 이미지 작업의 ID가 담깁니다.
실패 모드
- Name
400 - Bad Request- Description
요청을 실행할 수 없습니다. 오류 메시지에 발견된 문제가 표시됩니다. 예를 들면:
- 파라미터 누락:
ai_model또는prompt와 같은 필수 파라미터가 누락되었습니다. - 잘못된 파라미터:
ai_model또는aspect_ratio가 허용된 값이 아닙니다. - 충돌:
aspect_ratio가generate_multi_view: true와 함께 전송되었습니다.
요청을 수정한 후 다시 전송하세요. 오류를 참고하세요.
- 파라미터 누락:
- Name
401 - Unauthorized- Description
API 키가 없거나 유효하지 않습니다.
Authorization헤더를 확인하세요.
- Name
402 - Payment Required- Description
계정이 이 작업을 실행할 수 없습니다. 예를 들면:
- 무료 플랜: 작업을 생성하려면 유료 플랜이 필요합니다. 구독 설정에서 플랜을 업그레이드한 후 다시 시도하세요.
- 크레딧 부족: 계정에 이 작업을 수행할 충분한 크레딧이 없거나(
Insufficient funds), 계정이 크레딧 한도에 도달했습니다. - 플랜 필요: 요청이 Pro 미만 플랜에서
nano-banana-pro를 사용했거나,nano-banana와 함께pose_mode를 사용했습니다(Only Pro and above users can use nano-banana-pro또는Only Pro and above users can use A/T pose feature (requires nano-banana-pro)).
크레딧 잔액과 플랜을 확인한 후 다시 시도하세요.
- Name
429 - Too Many Requests- Description
속도 제한을 초과했습니다. 잠시 기다린 후 다시 시도하세요. 속도 제한을 참고하세요.
Text to Image 작업 조회
ID로 Text to Image 작업을 조회합니다.
Request
curl https://api.meshy.ai/openapi/v1/text-to-image/018a210d-8ba4-705c-b111-1f1776f7f578 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
{
"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=***"
]
}
텍스트로 이미지 작업 삭제
텍스트로 이미지 작업을 이미지와 데이터를 포함하여 영구적으로 삭제합니다. 삭제는 취소할 수 없습니다.
Request
curl --request DELETE \
--url https://api.meshy.ai/openapi/v1/text-to-image/018a210d-8ba4-705c-b111-1f1776f7f578 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
// 200 OK on success, with an empty body.
//
// 409 Conflict when the task is IN_PROGRESS. The task keeps running:
{
"message": "Task is IN_PROGRESS and cannot be deleted. Credits for a task the worker has already started are not refundable; wait for it to reach SUCCEEDED, FAILED or CANCELED, then delete it."
}
경로 매개변수
- Name
- id
- Type
- path
- Description
삭제할 작업의 ID입니다.
작업 상태
PENDING 상태의 작업을 삭제하면 작업을 생성할 때 사용된 크레딧이 환불됩니다.
IN_PROGRESS 상태의 작업은 삭제할 수 없습니다. 요청은 409 Conflict를 반환하며,
작업은 계속 실행됩니다. Meshy는 이미 시작된 작업에 대해서는 환불하지 않으므로,
해당 작업을 삭제하면 크레딧과 결과물을 모두 잃게 됩니다. 작업이 SUCCEEDED,
FAILED, CANCELED 상태에 도달할 때까지 기다린 후 삭제하세요.
최종 상태(SUCCEEDED, FAILED, 또는 CANCELED)인 작업을 삭제해도
크레딧은 환불되지 않습니다.
반환 값
작업이 삭제되면 200 OK를, 작업이 IN_PROGRESS 상태이면 409 Conflict를
반환합니다.
Text to Image 작업 목록 조회
사용자의 Text to Image 및 Image to Image 작업 목록을 반환합니다. 각 작업의 type 필드는 둘 중 어느 쪽인지를 나타냅니다.
Request
curl https://api.meshy.ai/openapi/v1/text-to-image?page_size=10 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response
[
{
"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=***"
]
}
]
매개변수
- Name
- page_num
- Type
- integer
- Description
반환할 페이지 번호입니다.
1부터 시작하며 기본값은1입니다.
- Name
- page_size
- Type
- integer
- Description
페이지당 작업 수이며, 최대
100까지 가능합니다. 기본값은10입니다.
- Name
- sort_by
- Type
- string
- Description
정렬 순서입니다.
사용 가능한 값:
+created_at: 오래된 순-created_at: 최신 순
반환 값
Text to Image 작업 객체와 동일한 형식의 페이지네이션된 작업 객체 목록입니다.
텍스트로 이미지 작업 스트리밍
텍스트로 이미지 작업의 업데이트를 Server-Sent Events(SSE)로 스트리밍합니다.
Request
curl -N https://api.meshy.ai/openapi/v1/text-to-image/018a210d-8ba4-705c-b111-1f1776f7f578/stream \
-H "Authorization: Bearer ${YOUR_API_KEY}"
Response Stream
// Error event example
event: error
data: {
"status_code": 404,
"message": "Task not found"
}
// Message event examples illustrate task progress.
// These examples are shortened. Each event holds the full task object.
event: message
data: {
"id": "018a210d-8ba4-705c-b111-1f1776f7f578",
"progress": 0,
"status": "PENDING"
}
event: message
data: {
"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=***"
]
}
매개변수
- Name
- id
- Type
- path
- Description
생성 응답에서 받은 작업 ID입니다.
반환값
텍스트로 이미지 작업 객체의 스트림을 Server-Sent Events로 반환합니다.
각 이벤트는 Get 엔드포인트가 반환하는 것과 동일한 형태로 전체 작업 객체를 담고 있습니다. 작업이 PENDING 또는 IN_PROGRESS 상태인 동안에는 결과 필드에 아직 값이 없습니다.
Text to Image 작업 객체
Text to Image 작업 객체는 텍스트 prompt로부터 하나의 이미지 생성을 설명합니다. 여기에는 상태, progress, 그리고 작업이 성공했을 때의 이미지 URL이 담겨 있습니다.
속성
Example Text to Image Task Object
{
"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=***"
],
"task_error": null,
"consumed_credits": 3
}
- Name
- id
- Type
- string
- Description
작업 ID입니다. 불투명한 문자열로 취급하고 형식에 의존하지 마세요.
- Name
- type
- Type
- string
- Description
작업 유형으로, 항상
text-to-image입니다.
- Name
- ai_model
- Type
- string
- Description
작업에 사용된 AI 모델입니다.
가능한 값:
nano-banananano-banana-2nano-banana-2-litenano-banana-2-1nano-banana-progpt-image-2gpt-image-2-5-flaregpt-image-2-5-sunburst
- 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
작업이 생성된 시각으로, 밀리초 단위의 유닉스 시간입니다.
- Name
- started_at
- Type
- timestamp
- Description
작업이 시작된 시각으로, 밀리초 단위의 유닉스 시간입니다. 작업이 시작되기 전까지는 존재하지 않습니다.
- Name
- finished_at
- Type
- timestamp
- Description
작업이 종료된 시각으로, 밀리초 단위의 유닉스 시간입니다. 작업이 종료되기 전까지는 존재하지 않습니다.
- Name
- expires_at
- Type
- timestamp
- Description
작업 결과가 만료되는 시각으로, 밀리초 단위의 유닉스 시간입니다. 작업이 종료되기 전까지는 존재하지 않습니다.
- Name
- preceding_tasks
- Type
- integer
- Description
대기열에서 이 작업보다 앞에 있는 작업의 수입니다. 이 값은 작업이
PENDING상태일 때만 의미가 있습니다. 값이0인 경우 이 필드는 생략됩니다.
- Name
- image_urls
- Type
- array
- Description
생성된 이미지를 다운로드할 수 있는 URL입니다.
generate_multi_view: true인 경우, 배열에는 보통 세 개인 뷰마다 하나씩의 URL이 담깁니다. Meshy가 모든 뷰를 분리하지 못하면 더 적은 수를 반환하며, 이 경우에도 작업은 성공한 것으로 처리됩니다. 그렇지 않으면 하나의 URL만 담깁니다.
- Name
- task_error
- Type
- object
- Description
작업이 실패했을 때의 오류 상세 정보입니다. 상태가
FAILED가 아니면null입니다. 오류를 참고하세요.
- Name
- consumed_credits
- Type
- integer
- Description
작업에 사용된 크레딧 수입니다. 상태가
PENDING,IN_PROGRESS,SUCCEEDED일 때 존재합니다.FAILED작업의 경우 Meshy가 작업 실패 시 크레딧을 환불하므로0입니다.