SciFig

API 참조 문서

이미지 편집

지시나 영역 지정으로 이미지를 편집하고, 배경 교체, 화면 비율 변경, 색상 변경 또는 텍스트 교체를 할 수 있습니다.

Markdown으로 보기

작업 종류#

JSON 본문을 포함한 POST /images/edits. 필요한 범위: figures:generate. image는 file_id(업로드 또는 이전 결과)이며, operation은 편집 종류를 선택하고 기본값은 instruct입니다. 웹사이트 결과 도구 모음에서도 같은 도구를 사용할 수 있습니다.

operation기능필드크레딧
instruct지시에 따라 이미지 전체를 편집. 마스크가 있으면 마스크 영역만 다시 그림instruction(1–2,000자), 선택 항목 mask, quality품질에 따라 50 / 75 / 100, 마스크 사용 시 100
white_background배경을 단색 흰색으로 교체(투명 배경이 아님)quality50 / 75 / 100
aspect_ratio배경을 확장하여 그림 전체를 새 화면 비율로 조정aspect_ratio (1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9), quality50 / 75 / 100
recolor라벨 색상을 유지하면서 그림에 팔레트 적용선택 항목 palette(#RRGGBB 1–8개, 생략 시 자동 선택), quality50 / 75 / 100
replace_text글꼴과 위치를 유지하면서 텍스트 라벨 교체text_detection, replacements100

마스크는 용도 mask로 업로드하는 PNG입니다. 이미지와 크기가 같아야 하며, 변경 가능한 영역을 흰색으로 표시합니다. 영역 편집은 quality 값과 관계없이 항상 premium 모델을 사용합니다. replace_text는 quality를 받지 않으며, 항상 텍스트 편집 모델을 사용하고 premium 가격이 적용됩니다.

텍스트 교체#

  • 같은 이미지에 POST /images/text-detections를 호출하세요. 무료이며, id와 각 항목에 index가 포함된 texts를 반환합니다.
  • operation: "replace_text", text_detection: <id> 및 replacements: [{"index": 0, "text": "Figure 1"}]를 보내세요. 목록에 넣지 않은 텍스트는 그대로 유지됩니다.
  • 감지 결과에 없는 인덱스를 지정하면 details.reason = TEXT_INDEX_OUT_OF_RANGE가 포함된 400 INVALID_REQUEST를 반환하며, 크레딧은 차감하지 않습니다.

크레딧#

작업 생성 시 크레딧을 예약하고, 성공 시 한 번만 차감하며, 실패 시 전액 반환합니다. 응답은 작업 객체입니다. 필드와 상태는 작업 및 대기 시간 제한을, 오류는 오류를 참조하세요.

cURL#

curl -X POST https://scifig.ai/api/v1/images/edits \
  -H "Authorization: Bearer $SCIFIG_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Prefer: wait=25" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "<file_id>",
    "operation": "aspect_ratio",
    "aspect_ratio": "16:9"
  }'

JavaScript#

const response = await fetch('https://scifig.ai/api/v1/images/edits', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.SCIFIG_API_KEY}`,
    'Idempotency-Key': crypto.randomUUID(),
    Prefer: 'wait=25',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "image": "<file_id>",
    "operation": "aspect_ratio",
    "aspect_ratio": "16:9"
  }),
});
const result = await response.json();
console.log(response.status, result);

Python#

import os
import uuid

import requests

headers = {
    "Authorization": f"Bearer {os.environ['SCIFIG_API_KEY']}",
    "Idempotency-Key": str(uuid.uuid4()),
    "Prefer": "wait=25",
}
response = requests.post(
    "https://scifig.ai/api/v1/images/edits",
    headers=headers,
    json={
        "image": "<file_id>",
        "operation": "aspect_ratio",
        "aspect_ratio": "16:9"
    },
    timeout=60,
)
print(response.status_code, response.json())