# AI视频翻译-创建导出任务 API Documentation

> 创建最终视频导出任务，将翻译后的音频与原视频合成，生成带字幕的最终翻译视频；

## Overview

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

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

## 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/generate`
- **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 |
|-----------|----------|-------------|
| `video_url` | Yes | 视频URL |
| `audio_url` | Yes | 音频URL |
| `preview_task_id` | No | 预览任务ID（可选） |
| `subtitles` | Yes | 字幕列表 |
| `subtitle_style` | Yes | 字幕样式 |

> **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/generate?key=你的密钥
```

## Details

## 请求参数说明：

| 名称 | 必填 | 类型 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| video_url | 是 | string | https://example.com/video.mp4 | 原始视频URL |
| audio_url | 是 | string | https://example.com/audio.mp3 | 翻译后的音频URL |
| preview_task_id | 否 | string | abc123-def456 | 关联的预览任务ID |
| subtitles | 否 | array | [{"start":0,"end":1830,"text":"你好"}] | 字幕列表 |
| subtitle_style | 否 | object | {"font_size":20,"font_color":"(255,255,255,1)"} | 字幕样式配置：alignment(对齐)、font_size(字体大小)、font_color(字体颜色)等 |

## Response Example

```json
{
    "code": 200,
    "msg": "任务已提交",
    "data": {
        "id": 3,
        "task_id": "generate-task-789",
        "status": 1,
        "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}`)._
