# 语音合成 - 任务查询 API Documentation

> 查询语音合成任务结果。配合语音合成创建接口使用，创建后用 task_id 轮询。查询不扣费。

## Overview

This document describes how to call the **语音合成 - 任务查询** API.

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

## 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**: `GET https://apis.xiaobao.ink/api/aihuman/tts_query`
- **Content-Type**: `application/json` (request body commonly `application/json` or `application/x-www-form-urlencoded` for POST)
- **HTTP Method**: `GET`

### Request Parameters

| Parameter | Required | Description |
|-----------|----------|-------------|
| `task_id` | Yes | 语音合成创建接口返回的任务ID |

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

### Request Example

```
https://apis.xiaobao.ink/api/aihuman/tts_query?task_id=你的task_id&key=你的密钥
```

## Details

## 接口说明：

配合语音合成创建接口使用。创建任务后，用返回的 task_id 查询结果。音频与字幕会转存到本站，请及时下载。查询不扣费。

关联接口：[语音合成](/doc/10)

## 请求参数说明：

| 名称 | 必填 | 类型 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| task_id | 是 | string | t546950c297cde85 | 语音合成创建接口返回的任务ID |

## 返回参数说明：

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| code | int | 状态码，200 表示查询成功 |
| msg | string | 状态信息 |
| data | object | 结果数据 |
| - task_id | string | 任务id |
| - status | int | 0 处理中，1 成功，2 失败 |
| - audio_url | string | 结果音频url。成功时有值，已转存到本站 |
| - audio_duration | int | 声音时长（毫秒），例如 52886。未完成时为 0 |
| - srt_url | string | 本音频配套的字幕文件url。成功且返回时有值 |
| - fail_reason | string | 失败原因，仅失败时有值 |

处理中请间隔数秒再次查询。

## Response Example

```json
{
    "code": 200,
    "msg": "查询成功",
    "data": {
        "task_id": "t546950c297cde85",
        "status": 1,
        "audio_url": "https://apis.xiaobao.ink/upload/audio/2026/09/19/demo.mp3",
        "audio_duration": 52886,
        "srt_url": "https://apis.xiaobao.ink/upload/audio/2026/09/19/demo.srt",
        "fail_reason": ""
    }
}
```

## Error Codes

| HTTP 响应状态码 | 说明 |
| --- | --- |
| 200 | 请求成功 |
| 400 | 参数错误，或任务不存在 |
| 401 | 认证失败，请检查 key |

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