{"predictions":[{"audioContent":"BASE64_ENCODED_WAV_STRING_SAMPLE_1","mimeType":"audio/wav"}// Additional audio samples will be listed here if sample_count > 1// e.g.,//{"audioContent": "BASE64_ENCODED_WAV_STRING_SAMPLE_2",// "mimeType": "audio/wav"//}],"deployedModelId":"xxxxxxxxxxxxxxx",// Actual ID may vary based on deployment"model":"projects/PROJECT_ID/locations/LOCATION/publishers/google/models/lyria-002","modelDisplayName":"Lyria 2"}
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-02 (世界標準時間)。"],[],[],null,["# Lyria API\n\nLyria is a new foundation model for high-quality audio\ngeneration, capable of creating diverse soundscapes and musical pieces from text\nprompts. Lyria enables users to generate high-quality\ninstrumental music from text prompts.\n\nTo explore this model in the console, see the Lyria model card in\nthe Model Garden (accessible using the Media Studio tab).\n\n[Try Lyria on Vertex AI (Vertex AI Studio)](https://console.cloud.google.com/vertex-ai/studio/media/generate;tab=music)\n\n\n[Try Lyria in a Colab](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/audio/music/getting-started/lyria2_music_generation.ipynb)\n\nSupported Models\n----------------\n\nThe Lyria API supports the following model:\n\n- `lyria-002`\n\nHTTP request\n------------\n\n curl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n https://\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e[-aiplatform.googleapis.com/v1/projects/](https://-aiplatform.googleapis.com/v1/projects/)\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e/publishers/google/models/lyria-002:predict \\\n -d '{\n \"instances\": [\n {\n \"prompt\": \"string\",\n \"negative_prompt\": \"string\", // Optional\n \"seed\": 0 // Optional. Cannot be used with sample_count.\n }\n ],\n \"parameters\": {\n \"sample_count\": 1 // Optional. Cannot be used with seed.\n }\n }'\n\nUse the following parameters for the Lyria model. For more\ninformation, see the Lyria Model Garden card details.\n\nSample request\n--------------\n\nUse the following request to generate instrumental music from a text prompt:\n\n### Text-to-music generation request\n\n### curl\n\n```\ncurl -X POST \\\n-H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n-H \"Content-Type: application/json\" \\\nhttps://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/lyria-002:predict \\\n-d '{\n \"instances\": [\n {\n \"prompt\": \"A calm acoustic folk song with a gentle guitar melody and soft strings.\",\n \"negative_prompt\": \"drums, electric guitar\",\n \"seed\": 98765\n }\n ],\n \"parameters\": {}\n}'\n```\n\n### JSON\n\nThis example uses `seed` for reproducible output. \n\n```\n\n{\n \"instances\": [\n {\n \"prompt\": \"A calm acoustic folk song with a gentle guitar melody and soft strings.\",\n \"negative_prompt\": \"drums, electric guitar\",\n \"seed\": 98765\n }\n ],\n \"parameters\": {}\n}\n\n```\n\n### JSON with sample_count\n\nThis example uses `sample_count` to generate multiple samples.\n\nTo test a text prompt using the Lyria API, send a POST request to\nthe publisher model endpoint. The following example omits `seed` from the `instances` object and uses `sample_count` in the `parameters` object to generate multiple samples. \n\n```\n\n{\n \"instances\": [\n {\n \"prompt\": \"A calm acoustic folk song with a gentle guitar melody and soft strings.\",\n \"negative_prompt\": \"drums, electric guitar\"\n }\n ],\n \"parameters\": {\n \"sample_count\": 2\n }\n}\n\n```\n\nResponse body\n-------------\n\nA successful request returns a JSON object containing the generated audio data.\nEach generated audio clip is 30 seconds long and provided as a WAV audio file at\na 48kHz sample rate. \n\n {\n \"predictions\": [\n {\n \"audioContent\": \"BASE64_ENCODED_WAV_STRING_SAMPLE_1\",\n \"mimeType\": \"audio/wav\"\n }\n // Additional audio samples will be listed here if sample_count \u003e 1\n // e.g.,\n //{\"audioContent\": \"BASE64_ENCODED_WAV_STRING_SAMPLE_2\",\n // \"mimeType\": \"audio/wav\"\n //}\n ],\n \"deployedModelId\": \"xxxxxxxxxxxxxxx\", // Actual ID may vary based on deployment\n \"model\": \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e/publishers/google/models/lyria-002\",\n \"modelDisplayName\": \"Lyria 2\"\n }\n\nBest practices and limitations\n------------------------------\n\nRefer to the Lyria Model Card for detailed best practices on\nprompting, language support (US English only for prompts), generation times,\noutput format (WAV, 48 kHz, 30s instrumental clips), safety measures, and\ndeployment information.\n\nKey points:\n\n- **Detailed Prompts:** Generally lead to better audio.\n- **Specify:** Genre, mood, instrumentation, tempo.\n- **Negative Prompting:** Use `negative_prompt` to exclude elements.\n- **Output:** 30-second WAV audio clips, 48 kHz, instrumental only.\n- **Safety:** Content safety filters, recitation checking, artist intent checks, and SynthID watermarking are applied.\n\nPricing\n-------\n\nLyria 2 usage is priced at $0.06 per 30 seconds of output music generated. For\nmore details, see [Vertex AI Pricing](https://cloud.google.com/vertex-ai/pricing).\n\nMore information\n----------------\n\n- Learn more about [Generative AI on Vertex AI](https://cloud.google.com/vertex-ai/docs/generative-ai/).\n- For an overview of Lyria, refer to its model card available in the Model Garden (Media Studio).\n\nWhat's next\n-----------\n\n- Try out Lyria in the [Vertex AI Studio](https://console.cloud.google.com/vertex-ai/studio/media/generate;tab=music).\n- Review the [Google Cloud Service Terms](https://cloud.google.com/terms).\n- Read the [Additional Terms for Generative AI Products](https://cloud.google.com/terms/generative-ai)."]]