메인 콘텐츠로 건너뛰기
POST
/
v1
/
uploads
/
images
curl --request POST \
  --url https://api.apimart.ai/v1/uploads/images \
  --header 'Authorization: Bearer <token>' \
  --form 'file=@/path/to/your/image.jpg'
{
  "url": "https://upload.apimart.ai/f/image/9990000123456-a1b2c3d4-photo.jpg",
  "filename": "photo.jpg",
  "content_type": "image/jpeg",
  "bytes": 235680,
  "created_at": 1743436800
}
문서 Playground는 파일 업로드를 지원하지 않습니다: 아래의 cURL, Python 또는 JavaScript 코드 예제를 사용하여 테스트해 주세요.
중요 변경사항: 더 나은 성능과 비용 관리를 위해 생성 API에서 base64 이미지 데이터를 직접 전달하는 것은 더 이상 지원되지 않습니다. 본 API를 사용하여 이미지를 업로드하고 URL을 획득한 후 생성 API를 호출해 주세요.

왜 이미지를 먼저 업로드해야 하나요?

  1. 성능 최적화 - base64 인코딩은 데이터를 33% 팽창시킵니다. 먼저 업로드하면 요청 본문 크기를 크게 줄일 수 있습니다
  2. 이미지 재사용 - 한 번 업로드하면 URL을 여러 번 사용할 수 있어 중복 전송이 필요 없습니다

사용 흐름

curl --request POST \
  --url https://api.apimart.ai/v1/uploads/images \
  --header 'Authorization: Bearer <token>' \
  --form 'file=@/path/to/your/image.jpg'
{
  "url": "https://upload.apimart.ai/f/image/9990000123456-a1b2c3d4-photo.jpg",
  "filename": "photo.jpg",
  "content_type": "image/jpeg",
  "bytes": 235680,
  "created_at": 1743436800
}

Authorizations

Authorization
string
필수
모든 API는 Bearer Token 인증이 필요합니다API Key 획득:API Key 관리 페이지에서 API Key를 획득하세요요청 헤더에 추가:
Authorization: Bearer YOUR_API_KEY

Body

file
file
필수
이미지 파일지원 형식: JPEG (.jpg, .jpeg), PNG (.png), WebP (.webp), GIF (.gif)최대 파일 크기: 20MB

Response

url
string
이미지의 공개 접근 URL, 생성 API에서 직접 사용 가능 (72시간 유효)
filename
string
원본 파일명
content_type
string
감지된 MIME 유형, 예: image/jpeg
bytes
integer
파일 크기(바이트)
created_at
integer
업로드 시간의 Unix 타임스탬프(초)

전체 예제: 이미지 생성 워크플로우

Python
import requests
import time

API_KEY = "your-Apimart-key"
BASE_URL = "https://api.apimart.ai"

# 1단계: 참조 이미지 업로드
def upload_image(file_path):
    with open(file_path, 'rb') as f:
        response = requests.post(
            f"{BASE_URL}/v1/uploads/images",
            headers={"Authorization": f"Bearer {API_KEY}"},
            files={"file": f}
        )
    return response.json()['url']

# 2단계: 생성 작업 생성
def create_generation(image_url, prompt):
    response = requests.post(
        f"{BASE_URL}/v1/images/generations",
        headers={
            "Authorization": f"Bearer {API_KEY}",
            "Content-Type": "application/json"
        },
        json={
            "model": "gemini-3-pro-image-preview",
            "prompt": prompt,
            "image_urls": [{"url": image_url}],
            "size": "16:9"
        }
    )
    return response.json()['id']

# 3단계: 작업 상태 폴링
def wait_for_result(task_id):
    while True:
        response = requests.get(
            f"{BASE_URL}/v1/images/generations/{task_id}",
            headers={"Authorization": f"Bearer {API_KEY}"}
        )
        result = response.json()

        if result['status'] == 'completed':
            return result['url']
        elif result['status'] == 'failed':
            raise Exception(f"생성 실패: {result.get('fail_reason')}")

        time.sleep(2)

# 워크플로우 실행
image_url = upload_image("reference.jpg")
print(f"이미지 업로드 완료: {image_url}")

task_id = create_generation(image_url, "이 사진을 지브리 애니메이션 스타일로 변환")
print(f"작업 생성 완료: {task_id}")

result_url = wait_for_result(task_id)
print(f"생성 완료: {result_url}")