빠른 시작
이미지를 원시 본문으로 POST 요청을 전송합니다. API는 MPP 사양에 따라 HTTP 402와 WWW-Authenticate: Payment 헤더로 챌린지를 반환합니다.
# Step 1: discovery — returns HTTP 402 with a "Payment" challenge curl -X POST https://mpp.clearcanvas.app/v1/remove-background \ -H "Content-Type: image/png" \ --data-binary @photo.png # Step 2: paid request — attach an Authorization: Payment header curl -X POST https://mpp.clearcanvas.app/v1/remove-background \ -H "Content-Type: image/png" \ -H "Authorization: Payment <mpp-credential>" \ --data-binary @photo.png \ --output result.png
MPP를 통한 인증
MPP는 Stripe와 Tempo가 공동 출시한 오픈 HTTP 결제 프로토콜입니다. 첫 번째 요청 시 API는 HTTP 402와 WWW-Authenticate: Payment 챌린지를 반환합니다. mppx SDK를 사용하여 Tempo에서 pathUSD 전송에 서명한 후 Authorization: Payment 헤더와 함께 재전송하세요.
mppx SDK 문서 보기 →TypeScript
import fs from 'fs';
import { MppxClient } from 'mppx/client';
// Configure the mppx client for the Tempo crypto rail (pathUSD).
const client = new MppxClient({
wallet: process.env.TEMPO_WALLET_PRIVATE_KEY!,
network: 'tempo',
});
const res = await client.fetch('https://mpp.clearcanvas.app/v1/remove-background', {
method: 'POST',
headers: { 'Content-Type': 'image/png' },
body: fs.readFileSync('photo.png'),
});
const buffer = await res.arrayBuffer();
fs.writeFileSync('result.png', Buffer.from(buffer));Python
import os
import httpx
from mpp import wrap_httpx # pip install mpp
client = wrap_httpx(
wallet=os.environ["TEMPO_WALLET_PRIVATE_KEY"],
network="tempo",
)
resp = client.post(
"https://mpp.clearcanvas.app/v1/remove-background",
content=open("photo.png", "rb").read(),
headers={"Content-Type": "image/png"},
)
open("result.png", "wb").write(resp.content)요청 형식
- •엔드포인트
- •Body: 원시 이미지 바이트 (PNG, JPEG 또는 WebP)
- •Content-Type: image/png | image/jpeg | image/webp
- •선택 사항: WebP 출력을 위한 ?format=webp
응답 형식
- •HTTP 200 — 바이너리 이미지 (PNG 또는 WebP)
- •HTTP 402 — 결제 필요 (WWW-Authenticate: Payment 챌린지)
오류 처리
- •400 — 유효하지 않은 이미지 (잘못된 형식, 매직 바이트 불일치, 또는 크기 초과)
- •413 — 파일이 너무 큼 (> 25 MB)
- •415 — 지원하지 않는 Content-Type
- •429 — 요청 한도 초과 (미결제 요청: 30회/분/IP)
- •500 — 처리 실패 (retryable: true)
- •503 — 프로세서 일시적 사용 불가 (retryable: true)
제한 및 형식
- •최대 파일 크기: 25 MB
- •최대 해상도: 10,000 × 10,000 px
- •지원 입력: PNG, JPEG, WebP
- •출력: PNG (기본값) 또는 WebP
네트워크
API는 Tempo 메인넷에서 실행됩니다. 결제는 pathUSD로 처리됩니다 (이미지당 $0.05). 요청하기 전에 Tempo 지갑에 pathUSD가 있는지 확인하세요. 비용 없이 end-to-end 테스트를 하려면 Tempo 테스트넷을 사용하세요.