GemPix2 API 문서

Google Gemini AI 모델을 사용한 GemPix2 이미지 생성 서비스의 완전한 API 문서

가격 확인GemPix2 가격 플랜 보기

GemPix2 API 개요

GemPix2 이미지 생성 API는 텍스트 프롬프트와 참조 이미지로부터 고품질 이미지를 생성하는 Google Gemini AI 모델에 대한 접근을 제공합니다. 우리의 GemPix2 서비스는 포괄적인 작업 관리와 콜백 지원을 갖춘 간단한 RESTful 인터페이스를 제공합니다.

GemPix2 주요 기능

  • Google Gemini AI 모델을 사용한 GemPix2 텍스트-이미지 생성
  • 참조 이미지 지원 (최대 4개 이미지) GemPix2
  • 상태 추적이 가능한 GemPix2 비동기 작업 처리
  • 실시간 알림을 위한 GemPix2 웹훅 콜백 지원
  • JSON 응답을 제공하는 GemPix2 RESTful API
  • Bearer 토큰 인증을 사용하는 GemPix2

overview.base_url

https://api.defapi.org

overview.api_version

v1.0.0

GemPix2 시작하기

  1. 1. 프로덕션 서버에서 GemPix2 API 키 등록하기
  2. 2. Authorization 헤더에 GemPix2 API 키 포함하기
  3. 3. GemPix2 이미지 생성 엔드포인트로 POST 요청 보내기
  4. 4. 반환된 GemPix2 task_id를 사용하여 생성 상태 확인하기
  5. 5. 작업이 완료되면 GemPix2 생성된 이미지 가져오기

인증

모든 API 요청은 Bearer 토큰 인증을 사용해야 합니다. 모든 요청의 Authorization 헤더에 API 키를 포함하세요.

인증 방법

Authorization 헤더에 API 키를 포함하여 HTTP Bearer 토큰 인증을 사용하세요:

Authorization: Bearer <your-api-key>

API 키 형식 예시

Authorization: Bearer dk-1234567890abcdef

요청 예시

curl -X POST "https://api.defapi.org/api/image/gen" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-key-here" \
  -d '{
    "model": "google/gempix2",
    "prompt": "A beautiful landscape"
  }'

유효한 인증

  • API 키가 유효함
  • 사용자 계정이 활성화됨
  • 충분한 크레딧 사용 가능

일반적인 오류

  • API 키 누락
  • 잘못된 API 키 형식
  • 만료되거나 비활성화된 계정

GemPix2 이미지 생성 API

Google Gemini AI 모델과 사용자 정의 프롬프트 및 참조 이미지를 사용하여 GemPix2로 이미지를 생성합니다.

엔드포인트

POST /api/image/gen

요청 매개변수

ParameterTypeRequiredDescription
modelstringYesModel identifier (e.g., "google/gempix2")
promptstringYesText prompt describing the image
imagesarrayNoReference image URLs (max 4)
callback_urlstringNoWebhook URL for completion notifications

요청 예시

기본 GemPix2 이미지 생성

{
  "model": "google/gempix2",
  "prompt": "A beautiful girl dancing in a garden"
}

참조 이미지를 사용한 GemPix2 이미지 기반 생성

{
  "model": "google/gempix2",
  "prompt": "Put them in a basket",
  "images": [
    "https://cdn.openai.com/API/docs/images/body-lotion.png",
    "https://cdn.openai.com/API/docs/images/soap.png"
  ],
  "callback_url": "https://example.com/webhook/image-callback"
}

응답 형식

{
  "code": 0,
  "message": "ok",
  "data": {
    "task_id": "ta12345678-1234-1234-1234-123456789abc"
  }
}

오류 응답

400 - Bad Request

{"code": 1, "message": "failed", "detail": "prompt is required"}

401 - Unauthorized

{"code": 1, "message": "Invalid API key"}

GemPix2 작업 조회 API

GemPix2 이미지 생성 엔드포인트에서 반환된 작업 ID를 사용하여 GemPix2 이미지 생성 작업의 상태와 결과를 조회합니다.

엔드포인트

GET /api/task/query?task_id=<task_id>

조회 매개변수

ParameterTypeRequiredDescription
task_idstringYesUnique task identifier returned from generation endpoint

요청 예시

curl -X GET "https://api.defapi.org/api/task/query?task_id=ta823dfb-eaac-44fd-aec2-3e2c7ba8e071" \
  -H "Authorization: Bearer your-api-key-here"

GemPix2 작업 상태 값

pending - GemPix2 작업이 생성되어 처리 대기 중입니다
submitted - GemPix2 작업이 생성 대기열에 제출되었습니다
in_progress - GemPix2 작업이 현재 처리 중입니다
success - GemPix2 작업이 성공적으로 완료되어 이미지가 생성되었습니다
failed - 오류로 인해 GemPix2 작업이 실패했습니다

오류 응답

404 - Task Not Found

{"code": 1, "message": "task not found"}

401 - Unauthorized

{"code": 401, "message": "Invalid API key"}

GemPix2 데이터 모델

API 응답 및 요청에서 사용되는 모든 GemPix2 데이터 모델과 스키마에 대한 완전한 참조입니다.

ImageGenResult

Represents a generated image result.

{
  "image": "https://google.datas.systems/fileSystem/response_images/287/2025/08/29/1756432513771985292_2989.png"
}
FieldTypeDescription
imagestringImage URL or base64 data URI

CallbackPayload

Payload sent to the callback_url when task status changes to final states.

{
  "result": [
    {
      "image": "https://google.datas.systems/fileSystem/response_images/287/2025/08/29/1756432513771985292_2989.png"
    }
  ],
  "status": "success",
  "task_id": "ta5c9705-b8ae-4cb9-aa6f-97c4fee88c8d",
  "consumed": "0.500000",
  "status_reason": {
    "message": null
  }
}
FieldTypeDescription
resultarrayArray of ImageGenResult objects (null if failed)
statusstringFinal task status (success/failed)
task_idstringUnique task identifier
consumedstringCredits consumed by the task
status_reasonobjectStatus details including error message if failed

GemPix2 사용 가능한 모델

google/gempix2Nano Banana image generation model
google/gemini-2.5-flash-imageGemini 2.5 Flash image model

오류 처리

오류 처리 및 API 응답 코드 이해에 대한 종합 가이드입니다. 모든 오류 응답은 문제 해결에 도움이 되는 일관된 형식을 따릅니다.

HTTP 상태 코드

200

OK

Request was successful

400

Bad Request

Invalid request parameters or malformed JSON

401

Unauthorized

Invalid, missing, or expired API key

404

Not Found

Task not found or endpoint doesn't exist

500

Internal Server Error

Server-side error occurred

오류 처리 모범 사례

  1. 1. 응답 본문을 처리하기 전에 항상 HTTP 상태 코드를 확인하세요:
  2. 2. 500 오류에 대한 재시도 로직에서 지수 백오프를 구현하세요:
  3. 3. 디버깅을 위해 자세한 정보와 함께 오류 응답을 로그에 기록하세요:
  4. 4. 400 오류를 방지하기 위해 요청을 보내기 전에 입력값을 검증하세요:
  5. 5. 사용자에게 API 키 업데이트를 안내하여 인증 오류를 처리하세요:
  6. 6. 너무 자주 폴링하지 말고 주기적으로 작업 상태를 모니터링하세요:
  7. 7. 작업 완료를 위한 폴링을 피하기 위해 가능하면 웹훅을 사용하세요:

샘플 오류 처리 (JavaScript)

async function generateImage(prompt, apiKey) {
  try {
    const response = await fetch('https://api.defapi.org/api/image/gen', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${apiKey}`
      },
      body: JSON.stringify({
        model: 'google/gempix2',
        prompt: prompt
      })
    });

    if (!response.ok) {
      const errorData = await response.json();
      throw new Error(`API Error ${response.status}: ${errorData.message}`);
    }

    const data = await response.json();
    return data.data.task_id;

  } catch (error) {
    console.error('Image generation failed:', error.message);
    throw error;
  }
}