We use cookies. Cookies and browser storage keep you signed in and remember your preferences. With your permission we also measure how the site is used. You can any time. See our cookie policy.

Music widget

AI music generator widget code: short clips from a text prompt

Put an AI music generator on your website with one script tag. Visitors describe a mood or style and hear a short clip, played right in the widget.

Published:

A music widget turns a short description into a music clip. A visitor types "upbeat acoustic guitar for a summer video" and a few moments later the clip plays in the widget, with a download link. It is a simple way to add an interactive, creative tool to a site about music, video or content creation.

How it works

  1. The visitor writes a prompt describing the style, mood, instruments or tempo.
  2. The widget sends it to api14 using your widget id. The model, your API key and your limits stay on the server.
  3. The music model streams the audio back and the widget plays it as soon as it is ready.

Music generation is handled by models built for it. The widget's default model for the music type is chosen from those music models, not from speech models, so a new widget starts with something that actually produces music.

The embed code

Create a widget in Widgets, pick Music as the type and save:

<script src="https://api14.com/widget.js" data-widget="YOUR_WIDGET_ID" async></script>

Paste the tag where the generator should appear. Use data-target to place it inside an existing element and data-height to change its height (420px by default). The Floating button placement opens it from a corner button instead.

Settings to review

  • Model: the picker shows music models with their prices. Clip length and quality differ between models, so test a few prompts in the preview.
  • API key: choose the key the widget runs under, or select Create new API key at the end of the list. The key's daily spend limit, request rate and allowed models apply to the widget.
  • Texts: a good placeholder prompt teaches visitors what to type, for example "Calm piano, slow tempo, for a study playlist".
  • Look: accent color, theme and corner radius.

Prompts that work

Short, concrete prompts give the most predictable results. Combine three or four elements:

  • Genre: lo-fi, orchestral, synthwave, folk.
  • Mood: calm, energetic, mysterious.
  • Instruments: piano, strings, drums, acoustic guitar.
  • Use: intro, background loop, podcast sting.

Before going live

Add your domains under Settings, Widget sites, set a daily spend limit, and play a few clips on a phone and a desktop.

Read more about audio generation in the music and audio docs and try the builder on the widgets page.