메인 콘텐츠로 건너뛰기

소개

Seedream은 Ace Data Cloud에서 제공하는 AI 이미지 서비스로, ByteDance Seedream 이미지 생성 모델입니다. Ace Data Cloud 통합 API를 통해 JavaScript로 Seedream을 빠르게 통합하여 텍스트 생성 이미지, 이미지 편집, 다양한 해상도, 워터마크 제어 등의 기능을 구현할 수 있습니다.

전제 조건

  • Ace Data Cloud 계정을 보유하고 API Token을 획득
  • Node.js 18+ 또는 최신 브라우저 환경

기본 사용법

Seedream API의 주요 엔드포인트는 다음과 같습니다:
POST https://api.acedata.cloud/seedream/images
본 예제는 doubao-seedream-4-0-250828 모델을 사용합니다.
사용 가능한 모델에는 doubao-seedream-4-5-251128, doubao-seedream-4-0-250828, doubao-seedream-3-0-t2i-250415, doubao-seededit-3-0-i2i-250628가 포함됩니다.
완전한 JavaScript 코드 예제:
const response = await fetch("https://api.acedata.cloud/seedream/images", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "prompt": "하얀 샴 고양이가 창턱에 앉아 있다",
  "model": "doubao-seedream-4-0-250828",
  "size": "1K"
}),
});

const result = await response.json();
console.log(result);
YOUR_API_TOKEN을 Ace Data Cloud 플랫폼에서 획득한 실제 토큰으로 교체하세요.

응답 처리

응답 상태 코드를 확인하고 오류를 처리하는 것을 권장합니다:
if (response.ok) {
  const result = await response.json();
  console.log("호출 성공:", result);
} else {
  console.error(`호출 실패, 상태 코드: ${response.status}`);
  const error = await response.text();
  console.error(error);
}

Node.js 래핑

재사용 가능한 함수로 래핑하는 것을 권장합니다:
async function callSeedream(data) {
  const response = await fetch("https://api.acedata.cloud/seedream/images", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.ACE_API_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(data),
  });
  if (!response.ok) throw new Error(`API error: ${response.status}`);
  return response.json();
}

오류 처리

일반적인 오류 코드:
상태 코드설명
401인증 실패, API Token을 확인하세요
403잔액 부족 또는 접근 권한 없음
429요청 빈도 초과
500서버 내부 오류

다음 단계