Skip to content

이미지 생성 및 편집

Images API는 텍스트 생성과 기존 파일 편집을 지원합니다. 모델, 크기, 품질, 입력 형식이 가격에 영향을 주며 편집은 multipart/form-data를 씁니다.

  • 생성은 /v1/images/generations, 편집은 /v1/images/edits를 사용하세요.
  • 모델별 size, quality, 수량, 파일 제한을 확인하세요.
  • 최종 청구는 완료 결과와 반환된 usage를 기준으로 합니다.

전체 예제

원본 가이드의 실행 가능한 예제를 모두 아래에 보존했습니다. 사용 중인 도구와 운영체제에 해당하는 블록만 실행하세요.

bash
curl https://nordrouter.com/v1/chat/completions \
  -H "Authorization: Bearer sk-nr-YOUR-KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-3.1-flash-image-preview",
    "modalities": ["image", "text"],
    "messages": [{ "role": "user", "content": "A cozy cabin in the woods, watercolor" }]
  }'
python
from openai import OpenAI

client = OpenAI(base_url="https://nordrouter.com/v1", api_key="sk-nr-YOUR-KEY")

resp = client.chat.completions.create(
    model="google/gemini-3.1-flash-image-preview",
    modalities=["image", "text"],
    messages=[{"role": "user", "content": "A cozy cabin in the woods, watercolor"}],
)
img_b64 = resp.choices[0].message.images[0]["image_url"]["url"]  # data:image/png;base64,...
python
resp = client.chat.completions.create(
    model="google/gemini-3.1-flash-image-preview",
    modalities=["image", "text"],
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Repaint the car blue and remove the background"},
            {"type": "image_url", "image_url": {"url": "data:image/png;base64,<YOUR-PHOTO>"}},
        ],
    }],
)
bash
curl https://nordrouter.com/v1/images/generations \
  -H "Authorization: Bearer sk-nr-YOUR-KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-image-2",
    "prompt": "Coffee shop logo, minimalist, emerald on white",
    "size": "1024x1024",
    "n": 1
  }'
python
resp = client.images.generate(
    model="openai/gpt-image-2",
    prompt="Coffee shop logo, minimalist, emerald on white",
    size="1024x1024",
)
img_b64 = resp.data[0].b64_json

공식 문서 및 관련 링크

Model≈ per imageHow to call
google/gemini-3.1-flash-image-preview (Nano Banana)~$0.012chat + modalities
google/gemini-3-pro-image (Nano Banana Pro)~$0.028chat + modalities
openai/gpt-image-2~$0.001–0.10 (varies by size & quality)/v1/images/generations
Size · qualityOutput tokensPrice
1024×1024 · low~200~$0.0014
1024×1024 · high~7,000~$0.05
1536×1024 · high~10,500~$0.076
2048×2048 · high~14,300~$0.10

관련 가이드

먼저 최소 텍스트 요청으로 연결을 확인한 다음 스트리밍, 도구 호출, 이미지와 같은 고급 기능을 추가하세요. API 키를 공개 코드나 브라우저 프런트엔드에 넣지 마세요.

문제 해결