Lyria 2
Lyria 2 by Google DeepMind is an advanced model that generates high-fidelity 48kHz stereo instrumental music from text prompts or lyrics, offering precise control over tempo, key, mood, and structure.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/lyria-2"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Melodious guitar with gentle rain background.",
12 "negative_prompt": "No loud drums, no vocals."
13}
14
15response = requests.post(url, headers=headers, json=data)
16
17if response.status_code == 200:
18 result = response.json()
19 print(json.dumps(result, indent=2))
20else:
21 print(f"Error: {response.status_code}")
22 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/lyria-2"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Melodious guitar with gentle rain background.",
12 "negative_prompt": "No loud drums, no vocals."
13}
14
15response = requests.post(url, headers=headers, json=data)
16
17if response.status_code == 200:
18 result = response.json()
19 print(json.dumps(result, indent=2))
20else:
21 print(f"Error: {response.status_code}")
22 print(response.text)API Endpoint
https://api.segmind.com/v1/lyria-2Parameters
promptrequiredstringDirects audio creation with a detailed theme; guides tone and mood. Example: 'Melodious guitar with gentle rain background.'
"Melodious guitar with gentle rain background."negative_promptoptionalstringExcludes specific unwanted elements from the audio. Use 'No loud drums' for softer compositions, 'No vocals' for instrumentals.
"No loud drums, no vocals."seedoptionalintegerEnsures audio consistency across generations. Use '123' for repeated serene outputs, or omit for surprise variations.
nullResponse Type
Returns: Audio
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out