Loading...
Loading...
Music and sound effects generation — 8 providers with fallback chains, user-configurable preferences, local and cloud options.
npx skill4agent add framersai/agentos-skills audio-generationSUNO_API_KEYUDIO_API_KEYSTABILITY_API_KEYREPLICATE_API_TOKENFAL_API_KEYimport { generateMusic } from 'agentos';
const result = await generateMusic({
prompt: 'Upbeat lo-fi hip hop beat with vinyl crackle and mellow piano',
durationSec: 60,
});
console.log(result.audio[0].url);negativePrompt: 'vocals, singing, lyrics'| Option | Default | Description |
|---|---|---|
| (required) | Text description of the desired music |
| auto-detect | Provider ID ( |
| provider default | Model identifier within the provider |
| provider default | Output duration in seconds (Suno: up to ~240s, Stable Audio: ~47s) |
| — | Musical elements to avoid (not all providers support this) |
| | Output format: |
| random | Seed for reproducible output (provider-dependent) |
| | Number of clips to generate |
| provider default | Max wait time before polling providers time out |
| — | Best-effort callback for |
| — | Reorder, block, or weight providers for auto-selection and fallback |
ELEVENLABS_API_KEYSTABILITY_API_KEYREPLICATE_API_TOKENFAL_API_KEYimport { generateSFX } from 'agentos';
const result = await generateSFX({
prompt: 'Thunder crack followed by heavy rain on a tin roof',
durationSec: 5,
});
console.log(result.audio[0].url);| Option | Default | Description |
|---|---|---|
| (required) | Text description of the desired sound effect |
| auto-detect | Provider ID ( |
| provider default | Model identifier within the provider |
| provider default | Output duration in seconds (SFX is typically 1-15s) |
| | Output format: |
| random | Seed for reproducible output (provider-dependent) |
| | Number of clips to generate |
| provider default | Max wait time before polling providers time out |
| — | Best-effort callback for |
| — | Reorder, block, or weight providers for auto-selection and fallback |
| Provider | ID | Best For | Env Var | Key Required |
|---|---|---|---|---|
| Suno | | Highest quality vocals + instrumentals, full songs | | Yes |
| Udio | | High quality music, alternative to Suno | | Yes |
| Stable Audio | | Instrumentals, loops, ambient, fast generation | | Yes |
| Replicate | | Open-source models (MusicGen), pay-per-use | | Yes |
| Fal | | Fast serverless GPU, cost-effective | | Yes |
| MusicGen Local | | Offline generation, no API key needed, privacy | — | No |
| Provider | ID | Best For | Env Var | Key Required |
|---|---|---|---|---|
| ElevenLabs | | Highest quality SFX, fast turnaround | | Yes |
| Stable Audio | | Good SFX + music in one provider | | Yes |
| Replicate | | Open-source AudioGen model, pay-per-use | | Yes |
| Fal | | Fast serverless GPU | | Yes |
| AudioGen Local | | Offline SFX generation, no API key needed | — | No |
const result = await generateMusic({
prompt: 'Chill synthwave with arpeggiated synths',
provider: 'stable-audio',
apiKey: 'your-stability-key',
durationSec: 30,
});providerPreferencesimport { generateMusic } from 'agentos';
// Prefer Suno, fall back to Stable Audio, never use Udio
const result = await generateMusic({
prompt: 'Orchestral film score with dramatic strings',
providerPreferences: {
preferred: ['suno', 'stable-audio'],
blocked: ['udio'],
},
});| Field | Description |
|---|---|
| Ordered list of provider IDs to try first. Providers not in this list are excluded. |
| Provider IDs to unconditionally exclude from the chain. |
| Weight map for weighted primary selection after filtering/reordering (useful for A/B testing or load balancing). |
generateMusic()generateSFX()generateImage()generateVideo()| Need | API | Why |
|---|---|---|
| Background music, songs, jingles | | Optimized for musical compositions with melody, harmony, rhythm |
| Sound effects, foley, ambient sounds | | Optimized for short, non-musical audio (impacts, nature, UI sounds) |
| Speech, narration, voice cloning | TTS (speech subsystem) | Use the speech/TTS APIs instead — audio generation is for non-speech |
| Podcast intros with music + voice | Combine both | Generate music with |
generateMusic({ prompt: 'Gentle ambient pad' })generateSFX({ prompt: 'Notification chime' })import { generateMusic, generateSFX } from 'agentos';
// Generate assets in parallel
const [music, sfx] = await Promise.all([
generateMusic({ prompt: 'Calm podcast background music', durationSec: 120 }),
generateSFX({ prompt: 'Soft transition whoosh', durationSec: 2 }),
]);
// Use the URLs/base64 data in your mixing pipeline
console.log('Music:', music.audio[0].url);
console.log('SFX:', sfx.audio[0].url);@huggingface/transformers// Explicitly use local generation
const result = await generateMusic({
prompt: 'Simple piano melody',
provider: 'musicgen-local',
});@huggingface/transformersSUNO_API_KEYUDIO_API_KEYSTABILITY_API_KEYREPLICATE_API_TOKENFAL_API_KEYELEVENLABS_API_KEYSTABILITY_API_KEYREPLICATE_API_TOKENFAL_API_KEY