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

# HappyWan API：生成最长 45 秒的视频

> 使用 HappyWan API，可通过文本、关键帧，或图像、视频及音频参考素材，生成最长 45 秒的 480p 或 720p 视频。

## 概览

HappyWan 可生成 4–45 秒的 480p 或 720p 视频。你可以根据文本生成场景、用首尾帧生成动态画面，也可以结合不同类型的参考素材来引导视频生成。开启声音后，可生成与画面同步的对白、音效或音乐。

| 设置 | 值 |
| - | - |
| 模型 ID | `happywan` |
| Base URL | `https://api.apixo.ai/api/v1` |

## 端点和身份验证

每次请求都需要发送 `Authorization: Bearer YOUR_API_KEY`。创建任务时还需要发送 `Content-Type: application/json`。

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/happywan` | 提交视频生成任务 |
| `GET` | `/statusTask/happywan?taskId={taskId}` | 查询状态并获取结果 |

## 生成视频

### 文生视频

此请求生成一段 45 秒的视频，音频与画面同步。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/happywan" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video",
      "prompt": "First 15 seconds: follow a cyclist in a yellow raincoat along a wet riverside path. Next 15 seconds: show the cyclist ringing the bell on a bridge. Final 15 seconds: pull back to reveal the bridge lights reflected in the river. Include light rain and a clear bell ring.",
      "resolution": "720p",
      "aspect_ratio": "16:9",
      "duration": 45,
      "sound": true
    }
  }'
```

### 首尾帧

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "first_and_last_frames",
    "prompt": "Move smoothly from the street-level view to the wide skyline.",
    "image_urls": ["https://example.com/first-frame.jpg", "https://example.com/last-frame.jpg"],
    "duration": 8,
    "aspect_ratio": "auto"
  }
}
```

### 多模态参考

```json theme={null}
{
  "request_type": "callback",
  "callback_url": "https://example.com/webhooks/apixo",
  "input": {
    "mode": "omni_reference",
    "prompt": "Keep the product from the image recognizable, follow the camera movement in the video, and time the reveal to the audio cue.",
    "image_urls": ["https://example.com/product.jpg"],
    "video_urls": ["https://example.com/camera-movement.mp4"],
    "audio_urls": ["https://example.com/reveal-cue.mp3"],
    "duration": 12,
    "resolution": "480p"
  }
}
```

## 参数

**request\_type** `string` (default: async)

结果交付方式。`async` 表示通过轮询获取结果，`callback` 表示通过 Webhook 接收结果。

**callback\_url** `string`

用于接收任务最终数据的公开 HTTPS URL。`request_type` 为 `callback` 时必填。

**input** `object` *required*

HappyWan 的生成参数。

**属性**

**mode** `string` *required*

生成模式。可选值为 `text-to-video`、`first_and_last_frames`、`omni_reference`。

**prompt** `string` *required*

描述所需视频的文本，不可为空，最多 10,000 个字符。

**duration** `integer` (default: 5)

输出视频的时长，单位为秒。请填入 4 到 45 之间的整数，含两端。

**resolution** `string` (default: 720p)

输出分辨率。可选值为 `480p`、`720p`。

**aspect\_ratio** `string` (default: auto)

输出宽高比。支持 `auto`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16` 和 `21:9`。在 `first_and_last_frames` 模式下，设为 `auto` 或省略此字段。

**sound** `boolean` (default: true)

设为 `false` 可生成无声视频。

**watermark** `boolean` (default: false)

设为 `true` 可添加可见水印。

**image\_urls** `string[]`

可公开访问的图像 URL。`first_and_last_frames` 模式可提供一张起始帧，或按首帧、尾帧的顺序提供两张图像。`omni_reference` 模式最多接收 10 张参考图像。

**video\_urls** `string[]`

在 `omni_reference` 模式下，可提供最多五个可公开访问的参考视频 URL。每段参考视频须为 2–30 秒，所有参考视频总时长不得超过 30 秒。

**audio\_urls** `string[]`

在 `omni_reference` 模式下，可提供最多五个可公开访问的参考音频 URL。每段参考音频须为 2–30 秒，所有参考音频总时长不得超过 30 秒。提供音频时，须同时提供至少一张参考图像或一段参考视频。

### 各模式的输入要求

| 模式 | 要求 |
| - | - |
| `text-to-video` | 提供提示词，省略媒体字段。 |
| `first_and_last_frames` | 提供提示词，并在 `image_urls` 中填入一个或两个 URL。将 `aspect_ratio` 设为 `auto` 或省略该字段。 |
| `omni_reference` | 提供提示词，并在 `image_urls` 或 `video_urls` 中至少填入一个 URL。可用 `audio_urls` 引导声音生成。 |

## 延迟与轮询

创建任务后会返回 `data.taskId`。用该 ID 调用状态查询端点。

```bash theme={null}
curl "https://api.apixo.ai/api/v1/statusTask/happywan?taskId=YOUR_TASK_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

| 结果交付方式 | 如何获取结果 |
| - | - |
| 轮询 | `data.state` 为 `pending` 或 `processing` 时继续轮询。状态为 `success` 时，将 `data.resultJson` 解析为 JSON，从 `resultUrls` 读取视频 URL。状态为 `failed` 时，读取 `data.failCode` 和 `data.failMsg`。 |
| Webhook | 将 `request_type` 设为 `callback`，并提供 `callback_url`，用于接收任务的最终结果。 |

较长的视频或参考素材较多的请求可能需要更长时间。使用回调模式可在任务完成时收到结果。结果 URL 为临时链接。如需长期保留，请下载 MP4 文件。通用任务生命周期和结果格式见 [查询任务状态](https://apixo.ai/docs/zh/api-reference/status-task.md) 与 [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

## 计费

每秒费用取决于分辨率和请求是否包含参考视频。费率见 [API 定价](https://apixo.ai/pricing/api)，每次请求的总费用如何取整见 [积分换算与取整](https://apixo.ai/docs/zh/pricing.md#credit-conversion-and-rounding)。

## MCP 集成

[模型 Schema](https://apixo.ai/docs/models/schemas/video/happywan.json) 在 `mcp.result` 中声明视频结果的解码方式，并在 `mcp.attachments` 中声明 `image_urls`、`video_urls` 和 `audio_urls` 的有序附件绑定。请保留帧图像的顺序。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.