# 运行 AI 音乐生成任务。

AI 任务是异步处理的。功能支持 Webhook 时，优先用 Webhook 来接收完成通知。配置好您的 Webhook 端点、校验 Webhook 签名，收到 `success` 或 `error` 通知后，用收到的 `task_id` 查询任务结果。配置与校验的细节请见 [Webhook 接入指南](/develop/webhook)。
若功能不支持 Webhook，或您的接入方式用不了 Webhook，就请实现轮询。提交 AI 任务后，按固定间隔（例如每 10 秒）轮询状态接口，直到任务状态变为 `success` 或 `error`。

Endpoint: POST /s2s/v2.0/task/ai-song
Security: BearerAuthenticationV2

## Security:

  - `BearerAuthenticationV2` (unknown)
    http bearer

## Request fields (application/json):

  - `idea` (string)
    歌曲主题。instrumental 为 true 时必填。带人声的歌曲请提供 idea、lyrics 或两者。 想要特定语言的歌词，就在这里提出（例如 "with Japanese lyrics"）。
    Example: A song about a small café that stays open late for people who can't sleep

  - `lyrics` (string)
    歌曲歌词。支持 [intro]、[verse]、[chorus]、[outro] 等段落标签。支持的歌词语言： 英语、日语、韩语、葡萄牙语、西班牙语、德语、法语、意大利语、繁体中文、简体中文、印地语、土耳其语。
    Example: [verse]
Two a.m., the neon hums
Steam on the glass, the night still runs

[chorus]
Leave the light on, leave the light on
For the ones who don't go home

  - `music_style` (object)
    歌曲的音乐风格。所有字段均可选。

  - `music_style.genre` (string)
    歌曲曲风，例如 Pop、Lo-fi Hip Hop
    Example: Acoustic Pop

  - `music_style.mood` (string)
    歌曲情绪，例如 Calm、Uplifting
    Example: Calm, hopeful

  - `music_style.vocal` (string)
    人声类型。instrumental 为 true 时忽略。
    Enum: "female", "male"

  - `music_style.description` (string)
    其他细节，例如乐器或节奏。
    Example: soft piano, brushed drums

  - `instrumental` (boolean)
    设为 true 生成无人声、无歌词的纯音乐。
    Example: false

  - `idea` (any, required)

  - `lyrics` (any, required)

  - `instrumental` (string)
    Enum: "false"

## Response 200:

  - `200` (unknown)
    任务运行成功

## Response 200 fields (application/json):

  - `status` (integer)
    响应状态
    Example: 200

  - `data` (object)

  - `data.task_id` (string)
    该任务的 ID。凭这个 ID 可在 30 天内查询任务结果。
    Example: grH0CvsgXuAIHLUzD0V1Ol34hoet3R1tvdbtiVHrDb6_UqCLKIejAIajwxrhOAfe

## Response 400:

  - `400` (unknown)
    任务运行失败

## Response 400 fields (application/json):

  - `status` (integer)
    响应状态
    Example: 400

  - `error` (string)
    错误信息
    Example: The operation could not be completed

  - `error_code` (string)
    错误码：
* InvalidParameters - 请求参数无效
* CreditInsufficiency - 点数不足，无法运行
* BadRequest - 请求参数不符合预期
* InvalidStyleGroup - 风格分组 ID 无效
* InvalidStyle - 风格 ID 无效
    Enum: "InvalidParameters", "CreditInsufficiency", "InvalidStyleGroup", "InvalidStyle", "BadRequest"

## Response 401:

  - `401` (unknown)
    API 密钥无效或缺失

## Response 401 fields (application/json):

  - `status` (integer)
    响应状态
    Example: 401

  - `error` (string)
    Example: Invalid API key

## Response 429:

  - `429` (unknown)
    请求过多

## Response 429 fields (application/json):

  - `status` (integer)
    响应状态
    Example: 429

  - `error` (string)
    Example: Too many requests

