跳转至

MaaS_Lyria

模型说明

能力 说明
文生音乐 根据文本 prompt 生成音乐,同步返回
输出形态 音频(inlineData,如 audio/mpeg)+ 文本(歌词/结构标注)
接口风格 Vertex generateContent 原生 JSON;可选 OpenAI chat/completions 兼容
流式 不支持
异步轮询 不支持

1 文生音乐 — generateContent

1.1 请求 URL

POST https://genaiapi-m2.cloudsway.net/v1/ai/{endpointPath}/music/generateContent

1.2 请求 Header

Authorization: Bearer {your AK}

Content-Type: application/json

1.3 请求 Body

字段 必填
contents
contents[].parts[].text
contents[].role
generationConfig.responseModalities

请求示例

curl --location --request POST 'https://genaiapi-m2.cloudsway.net/v1/ai/{endpointPath}/music/generateContent' \
--header 'Authorization: Bearer ${your AK} 
--header 'Content-Type: application/json' 
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Upbeat pop song about a summer road trip, catchy chorus, female vocal"
        }
      ]
    }
  ],
  "generationConfig": {
    "responseModalities": ["AUDIO", "TEXT"]
  }
}

1.4 成功响应参数

成功时返回:

字段 说明
candidates[].content.parts[].text 歌词 / 结构文本
candidates[].content.parts[].inlineData.mimeType 如 audio/mpeg
candidates[].content.parts[].inlineData.data 音频 base64
candidates[].finishReason 如 STOP
usageMetadata token 用量

成功响应样例

curl --location --request POST 'https://genaiapi-m2.cloudsway.net/v1/ai/{endpointPath}/music/generateContent' \
--header 'Authorization: Bearer ${your AK} 
--header 'Content-Type: application/json' 
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "[Verse]\n...\n[Chorus]\n..."
          },
          {
            "inlineData": {
              "mimeType": "audio/mpeg",
              "data": "<base64-encoded-mp3>"
            }
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 14,
    "candidatesTokenCount": 3199,
    "totalTokenCount": 3213
  },
  "responseId": "******"
}

2 原生 Vertex v1beta1 — generateContent

2.1 请求 URL

POST https://genaiapi-m2.cloudsway.net/{endpointPath}/music/v1beta1/publishers/google/models/{modelName}:generateContent

2.2 请求 Body

与 1 相同;URL 中 {modelName} 会写入请求 model 字段。


3 OpenAI 兼容 — google/chat/completions

3.1 请求 URL

POST https://genaiapi-m2.cloudsway.net/v1/ai/{endpointPath}/music/google/chat/completions

3.2 请求 Header

Authorization: Bearer {平台 AK}

Content-Type: application/json

3.3 请求 Body

字段 必填 说明
model MaaS_Lyria_3_pro_preview
stream 必须为 false 或省略;不支持流式
messages OpenAI 消息数组
modalities 建议 ["audio", "text"]

请求示例

curl --location --request POST 'https://genaiapi-m2.cloudsway.net/v1/ai/{endpointPath}/music/generateContent' \
--header 'Authorization: Bearer ${your AK} 
--header 'Content-Type: application/json' 
{
  "model": "MaaS_Lyria_3_pro_preview",
  "stream": false,
  "messages": [
    {
      "role": "user",
      "content": "Upbeat pop song about a summer road trip, catchy chorus, female vocal"
    }
  ],
  "modalities": ["audio", "text"]
}

3.4 成功响应参数

OpenAI chat/completions 格式:

字段 说明
choices[0].message.content 歌词文本
choices[0].message.audio.data 音频 base64
choices[0].finish_reason 如 stop
usage token 统计

4 OpenAI 兼容 — chat/completions(端点路径模式)

4.1 请求 URL

POST https://genaiapi-m2.cloudsway.net/v1/ai/{endpointPath}/music/chat/completions

Body 同 3。


5 OpenAI 兼容 — chat/completions(兼容模式)

5.1 请求 URL

POST https://genaiapi-m2.cloudsway.net/v1/music/chat/completions

请求示例

curl --location --request POST 'https://genaiapi-m2.cloudsway.net/v1/ai/{endpointPath}/music/generateContent' \
--header 'Authorization: Bearer ${your AK} 
--header 'Content-Type: application/json' 
{
  "model": "MaaS_Lyria_3_pro_preview",
  "stream": false,
  "messages": [
    {
      "role": "user",
      "content": "Upbeat pop song about a summer road trip"
    }
  ],
  "modalities": ["audio", "text"]
}