# AI视频 - 角色创建 API Documentation

> 创建AI视频的人物角色

## Overview

This document describes how to call the **AI视频 - 角色创建** API.

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

## 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/character`
- **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 |
|-----------|----------|-------------|
| `pid` | Yes | 视频pid 生成视频结果的pid值(可以出现真人形象，pid和视频地址参数二选一即可） |
| `url` | Yes | 视频URL（禁止出现真人形象，视频地址可公网访问下载，视频时长不要过长） |
| `timestamps` | Yes | 视频取用角色出现的时间范围 格式: 开始秒数,结束秒数,最多3秒 |
| `notify` | 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/character?key=你的密钥
```

## Details

## 请求HEADER：

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

## 请求参数说明：

| 名称 | 必填 | 类型 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| pid | 否 | string | s_6933c62623048191a0f20b5dbe781888 | 视频pid AI生成视频结果的pid值(可以出现真人形象，pid和视频地址参数二选一即可） |
| url | 否 | string | https://ope.oss-cn-shanghai.aliyuncs.com/9d1212e12.mp4 | 视频URL（禁止出现真人形象，视频地址可公网访问下载，视频时长不要过长） |
| timestamps | 否 | string | 0,3 | 视频取用角色出现的时间范围 格式: 开始秒数,结束秒数,最多3秒 |
| notify | 是 | string | https://xx.com/xxx | 回调地址 （ 任务推送地址） |

## 返回参数说明：

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| code | int | 状态码 |
| msg | string | 状态信息 |
| data | array | 请求结果数据集 |
| - task_id | string  | 任务ID |
| exec_time | float | 执行耗时 |
| user_ip | string | 客户端IP |

回调参数说明：

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| code | int | 状态码 |
| msg | string | 状态信息 |
| data | array | 请求结果数据集 |
| - task_id | string  | 任务ID |
| - character_id | string | character.name  character_id: 角色id |
| - failure_reason | string | 失败原因 "output_moderation": 输出违规 "input_moderation": 输入违规 "error": 其他错误 ------ 当生成失败时，会返还积分 |
| - error | string | 失败详细信息 |
| exec_time | float | 执行耗时 |
| user_ip | string | 客户端IP |

## Response Example

```json
{
    "code": 200,
    "msg": "xxxx",
    "data": [
        {
            "task_id": "xxxxx",
            "character_id": "character.name",
            "failure_reason": "",
            "error": ""
        }
    ]
}
```

## 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}`)._
