메인 콘텐츠로 건너뛰기
POST
/
v1
/
images
/
generations
curl -X POST "https://api.lemondata.cc/v1/images/generations" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dall-e-3",
    "prompt": "A white cat sitting on a windowsill watching rain",
    "size": "1024x1024",
    "quality": "standard",
    "n": 1
  }'
{
  "created": 1706000000,
  "data": [
    {
      "url": "https://...",
      "revised_prompt": "A fluffy white cat with bright eyes sitting peacefully on a wooden windowsill, watching raindrops stream down the glass window..."
    }
  ]
}

요청 본문

model
string
기본값:"dall-e-3"
사용할 모델 (예: dall-e-3, flux-pro, midjourney).
prompt
string
필수
원하는 이미지에 대한 텍스트 설명.
n
integer
기본값:"1"
생성할 이미지 수 (1-4, 모델에 따라 다름).
size
string
기본값:"1024x1024"
이미지 크기. 모델에 따라 옵션이 다릅니다:
  • DALL-E 3: 1024x1024, 1792x1024, 1024x1792
  • 기타 모델: 512x512, 1024x1024
quality
string
기본값:"standard"
이미지 품질 (standard 또는 hd). DALL-E 3 전용.
response_format
string
기본값:"url"
응답 형식: url 또는 b64_json.
style
string
기본값:"vivid"
DALL-E 3 스타일: vivid 또는 natural.
user
string
최종 사용자의 고유 식별자.

응답

동기 응답 (DALL-E, Flux Schnell 등)

created
integer
생성 시점의 Unix 타임스탬프.
data
array
생성된 이미지 배열.각 객체에 포함된 항목:
  • url (string): 생성된 이미지의 URL
  • b64_json (string): Base64로 인코딩된 이미지 (요청 시)
  • revised_prompt (string): 사용된 프롬프트 (DALL-E 3)

비동기 응답 (Midjourney, Flux Pro, Ideogram 등)

일부 모델은 처리 시간이 더 오래 걸리며 비동기 응답을 반환합니다:
created
integer
생성 시점의 Unix 타임스탬프.
task_id
string
폴링을 위한 고유 작업 식별자.
status
string
초기 상태: pending.
poll_url
string
결과를 폴링할 상대 URL (예: /v1/images/generations/{task_id}).
data
array
플레이스홀더 데이터가 포함된 배열. url은 완료될 때까지 비어 있습니다.
status: "pending"을 받으면 이미지 상태 조회 엔드포인트를 사용하여 결과를 폴링하세요.
curl -X POST "https://api.lemondata.cc/v1/images/generations" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dall-e-3",
    "prompt": "A white cat sitting on a windowsill watching rain",
    "size": "1024x1024",
    "quality": "standard",
    "n": 1
  }'
{
  "created": 1706000000,
  "data": [
    {
      "url": "https://...",
      "revised_prompt": "A fluffy white cat with bright eyes sitting peacefully on a wooden windowsill, watching raindrops stream down the glass window..."
    }
  ]
}

사용 가능한 모델

모델유형특징
dall-e-3동기최고 품질, 프롬프트 향상
dall-e-2동기더 빠르고 저렴함
flux-pro비동기사실적, 고품질
flux-schnell동기매우 빠름
midjourney비동기예술적 스타일
ideogram-v3비동기최고의 텍스트 렌더링
stable-diffusion-3동기오픈 소스, 커스터마이징 가능
비동기 모델status: "pending"을 반환하며 폴링이 필요합니다. 결과를 가져오는 방법은 이미지 상태 조회를 참조하세요.

비동기 응답 처리

비동기 모델의 경우 응답에 status: "pending"이 포함되어 있는지 확인하세요:
import requests
import time

def generate_image(prompt, model="midjourney"):
    # 이미지 생성 요청
    response = requests.post(
        "https://api.lemondata.cc/v1/images/generations",
        headers={"Authorization": "Bearer sk-your-api-key"},
        json={"model": model, "prompt": prompt}
    )
    data = response.json()

    # 비동기 여부 확인
    if data.get("status") == "pending":
        task_id = data["task_id"]
        print(f"Async task started: {task_id}")

        # 결과 폴링
        while True:
            status_resp = requests.get(
                f"https://api.lemondata.cc/v1/images/generations/{task_id}",
                headers={"Authorization": "Bearer sk-your-api-key"}
            )
            status_data = status_resp.json()

            if status_data["status"] == "completed":
                return status_data["data"][0]["url"]
            elif status_data["status"] == "failed":
                raise Exception(status_data.get("error", "Generation failed"))

            time.sleep(3)
    else:
        # 동기 응답
        return data["data"][0]["url"]

# 사용 예시
url = generate_image("a beautiful sunset over mountains", model="midjourney")
print(f"Generated image: {url}")

본문

application/json
prompt
string
필수

원하는 이미지에 대한 텍스트 설명.

model
string

사용할 모델 (예: dall-e-3 , flux-pro , midjourney ).

n
integer

생성할 이미지 수 (1-4, 모델에 따라 다름).

size
string

이미지 크기. 모델에 따라 옵션이 다릅니다: DALL-E 3: 1024x1024 , 1792x1024 , 1024x1792 기타 모델: 512x512 , 1024x1024

quality
string

이미지 품질 ( standard 또는 hd ). DALL-E 3 전용.

response_format
string

응답 형식: url 또는 b64_json .

style
string

DALL-E 3 스타일: vivid 또는 natural .

user
string

최종 사용자의 고유 식별자.

응답

200 - application/json

Response 200

created
integer

생성 시점의 Unix 타임스탬프.

data
object[]

플레이스홀더 데이터가 포함된 배열. url 은 완료될 때까지 비어 있습니다.

task_id
string

폴링을 위한 고유 작업 식별자.

status
string

초기 상태: pending .

poll_url
string

결과를 폴링할 상대 URL (예: /v1/images/generations/{task_id} ).