> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xhuoapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Sora Tasks API의 연동 및 사용

> Sora Video Generation 集成指南 - XHuoAPI

Sora Tasks API의 주요 기능은 Sora Videos Generation API에서 생성된 작업 ID를 입력하여 해당 작업의 실행 상태를 조회하는 것입니다.

본 문서는 Sora Tasks API의 연동 설명을 자세히 소개하여, 여러분이 쉽게 통합하고 이 API의 강력한 기능을 충분히 활용할 수 있도록 돕습니다. Sora Tasks API를 통해 Sora Videos Generation API의 작업 실행 상태를 쉽게 조회할 수 있습니다.

## 신청 절차

Sora Tasks API를 사용하려면 먼저 신청 페이지 [Sora Videos Generation API](https://api.xhuoapi.ai/documents/99a24421-2e22-4028-8201-e19cb834b67e)에서 해당 서비스를 신청한 후, Sora Videos Generation API의 작업 ID를 복사합니다. 아래 그림과 같이 진행합니다:

<p>
  <img src="https://cdn.xhuoapi.ai/za62pb.png" width="500" className="m-auto" />
</p>

마지막으로 Tasks API 페이지 [Sora Tasks API](https://api.xhuoapi.ai/documents/c9d81bad-9064-4796-86b6-4fb43cc93a16)에서 해당 서비스를 신청하고, 페이지에 들어가면 「Acquire」 버튼을 클릭합니다. 아래 그림과 같이 진행합니다:

![신청 페이지](https://cdn.xhuoapi.ai/rci31i.png)

로그인 또는 등록이 되어 있지 않으면 자동으로 [로그인 페이지](https://api.xhuoapi.ai)로 이동하여 등록 및 로그인을 요청합니다. 로그인 및 등록 후에는 자동으로 현재 페이지로 돌아옵니다.

첫 신청 시 무료 사용량이 제공되어, 해당 API를 무료로 사용할 수 있습니다.

## 요청 예시

Sora Tasks API는 Sora Videos Generation API의 결과를 조회하는 데 사용됩니다. Sora Videos Generation API의 사용 방법에 대한 자세한 내용은 문서 [Sora Videos Generation API](https://api.xhuoapi.ai/documents/sora-videos-integration)를 참조하십시오.

Sora Videos Generation API 서비스에서 반환된 작업 ID를 예로 들어, 해당 API를 사용하는 방법을 시연합니다. 가정해 보겠습니다. 작업 ID가 b8976e18-32dc-4718-9ed8-1ea090fcb6ea라고 할 때, 다음과 같이 작업 ID를 전달하여 진행합니다.

### 작업 예시 그림

<p>
  <img src="https://cdn.xhuoapi.ai/za62pb.png" width="500" className="m-auto" />
</p>

### 요청 헤더 및 요청 본문 설정

**Request Headers**에는 다음이 포함됩니다:

* `accept`: JSON 형식의 응답 결과를 수신하도록 지정하며, 여기서는 `application/json`으로 입력합니다.
* `authorization`: API 호출에 필요한 키로, 신청 후 직접 드롭다운에서 선택할 수 있습니다.

**Request Body**에는 다음이 포함됩니다:

* `id`: 업로드된 작업 ID.
* `action`: 작업에 대한 조작 방식.

아래 그림과 같이 설정합니다:

<p>
  <img src="https://cdn.xhuoapi.ai/fe19dd.png" width="500" className="m-auto" />
</p>

### 코드 예시

페이지 오른쪽에는 다양한 언어의 코드가 자동으로 생성된 것을 확인할 수 있습니다. 아래 그림과 같이 진행합니다:

<p>
  <img src="https://cdn.xhuoapi.ai/ou5lfa.png" width="500" className="m-auto" />
</p>

일부 코드 예시는 다음과 같습니다:

#### CURL

```bash theme={null}
curl -X POST 'https://api.xhuoapi.ai/v1/sora/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
  "action": "retrieve"
}'
```

#### Python

```python theme={null}
import requests

url = "https://api.xhuoapi.ai/v1/sora/tasks"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
    "action": "retrieve"
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)
```

### 응답 예시

요청이 성공하면 API는 이곳 비디오 작업의 세부 정보를 반환합니다. 예를 들어:

```json theme={null}
{
  "_id": "68e914aa550a4144a5788305",
  "id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
  "api_id": "54aed96c-0346-4227-8c99-9780247a7ffd",
  "application_id": "f10c04c2-2273-4463-bd3f-593d71b75ac8",
  "created_at": 1760105642.045,
  "credential_id": "4e6e181d-f320-4874-8d80-fc2253b40b7e",
  "request": {
    "size": "large",
    "duration": 15,
    "orientation": "landscape",
    "prompt": "cat running on the river",
    "model": "sora-2",
    "image_urls": [
      "https://cdn.xhuoapi.ai/11wfp4.png"
    ],
    "callback_url": "https://webhook.site/eb238c4f-da3b-47a5-a922-a93aa5405daa"
  },
  "trace_id": "fb751e1e-4705-49ea-9fd4-5024b7865ea2",
  "type": "videos",
  "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
  "response": {
    "success": true,
    "task_id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
    "trace_id": "fb751e1e-4705-49ea-9fd4-5024b7865ea2",
    "data": [
      {
        "id": "sora-2:task_01k777hjrbfrgs2060q5zvf2a5",
        "video_url": "https://filesystem.site/gptimage/vg-assets/assets%2Ftask_01k777hjrbfrgs2060q5zvf2a5%2Ftask_01k777hjrbfrgs2060q5zvf2a5_genid_b8e2e5d1-a579-49ca-a21c-cb3869685cce_25_10_10_14_15_147334%2Fvideos%2F00000%2Fsrc.mp4?st=2025-10-10T12%3A38%3A49Z&se=2025-10-16T13%3A38%3A49Z&sks=b&skt=2025-10-10T12%3A38%3A49Z&ske=2025-10-16T13%3A38%3A49Z&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skoid=aa5ddad1-c91a-4f0a-9aca-e20682cc8969&skv=2019-02-02&sv=2018-11-09&sr=b&sp=r&spr=https%2Chttp&sig=p4aMqXqkP%2FI1IhOVGCB9JL8vUUvfNBBF12ESpKhKXOk%3D&az=oaivgprodscus",
        "state": "succeeded"
      }
    ]
  }
}
```

반환 결과는 여러 필드로 구성되어 있으며, request 필드는 작업을 시작할 때의 request body를 나타내고, response 필드는 작업 완료 후 반환된 response body를 나타냅니다. 필드 설명은 다음과 같습니다.

* `id`: 이 비디오 작업을 생성한 ID로, 이번 비디오 생성 작업을 고유하게 식별하는 데 사용됩니다.
* `request`: 비디오 작업의 요청 정보를 조회합니다.
* `response`: 비디오 작업의 반환 정보를 조회합니다.

## 배치 조회 작업

이는 여러 작업 ID에 대해 비디오 작업 세부 정보를 조회하는 것으로, 위와는 다르게 action을 retrieve\_batch로 선택해야 합니다.

**Request Body**에는 다음이 포함됩니다:

* `ids`: 업로드된 작업 ID 배열.
* `action`: 작업에 대한 조작 방식.

아래 그림과 같이 설정합니다:

<p>
  <img src="https://cdn.xhuoapi.ai/9cf4j8.png" width="500" className="m-auto" />
</p>

### 코드 예시

可以发现，在页面右侧已经自动生成了各种语言的代码，如图所示：

<p>
  <img src="https://cdn.xhuoapi.ai/8ci2tg.png" width="500" className="m-auto" />
</p>

部分代码示例如下：

### 응답 예시

요청 성공 후, API는 이번 모든 배치 비디오 작업의 구체적인 세부 정보를 반환합니다. 예를 들어:

```json theme={null}
{
  "items": [
    {
      "_id": "68e914aa550a4144a5788305",
      "id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
      "api_id": "54aed96c-0346-4227-8c99-9780247a7ffd",
      "application_id": "f10c04c2-2273-4463-bd3f-593d71b75ac8",
      "created_at": 1760105642.045,
      "credential_id": "4e6e181d-f320-4874-8d80-fc2253b40b7e",
      "request": {
        "size": "large",
        "duration": 15,
        "orientation": "landscape",
        "prompt": "cat running on the river",
        "model": "sora-2",
        "image_urls": [
          "https://cdn.xhuoapi.ai/11wfp4.png"
        ],
        "callback_url": "https://webhook.site/eb238c4f-da3b-47a5-a922-a93aa5405daa"
      },
      "trace_id": "fb751e1e-4705-49ea-9fd4-5024b7865ea2",
      "type": "videos",
      "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
      "response": {
        "success": true,
        "task_id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
        "trace_id": "fb751e1e-4705-49ea-9fd4-5024b7865ea2",
        "data": [
          {
            "id": "sora-2:task_01k777hjrbfrgs2060q5zvf2a5",
            "video_url": "https://filesystem.site/gptimage/vg-assets/assets%2Ftask_01k777hjrbfrgs2060q5zvf2a5%2Ftask_01k777hjrbfrgs2060q5zvf2a5_genid_b8e2e5d1-a579-49ca-a21c-cb3869685cce_25_10_10_14_15_147334%2Fvideos%2F00000%2Fsrc.mp4?st=2025-10-10T12%3A38%3A49Z&se=2025-10-16T13%3A38%3A49Z&sks=b&skt=2025-10-10T12%3A38%3A49Z&ske=2025-10-16T13%3A38%3A49Z&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skoid=aa5ddad1-c91a-4f0a-9aca-e20682cc8969&skv=2019-02-02&sv=2018-11-09&sr=b&sp=r&spr=https%2Chttp&sig=p4aMqXqkP%2FI1IhOVGCB9JL8vUUvfNBBF12ESpKhKXOk%3D&az=oaivgprodscus",
            "state": "succeeded"
          }
        ]
      }
    },
    {
      "_id": "68e914aa550a4144a5788305",
      "id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
      "api_id": "54aed96c-0346-4227-8c99-9780247a7ffd",
      "application_id": "f10c04c2-2273-4463-bd3f-593d71b75ac8",
      "created_at": 1760105642.045,
      "credential_id": "4e6e181d-f320-4874-8d80-fc2253b40b7e",
      "request": {
        "size": "large",
        "duration": 15,
        "orientation": "landscape",
        "prompt": "cat running on the river",
        "model": "sora-2",
        "image_urls": [
          "https://cdn.xhuoapi.ai/11wfp4.png"
        ],
        "callback_url": "https://webhook.site/eb238c4f-da3b-47a5-a922-a93aa5405daa"
      },
      "trace_id": "fb751e1e-4705-49ea-9fd4-5024b7865ea2",
      "type": "videos",
      "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
      "response": {
        "success": true,
        "task_id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea",
        "trace_id": "fb751e1e-4705-49ea-9fd4-5024b7865ea2",
        "data": [
          {
            "id": "sora-2:task_01k777hjrbfrgs2060q5zvf2a5",
            "video_url": "https://filesystem.site/gptimage/vg-assets/assets%2Ftask_01k777hjrbfrgs2060q5zvf2a5%2Ftask_01k777hjrbfrgs2060q5zvf2a5_genid_b8e2e5d1-a579-49ca-a21c-cb3869685cce_25_10_10_14_15_147334%2Fvideos%2F00000%2Fsrc.mp4?st=2025-10-10T12%3A38%3A49Z&se=2025-10-16T13%3A38%3A49Z&sks=b&skt=2025-10-10T12%3A38%3A49Z&ske=2025-10-16T13%3A38%3A49Z&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skoid=aa5ddad1-c91a-4f0a-9aca-e20682cc8969&skv=2019-02-02&sv=2018-11-09&sr=b&sp=r&spr=https%2Chttp&sig=p4aMqXqkP%2FI1IhOVGCB9JL8vUUvfNBBF12ESpKhKXOk%3D&az=oaivgprodscus",
            "state": "succeeded"
          }
        ]
      }
    }
  ],
  "count": 2
}
```

반환 결과는 여러 필드로 구성되어 있으며, 그 중 items는 배치 비디오 작업의 구체적인 세부 정보를 포함하고 있습니다. 각 비디오 작업의 구체적인 정보는 위의 필드와 동일하며, 필드 정보는 다음과 같습니다.

* `items`, 배치 비디오 작업의 모든 구체적인 세부 정보. 이는 배열이며, 각 배열의 요소는 위에서 단일 작업의 반환 결과 형식과 동일합니다.
* `count`, 여기서 배치 쿼리 비디오 작업의 개수입니다.

#### CURL

```bash theme={null}
curl -X POST 'https://api.xhuoapi.ai/v1/sora/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "ids": ["b8976e18-32dc-4718-9ed8-1ea090fcb6ea","b8976e18-32dc-4718-9ed8-1ea090fcb6ea"],
  "action": "retrieve_batch"
}'
```

#### Python

```python theme={null}
import requests

url = "https://api.xhuoapi.ai/v1/sora/tasks"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "ids": ["b8976e18-32dc-4718-9ed8-1ea090fcb6ea","b8976e18-32dc-4718-9ed8-1ea090fcb6ea"],
    "action": "retrieve_batch"
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)
```

## 오류 처리

API를 호출할 때 오류가 발생하면, API는 해당 오류 코드와 정보를 반환합니다. 예를 들어:

* `400 token_mismatched`：잘못된 요청, 누락되었거나 잘못된 매개변수 때문일 수 있습니다.
* `400 api_not_implemented`：잘못된 요청, 누락되었거나 잘못된 매개변수 때문일 수 있습니다.
* `401 invalid_token`：권한 없음, 잘못되었거나 누락된 인증 토큰입니다.
* `429 too_many_requests`：요청이 너무 많음, 비율 제한을 초과했습니다.
* `500 api_error`：내부 서버 오류, 서버에서 문제가 발생했습니다.

### 오류 응답 예시

```json theme={null}
{
  "success": false,
  "error": {
    "code": "api_error",
    "message": "fetch failed"
  },
  "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}
```

## 결론

이 문서를 통해 Sora Tasks API를 사용하여 단일 또는 배치 비디오 작업을 쿼리하는 모든 구체적인 세부 정보를 이해하게 되었습니다. 이 문서가 API를 더 잘 연결하고 사용하는 데 도움이 되기를 바랍니다. 질문이 있으시면 언제든지 기술 지원 팀에 문의해 주십시오.
