문서
ByteDance의 Doubao, Seedance, Seedream 모델을 위한 단일 OpenAI 호환 인터페이스입니다.
빠른 시작
어떤 OpenAI SDK든 그대로 사용할 수 있습니다. base URL과 모델 id만 바꾸면 됩니다. 키는 프로젝트 단위로 범위가 지정되며 다운타임 없이 교체할 수 있습니다.
- 1계정을 만들고 대시보드에서 키를 발급합니다.
- 2base URL을 https://byteplus.cc/v1 로 설정합니다.
- 3doubao-seed-1-6 같은 ByteDance 모델 id를 사용합니다.
# any OpenAI-compatible client works
pip install openai
export BYTEPLUS_KEY="bp_live_xxxxxxxxxxxxxxxx"인증
키를 bearer 토큰으로 전송합니다. 키가 없는 요청은 401을 반환하고, 할당량을 초과한 요청은 retry-after 헤더와 함께 429를 반환합니다.
curl https://byteplus.cc/v1/chat/completions \
-H "Authorization: Bearer $BYTEPLUS_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"doubao-pro-32k","messages":[{"role":"user","content":"hi"}]}'
# 401 invalid_api_key
# 429 rate_limit_exceeded (see retry-after header)Chat completions
POST /v1/chat/completions 는 표준 OpenAI 페이로드를 받습니다. model, messages, temperature, max_tokens, stream, tools를 지원합니다.
from openai import OpenAI
client = OpenAI(
base_url="https://byteplus.cc/v1",
api_key=os.environ["BYTEPLUS_KEY"],
)
stream = client.chat.completions.create(
model="doubao-seed-1-6",
messages=[{"role": "user", "content": "Summarise this deck."}],
temperature=0.7,
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")영상 작업
영상은 비동기 방식입니다. 작업을 생성한 뒤 폴링하거나 웹훅을 기다리면 됩니다. 작업 id는 안정적으로 유지되며 결과는 24시간 동안 조회할 수 있습니다.
# 1. create the task
curl https://byteplus.cc/v1/video/tasks \
-H "Authorization: Bearer $BYTEPLUS_KEY" \
-d '{
"model": "seedance-1-0-pro",
"prompt": "neon koi in a datacenter, dolly-in",
"resolution": "1080p",
"duration": 5
}'
# => {"id": "task_9f2c", "status": "queued"}
# 2. poll for the artifact
curl https://byteplus.cc/v1/video/tasks/task_9f2c \
-H "Authorization: Bearer $BYTEPLUS_KEY"
# => {"status": "succeeded", "video_url": "https://..."}이미지 생성
POST /v1/images/generations 는 텍스트 프롬프트로 배치를 렌더링하고, POST /v1/images/edits 는 기존 이미지에 지시문을 적용합니다.
curl https://byteplus.cc/v1/images/generations \
-H "Authorization: Bearer $BYTEPLUS_KEY" \
-d '{
"model": "seedream-4-0",
"prompt": "isometric mint server garden, 4K",
"size": "4096x4096",
"n": 4
}'모델 목록
GET /v1/models 는 모든 모델 id를 모달리티, 컨텍스트 윈도우, 단가와 함께 반환합니다.
curl https://byteplus.cc/v1/models \
-H "Authorization: Bearer $BYTEPLUS_KEY"
# => {"data": [
# {"id": "doubao-seed-1-6", "modality": "language", "context": 262144},
# {"id": "seedance-1-0-pro", "modality": "video", "max_duration": 10},
# {"id": "seedream-4-0", "modality": "image", "max_size": "4096x4096"}
# ]}에러 코드
에러는 OpenAI 형식을 따릅니다. type, code, message, param을 담은 error 객체입니다. 429와 5xx는 지수 백오프로 재시도하세요.
| 401 | invalid_api_key | bearer 토큰과 키의 활성 상태를 확인하세요. |
| 402 | insufficient_balance | 계정 잔액을 충전하세요. |
| 404 | model_not_found | GET /v1/models 로 모델 id를 확인하세요. |
| 422 | invalid_request | 에러의 param을 확인하고 페이로드를 수정하세요. |
| 429 | rate_limit_exceeded | 잠시 기다렸다가 재시도하거나 동시성을 예약하세요. |
| 503 | capacity_unavailable | retry-after 시간 이후에 재시도하세요. 대기열 순번은 헤더에 있습니다. |
요청 제한
제한은 키별, 모델별로 적용되며 분당 요청 수와 분당 토큰 수로 표시됩니다. 예약 고객에게는 전용 동시성 풀이 제공됩니다.