에셋 그룹과 에셋 관리
Seedance API(v3)
https://api.tokenlio.ai와 플랫폼 Bearer Key, 현재 목록의 정확한 model ID를 사용하세요. 상세 필드는 공식 자료를 참고할 수 있으며 호출 주소·인증·예시는 본문을 따르세요.
그룹과 이미지·동영상·오디오 에셋을 관리합니다. AIGC와 인증된 인물 그룹은 같은Action을 사용합니다. 필요하면 인물 에셋 인증으로GroupId를 얻으세요.
쓰기 결과 불명에는 X-Tokenlio-Operation-Id를 저장하고 복구를 따르세요. 공유 범위는 권한 규칙에 있습니다.
| 메서드 | 경로 |
|---|---|
| POST | /?Action={Action}&Version=2024-01-01 |
| POST | /api/v3/assets?Action={Action} |
Action
| Action | 본문 예시 | Result |
|---|---|---|
CreateAssetGroup | {"Name":"Characters"} | Id |
GetAssetGroup | {"Id":"GROUP_ID"} | 그룹 상세 |
ListAssetGroups | {} | Items와 페이지 정보 |
UpdateAssetGroup | {"Id":"GROUP_ID","Name":"New name"} | Id |
DeleteAssetGroup | {"Id":"GROUP_ID"} | {} |
CreateAsset | {"GroupId":"GROUP_ID","URL":"https://example.com/character.png","AssetType":"Image"} | Id |
GetAsset | {"Id":"ASSET_ID"} | 에셋 상세·상태 |
ListAssets | {"Filter":{"GroupIds":["GROUP_ID"]}} | Items와 페이지 정보 |
UpdateAsset | {"Id":"ASSET_ID","Name":"New name"} | Id |
DeleteAsset | {"Id":"ASSET_ID"} | {} |
요청 매개변수
| 필드 | 타입 | 설명 |
|---|---|---|
Id | string | 조회·수정·삭제할 그룹/에셋 ID. 대소문자 구분. |
GroupId | string | CreateAsset의 상위 그룹. |
Name | string | 1~128자. CreateAssetGroup과 UpdateAsset은 필수입니다. CreateAsset은 선택이며 생략하면 Tokenlio가 영문 소문자와 숫자로 된 16자리 이름을 생성합니다. 입력한 이름은 유지됩니다. |
Description | string | 최대 1024자. 빈 문자열로 설명 삭제. UpdateAssetGroup은 Name 또는 Description 필요. |
GroupType | string | 생략 시에만 AIGC. 명시한 값 유지. |
AssetType | string | Image, Video, Audio. 에셋 생성 시 필수. |
URL | string | 접근 가능한 HTTPS 미디어 URL, 최대 8192자. |
ProjectName | string | 선택,1~128자. 생략 시default 프로젝트이며 관련 작업은 같은 값을 사용. |
NextToken / MaxResults | string / integer | 커서 방식. MaxResults 1~100, 기본값 10. |
PageNumber / PageSize | integer | 페이지 방식: 1~1000000 / 1~100, 기본값 1 / 10. 커서와 혼용 불가. |
SortBy / SortOrder | string | CreateTime / UpdateTime, ListAssets는 GroupId도 지원. Asc / Desc, 기본값 CreateTime / Desc. |
Filter.GroupType | string | 기본값 AIGC. 인증 인물 그룹은 LivenessFace. |
Filter.GroupIds | string[] | 서로 다른 그룹 ID 최대 100개. |
Filter.Name | string | 이름 부분 일치. |
Filter.Statuses | string[] | ListAssets: Pending, Processing, Active, Failed. |
다음 페이지에도 같은 필터·정렬·크기를 사용합니다. Get/Delete는 본문의 Id를 사용하며 GroupId나 URL 쿼리 Id를 사용하지 않습니다.
표의 길이는 요청 수신 상한이며 실제 처리 결과는 응답을 따릅니다. 올바른JSON타입을 사용하세요.
에셋 생성과 조회
Action 표의 CreateAsset 최소 요청은 Name을 생략합니다. Tokenlio가 a-z와 0-9로 된 16자리 이름을 생성하며 GetAsset 또는 ListAssets에서 확인할 수 있습니다. 아래 예제에서는 지정한 Name을 유지합니다. 이 기본 동작은 CreateAsset에만 적용되며 CreateAssetGroup과 UpdateAsset에는 Name이 필요합니다.
curl -sS --fail-with-body "https://api.tokenlio.ai/api/v3/assets?Action=CreateAssetGroup&Version=2024-01-01" \
-H "Authorization: Bearer $TOKENLIO_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"Name": "Characters"
}'
curl -sS --fail-with-body "https://api.tokenlio.ai/api/v3/assets?Action=CreateAsset" \
-H "Authorization: Bearer $TOKENLIO_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"GroupId": "GROUP_ID",
"Name": "Portrait",
"URL": "https://example.com/character.png",
"AssetType": "Image"
}'
curl -sS --fail-with-body "https://api.tokenlio.ai/api/v3/assets?Action=GetAsset" \
-H "Authorization: Bearer $TOKENLIO_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"Id": "ASSET_ID"
}'import os
import requests
BASE_URL = "https://api.tokenlio.ai"
headers = {
"Authorization": f"Bearer {os.environ['TOKENLIO_API_KEY']}",
"Content-Type": "application/json",
}
def action(name, body):
response = requests.post(
f"{BASE_URL}/api/v3/assets?Action={name}",
headers=headers, json=body, timeout=30,
)
response.raise_for_status()
data = response.json()
error = data.get("ResponseMetadata", {}).get("Error") or (data.get("Result") or {}).get("Error")
if error:
raise RuntimeError(error)
return data["Result"]
group = action("CreateAssetGroup", {"Name": "Characters"})
asset = action("CreateAsset", {
"GroupId": group["Id"],
"Name": "Portrait",
"URL": "https://example.com/character.png",
"AssetType": "Image",
})
print(action("GetAsset", {"Id": asset["Id"]}))const baseUrl = "https://api.tokenlio.ai";
const headers = {
Authorization: `Bearer ${process.env.TOKENLIO_API_KEY}`,
"Content-Type": "application/json",
};
async function action(name, body) {
const response = await fetch(`${baseUrl}/api/v3/assets?Action=${name}`, {
method: "POST", headers, body: JSON.stringify(body),
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
const data = await response.json();
const error = data.ResponseMetadata?.Error || data.Result?.Error;
if (error) throw new Error(JSON.stringify(error));
return data.Result;
}
const group = await action("CreateAssetGroup", { Name: "Characters" });
const asset = await action("CreateAsset", {
GroupId: group.Id, Name: "Portrait", URL: "https://example.com/character.png", AssetType: "Image",
});
console.log(await action("GetAsset", { Id: asset.Id }));GetAsset은 최신 상태를 반환합니다. Pending/Processing은 처리 중, Active는 사용 가능, Failed는 실패 정보를 포함합니다. 생성은 asset://ASSET_ID로 참조하며 동영상 작업 생성를 사용합니다.
목록과 페이지 처리
페이지 필드를 생략하면 커서 방식으로 MaxResults=10입니다. Result는 Items를 포함하며 다음 페이지가 있을 때만 NextToken을 반환합니다. 같은 프로젝트, 필터, 정렬과 MaxResults로 토큰을 그대로 다시 보내세요. 빈 NextToken이나 다른 Workspace/에셋 서비스에서의 커서 재사용은 금지됩니다.
PageNumber/PageSize를 명시하면 Items/TotalCount/PageNumber/PageSize의 페이지 방식입니다. 두 방식을 섞지 마세요. 목록은 모든 에셋 상태를 갱신하지 않으므로 최신 상태는 GetAsset으로 조회합니다.
curl -sS --fail-with-body 'https://api.tokenlio.ai/api/v3/assets?Action=ListAssetGroups&Version=2024-01-01' \
-H "Authorization: Bearer $TOKENLIO_API_KEY" \
-H 'Content-Type: application/json' \
--data '{
"ProjectName": "default",
"Filter": {
"GroupType": "AIGC"
},
"PageNumber": 1,
"PageSize": 10,
"SortBy": "CreateTime",
"SortOrder": "Desc"
}'
curl -sS --fail-with-body 'https://api.tokenlio.ai/api/v3/assets?Action=ListAssets' \
-H "Authorization: Bearer $TOKENLIO_API_KEY" \
-H 'Content-Type: application/json' \
--data '{
"ProjectName": "default",
"Filter": {
"GroupIds": [
"GROUP_ID"
],
"GroupType": "AIGC"
},
"MaxResults": 10
}'응답과 오류
{
"ResponseMetadata": {
"RequestId": "REQUEST_ID",
"Action": "CreateAssetGroup",
"Version": "2024-01-01",
"Service": "ark",
"Region": "cn-beijing"
},
"Result": {
"Id": "GROUP_ID"
}
}목록은 Items와 다음 페이지가 있을 때 NextToken을 반환합니다. 페이지 방식은 TotalCount, PageNumber, PageSize를 반환합니다. 그룹 삭제는 하위 에셋도 삭제하므로 대상을 확인하세요. DeleteAsset / DeleteAssetGroup 성공은 HTTP200과 빈 Result: {}이며 Id는 반환하지 않습니다. 에셋 삭제는 기존 생성 작업을 취소하거나 생성 요금을 환불하지 않습니다. 생성과 삭제가 경쟁하면 실제 작업 결과를 확인하세요.
{
"ResponseMetadata": {
"RequestId": "REQUEST_ID",
"Action": "GetAsset",
"Version": "2024-01-01",
"Service": "ark",
"Region": "cn-beijing",
"Error": {
"Code": "InvalidParameter",
"Message": "One or more parameters specified in the request are not valid."
}
}
}HTTP 상태와 ResponseMetadata.Error.Code/Message를 확인하세요. 주요 오류는 MissingParameter/InvalidParameter, AuthenticationError, AccessDenied, ResourceNotFound, OperationConflict, RequestTooLarge, RequestLimitExceeded, ServiceUnavailable입니다. 인증 미완료는 성공한 GroupId로 해석하지 않고 오류로 처리합니다.
관측한 HTTP, 전체 ResponseMetadata/Result, 오류 필드와 유효한 확장을 보존하며 모두503으로 바꾸지 않습니다. 명확한 매개변수 거절은 Code/Message에 따라 수정하세요. HTTP422의 내부 타임아웃은 이미 제출되었을 수 있으므로 새 의도를 자동 재전송하지 마세요. 원래 본문, 안정적인 키, 작업 ID로 복구합니다. ResourceNotFound는 관리 범위 밖을 뜻할 수도 있으며 다른 서비스에도 없다는 의미는 아닙니다.
