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

# 获取 Kling 文生视频任务状态

> <ul><li>查询 Kling 文生视频任务的状态和结果。</li></ul>

<RequestExample>
  ```bash cURL theme={null} theme={null}
  curl --request GET \
    --url 'https://api.elkapi.com/kling/v1/videos/text2video/task_1234567890' \
    --header 'Authorization: Bearer <token>'
  ```

  ```python Python theme={null} theme={null}
  import requests

  url = "https://api.elkapi.com/kling/v1/videos/text2video/task_1234567890"
  headers = {
      "Authorization": "Bearer <token>"
  }

  response = requests.request("GET", url, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null} theme={null}
  const url = "https://api.elkapi.com/kling/v1/videos/text2video/task_1234567890";

  const headers = {
    "Authorization": "Bearer <token>"
  };

  const response = await fetch(url, { method: "GET", headers });
  console.log(await response.json());
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null} theme={null}
  {
    "task_id": "task_1234567890",
    "status": "completed",
    "url": "https://example.com/image.png",
    "format": "mp4",
    "metadata": {
      "duration": 5,
      "fps": 30,
      "width": 1280,
      "height": 720,
      "seed": 12345
    },
    "error": {
      "code": 1,
      "message": "message"
    }
  }
  ```

  ```json 404 theme={null} theme={null}
  {
    "error": {
      "message": "message",
      "type": "type",
      "param": "param",
      "code": "code"
    }
  }
  ```
</ResponseExample>

## Authorizations

<ParamField header="Authorization" type="string" required>
  所有接口均需要使用 Bearer Token 进行认证。

  在请求头中添加：

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Path Parameters

<ParamField path="task_id" type="string" required>
  任务 ID
</ParamField>

## Response

<ResponseField name="task_id" type="string">
  任务 ID

  示例：`abcd1234efgh`
</ResponseField>

<ResponseField name="status" type="string">
  任务状态

  可选值：`queued`、`in_progress`、`completed`、`failed`

  示例：`completed`
</ResponseField>

<ResponseField name="url" type="string">
  视频资源 URL（成功时）

  示例：`https://example.com/video.mp4`
</ResponseField>

<ResponseField name="format" type="string">
  视频格式

  示例：`mp4`
</ResponseField>

<ResponseField name="metadata" type="object">
  视频任务元数据

  <ResponseField name="metadata.duration" type="number">
    实际生成的视频时长

    示例：`5`
  </ResponseField>

  <ResponseField name="metadata.fps" type="integer">
    实际帧率

    示例：`30`
  </ResponseField>

  <ResponseField name="metadata.width" type="integer">
    实际宽度

    示例：`1280`
  </ResponseField>

  <ResponseField name="metadata.height" type="integer">
    实际高度

    示例：`720`
  </ResponseField>

  <ResponseField name="metadata.seed" type="integer">
    使用的随机种子

    示例：`20231234`
  </ResponseField>
</ResponseField>

<ResponseField name="error" type="object">
  视频任务错误信息

  <ResponseField name="error.code" type="integer">
    错误码
  </ResponseField>

  <ResponseField name="error.message" type="string">
    错误信息
  </ResponseField>
</ResponseField>
