비동기 작업
작업 상태 가져오기
create 엔드포인트에서 반환된 poll_url을 사용하여 모든 비동기 작업의 상태와 결과를 조회합니다
개요
비디오, 이미지, 음악, 3D 생성과 같은 작업 유형 전반에서 통합된 비동기 polling을 위해 이 엔드포인트를 사용하세요.
create 응답에 poll_url이 포함되어 있으면 해당 정확한 path를 호출하세요. 최신 비동기 워크플로에서는 poll_url이 /v1/tasks/{id}를 가리킬 수 있습니다.
경로 매개변수
create 요청에서 반환된 작업 ID입니다.
응답
결과, 오류, 타임스탬프, 모델 필드는 작업에서 제공될 때 반환됩니다.
작업 식별자입니다.
비동기 작업 식별자의 별칭입니다.
생성 응답에서 제공될 때 우선 사용할 폴링 URL입니다.
작업 상태입니다. 예: pending, processing, completed, failed. 취소된 작업은 failed와 cancelled: true로 표시됩니다.
대기 중인 비동기 작업이 실행 전에 취소되면 true입니다.
취소 마커입니다. 취소 성공 시 cancelled입니다.
완료된 이미지 작업의 경우 생성된 이미지 결과가 여기에 반환됩니다. 이미지 작업은 data[].url에 URL을 반환합니다.
선택적 진행 값입니다. 실제 진행 값이 제공될 때만 반환됩니다. 완료 여부는 status 로 판단하세요.
작업이 완료되어 비디오를 생성한 경우의 결과 asset URL입니다.
사용 가능한 경우 url, duration, width, 및 height를 포함한 단일 비디오 페이로드.
생성 작업이 여러 출력을 반환할 때의 다중 비디오 페이로드.
생성 타임스탬프.
최종 업데이트 타임스탬프.
작업에 사용된 모델.
작업이 실패했을 때의 오류 메시지입니다.
오류 동작
만료되었거나 사용할 수 없는 공개 작업은 404 async_task_not_found를 반환할 수 있습니다. 현재 API 키로 작업 소유권을 확인할 수 없으면 403 task_not_owned가 반환됩니다.
{
"error": {
"message": "Task not found or no longer available.",
"type": "invalid_request_error",
"code": "async_task_not_found"
}
}예제
요청
curl "https://api.tokenlab.sh/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-H "Authorization: Bearer sk-your-api-key"import requests
poll_url = "/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
response = requests.get(
f"https://api.tokenlab.sh{poll_url}",
headers={"Authorization": "Bearer sk-your-api-key"},
)
print(response.json())const pollUrl = '/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
const response = await fetch(`https://api.tokenlab.sh${pollUrl}`, {
headers: { Authorization: 'Bearer sk-your-api-key' },
});
console.log(await response.json());{ "id": "string", "status": "pending", "progress": 0, "created": 0, "updated": 0, "model": "string", "video": { "url": "string", "duration": 0, "width": 0, "height": 0 }, "error": "string", "error_details": { "projection_version": 0, "status": 400, "message": "string", "type": "string", "code": "string", "param": "string", "retryable": true, "upstream": { "source": "string", "code": "string", "message": "string", "param": "string" } }, "task_id": "string", "poll_url": "string", "cancelled": true, "cancellation_status": "cancelled", "billing_transaction_id": "string", "video_url": "string", "videos": [ {} ], "data": [ {} ], "audio_url": "string", "title": "string", "lyrics": "string", "model_url": "string", "glb_url": "string", "fbx_url": "string"}인증
BearerAuth API 키 인증입니다. Dashboard > API > API Keys에서 API 키를 생성하거나 관리하십시오.
위치: header
경로 매개변수
id / task_id로 반환되거나 poll_url에 포함된 비동기 작업 ID입니다.
응답
application/json
application/json
application/json
application/json