API 레퍼런스
이미지 생성
요약
텍스트 프롬프트에서 이미지를 생성하는 API입니다.
Google, OpenAI, BFL, xAI 등 다양한 제공업체의 이미지 모델을 지원하며, 제공업체에 따라 동기(즉시 반환) 또는 비동기(폴링) 방식으로 결과를 받을 수 있습니다.
동기 이미지 생성은 모델에 따라 응답 시간이 다릅니다. Google Gemini 모델은 약 510초, OpenAI 모델은 약 1530초가 소요됩니다. HTTP 클라이언트의 타임아웃을 최소 60초 이상으로 설정해주세요 (httpx 기본값은 5초입니다).
이미지 생성
POST/v1/gateway/images/generate/
텍스트 프롬프트에서 하나 이상의 이미지를 생성합니다.
상태 폴링 (비동기 전용)
GET/v1/gateway/images/generate/{operation_id}/비동기 이미지 생성 상태 폴링 (Fal/Replicate 전용).
파라미터
modelstring
required
promptstring
required
number_of_imagesinteger
1).aspect_ratiostring
"1:1", "16:9", "9:16", "4:3".qualitystring
"standard" 또는 "hd" (제공업체별 상이).응답 — 동기 제공업체 (Google)
json
{
"id": "img-a1b2c3d4e5f6g7h8",
"created": 1738000000,
"model": "gemini-2.5-flash-image",
"data": [
{ "url": "data:image/png;base64,iVBORw0KGgo..." }
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 1290,
"total_tokens": 1332
}
}
Fal/Replicate 등 비동기 제공업체는 결과가 바로 반환되지 않습니다.
operation_id를 사용하여 상태를 폴링해야 합니다. 아래 비동기 응답 섹션을 참고해주세요.응답 — 비동기 제공업체 (Fal, Replicate)
json
{
"operation_id": "fal-abc123def456",
"status": "processing"
}
GET /v1/gateway/images/generate/{operation_id}/?model=<model_name>으로 status가 "completed"가 될 때까지 폴링하세요.예제
curl
bashcurl -X POST https://factchat-cloud.mindlogic.ai/v1/gateway/images/generate/ \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-2.5-flash-image", "prompt": "A mountain landscape at sunset with dramatic clouds", "aspect_ratio": "16:9" }'
Python
python
import httpx, base64
API_KEY = "YOUR_API_KEY"
BASE = "https://factchat-cloud.mindlogic.ai/v1/gateway"
client = httpx.Client(headers={"Authorization": f"Bearer {API_KEY}"}, timeout=60.0)
# 동기 제공업체 (Google Gemini) — 즉시 반환
resp = client.post(f"{BASE}/images/generate/", json={
"model": "gemini-2.5-flash-image",
"prompt": "A mountain landscape at sunset with dramatic clouds",
"aspect_ratio": "16:9",
"number_of_images": 1,
})
data = resp.json()
# base64 이미지 저장
for i, img in enumerate(data["data"]):
b64 = img["url"].split(",", 1)[1]
with open(f"image_{i}.png", "wb") as f:
f.write(base64.b64decode(b64))
print(f"Saved image_{i}.png")
print(f"사용된 토큰: {data['usage']['total_tokens']}")
Python — 비동기 제공업체 (Fal/Replicate)
python
import time
# 비동기 제공업체 — 폴링 필요
resp = client.post(f"{BASE}/images/generate/", json={
"model": "xai/grok-imagine-image",
"prompt": "A futuristic city skyline",
"aspect_ratio": "16:9",
})
data = resp.json()
operation_id = data["operation_id"]
# 완료될 때까지 폴링
while True:
status = client.get(
f"{BASE}/images/generate/{operation_id}/",
params={"model": "xai/grok-imagine-image"},
).json()
if status["status"] == "completed":
print("이미지 URL:", status["data"][0]["url"])
break
time.sleep(5)
JavaScript
javascript
const response = await fetch(
"https://factchat-cloud.mindlogic.ai/v1/gateway/images/generate/",
{
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-image-1",
prompt: "A mountain landscape at sunset",
quality: "high",
number_of_images: 1,
}),
}
);
const data = await response.json();
console.log(`생성된 이미지: ${data.data.length}개`);
제공업체 참고
| 제공업체 | 동기/비동기 | URL 유형 | 비고 |
|---|---|---|---|
| Google (Gemini) | 동기 | Base64 인라인 | 기본 제공업체. 모델: gemini-2.5-flash-image |
| Fal | 비동기 | HTTPS CDN URL | 폴링 필요 |
| Replicate | 비동기 | HTTPS URL | 폴링 필요 |
사용 가능한 모델
| 모델 | 제공업체 | 크레딧/이미지 | 동기/비동기 | 주요 파라미터 |
|---|---|---|---|---|
gemini-2.5-flash-image | 39 | 동기 | aspect_ratio, number_of_images (최대 4) | |
gemini-3-pro-image-preview | 145 | 동기 | aspect_ratio, image_size (1K/2K/4K), number_of_images (최대 4) | |
gpt-image-1.5 | OpenAI | 38 | 동기 | size, quality (low/medium/high), background (auto/transparent/opaque) |
gpt-image-1 | OpenAI | 42 | 동기 | size, quality (low/medium/high), background |
gpt-image-1-mini | OpenAI | 8 | 동기 | size, quality (low/medium/high), background |
black-forest-labs/flux-2-pro | BFL (Replicate) | 30 | 비동기 | aspect_ratio, resolution (1MP/2MP/4MP) |
black-forest-labs/flux-1.1-pro | BFL (Replicate) | 40 | 비동기 | aspect_ratio |
xai/grok-imagine-image | xAI (Fal) | 20 | 비동기 | aspect_ratio |
fal-ai/bytedance/seedream/v4.5 | ByteDance (Fal) | 40 | 비동기 | image_size (square/landscape/portrait/2K/4K) |
bytedance/seedream-4 | ByteDance (Replicate) | 30 | 비동기 | aspect_ratio, size (1K/2K/4K) |
runwayml/gen4-image | Runway (Replicate) | 80 | 비동기 | aspect_ratio, resolution (720p/1080p) |
stability-ai/sdxl | Stability AI (Replicate) | 5 | 비동기 | — |
테넌트에 따라 일부 모델이 활성화되지 않을 수 있습니다. 활성화되지 않은 모델을 사용하면
403 에러가 반환됩니다 — 관리자에게 문의하세요.마지막 수정 날짜: Feb 24, 2026