# AI视频翻译-创建预览任务 API Documentation

> 创建视频翻译预览任务，智能提取视频字幕并翻译，以JSON格式返回原声字幕和翻译字幕；

## Overview

This document describes how to call the **AI视频翻译-创建预览任务** API.

- **Model / path slug**: `video_translation/preview`
- **Task type**: `sync` (`sync` = synchronous, `async` = create task then poll / callback)
- **HTML docs**: `/doc/33`

## Authentication

All API requests require your platform API key as the query parameter `key`:

```
?key=YOUR_API_KEY
```

Get API Key:
1. Sign in to the console
2. Open [API Key Management](/user/key) and create or copy your key
3. Append `key=YOUR_API_KEY` to the request URL (or pass it in form/JSON when the endpoint accepts it)

---

## API Information

- **URL**: `POST https://apis.xiaobao.ink/api/video_translation/preview`
- **Content-Type**: `application/json` (request body commonly `application/json` or `application/x-www-form-urlencoded` for POST)
- **HTTP Method**: `POST`

### Request Parameters

| Parameter | Required | Description |
|-----------|----------|-------------|
| `url` | Yes | 视频URL |
| `language` | Yes | 目标翻译语言 |
| `original_srt_url` | No | 原始SRT字幕URL（可选） |
| `translate_srt_url` | No | 翻译SRT字幕URL（可选） |
| `speaker_identification` | No | 区分说话人（可选） |
| `voice` | No | 音色标识（可选） |

> **Note**: `key` (API key) is required for authenticated calls even if omitted from the parameter list above.

### Request Example

```
https://apis.xiaobao.ink/api/video_translation/preview?key=你的密钥
```

## Details

## 请求HEADER：

| 名称 | 值 |
| --- | --- |
| Content-Type | application/json |

## 请求参数说明：

| 名称 | 必填 | 类型 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| url | 是 | string | https://example.com/video.mp4 | 视频URL，必须为可解析的HTTP/HTTPS协议URL |
| language | 是 | string | en-US | 目标翻译语言，如：zh-CN、en-US、en |
| original_srt_url | 否 | string | https://example.com/original.srt | 原始SRT字幕文件URL |
| translate_srt_url | 否 | string | https://example.com/translate.srt | 翻译SRT字幕文件URL |
| speaker_identification | 否 | int | 0 | 区分说话人。0-不区分(默认)，1-区分说话人 |
| voice | 否 | string | cv_longanhuan | 音色标识 |

## Response Example

```json
{
    "code": 200,
    "msg": "任务已提交",
    "data": {
        "id": 1,
        "task_id": "abc123-def456-ghi789",
        "status": 1,
        "video_duration": 90,
        "power_cost": 40,
        "progress": 0
    }
}
```

## Error Codes

| Status / code | Description |
|---------------|-------------|
| 200 / success | Request successful |
| 400 | Invalid request parameters |
| 401 | Authentication failed, please check API Key |
| 402 | Insufficient account balance / points |
| 429 | Request rate limit exceeded |
| 500 | Internal server error |

## Usage Flow

1. Obtain your API Key from the console
2. Call the endpoint with `key` and required parameters
3. Parse the JSON (or binary) response according to the examples above

---

_Generated for AI / LLM consumption. Source of truth: `api_list` (same as HTML `/doc/{id}`)._
