Ana içeriğe geç
meta avatarı

musicgen API

meta/musicgen

Yüksek sadakatli müzik üretimi için hızlı ve kontrol edilebilir bir auto-regressive Transformer.

A100
0.117176

Model girdisi

Input

Model to use for generation

A description of the music you want to generate.

An audio file that will influence the generated music. If `continuation` is `True`, the generated music will be a continuation of the audio file. Otherwise, the generated music will mimic the audio file's melody.

Duration of the generated audio in seconds.

If `True`, generated music will continue from `input_audio`. Otherwise, generated music will mimic `input_audio`'s melody.

Min: 0

Start time of the audio file to use for continuation.

Min: 0

End time of the audio file to use for continuation. If -1 or None, will default to the end of the audio clip.

If `True`, the EnCodec tokens will be decoded with MultiBand Diffusion. Only works with non-stereo models.

Strategy for normalizing audio.

Reduces sampling to the k most likely tokens.

Reduces sampling to tokens with cumulative probability of p. When set to `0` (default), top_k sampling is used.

Controls the 'conservativeness' of the sampling process. Higher temperature means more diversity.

Increases the influence of inputs on the output. Higher values produce lower-varience outputs that adhere more closely to inputs.

Output format for generated audio.

Seed for random number generator. If None or -1, a random seed will be used.

You need to be logged in to run this model and view results.
Log in

Model çıktısı

Output

Fill in the input form and click submit to see the output
Logs (1 lines)

musicgen API

musicgen is a sound AI model by meta. On ModelRunner it runs through a REST API or via MCP from any AI assistant, at about $0.117176 per audio clip.

POST https://queue.modelrunner.run/meta/musicgen

cURL

# Submit a request to the queue. Input fields go at the top level of the
# body. The optional reserved "metadata" object holds your own flat string
# tags — stored on the request, never sent to the model; filter later with
# GET https://queue.modelrunner.run/requests?metadata=<url-encoded JSON>.
curl -X POST https://queue.modelrunner.run/meta/musicgen \
  -H "Authorization: Key $MRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model_version": "stereo-melody-large",
    "metadata": {
      "project": "my-project"
    }
  }'
# → { "request_id": "...", "status_url": "...", "response_url": "..." }

# Poll status_url until "COMPLETED", then fetch the result
curl "https://queue.modelrunner.run/meta/musicgen/requests/$REQUEST_ID/status" \
  -H "Authorization: Key $MRUN_API_KEY"
curl "https://queue.modelrunner.run/meta/musicgen/requests/$REQUEST_ID" \
  -H "Authorization: Key $MRUN_API_KEY"

JavaScript

import { modelrunner } from "@modelrunner/client";

const result = await modelrunner.subscribe("meta/musicgen", {
  input: {
    "model_version": "stereo-melody-large"
  },
});
console.log(result);

Python

import os
import requests

headers = {"Authorization": f"Key {os.environ['MRUN_API_KEY']}"}

submitted = requests.post(
    "https://queue.modelrunner.run/meta/musicgen",
    headers=headers,
    json={
      "model_version": "stereo-melody-large"
    },
).json()

# Poll submitted["status_url"] until "COMPLETED", then:
result = requests.get(submitted["response_url"], headers=headers).json()

Input parameters

Input parameters of musicgen
NameTypeRequiredDescription
model_versionenumnoModel to use for generation One of: stereo-melody-large, stereo-large, melody-large, large. Default: "stereo-melody-large".
promptstringnoA description of the music you want to generate.
input_audiostring (uri)noAn audio file that will influence the generated music. If continuation is True, the generated music will be a continuation of the audio file. Otherwise, the generated music will mimic the audio file's melody.
durationintegernoDuration of the generated audio in seconds. Default: 8.
continuationbooleannoIf True, generated music will continue from input_audio. Otherwise, generated music will mimic input_audio's melody. Default: false.
continuation_startintegernoStart time of the audio file to use for continuation. Default: 0.
continuation_endintegernoEnd time of the audio file to use for continuation. If -1 or None, will default to the end of the audio clip.
multi_band_diffusionbooleannoIf True, the EnCodec tokens will be decoded with MultiBand Diffusion. Only works with non-stereo models. Default: false.
normalization_strategyenumnoStrategy for normalizing audio. One of: loudness, clip, peak, rms. Default: "loudness".
top_kintegernoReduces sampling to the k most likely tokens. Default: 250.
top_pnumbernoReduces sampling to tokens with cumulative probability of p. When set to 0 (default), top_k sampling is used. Default: 0.
temperaturenumbernoControls the 'conservativeness' of the sampling process. Higher temperature means more diversity. Default: 1.
classifier_free_guidanceintegernoIncreases the influence of inputs on the output. Higher values produce lower-varience outputs that adhere more closely to inputs. Default: 3.
output_formatenumnoOutput format for generated audio. One of: wav, mp3. Default: "wav".
seedintegernoSeed for random number generator. If None or -1, a random seed will be used.

Machine-readable: OpenAPI schema · llms.txt

Use musicgen from Claude & Cursor (MCP)

Point Claude Code, Claude Desktop, Cursor, or any MCP client at the ModelRunner MCP server and musicgen becomes a tool your assistant can call directly — it authorizes via OAuth (no API key in config) and runs this model with the run_model tool using the endpoint meta/musicgen.

MCP client config (Claude Desktop, Cursor)

{
  "mcpServers": {
    "modelrunner": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.modelrunner.run/mcp"]
    }
  }
}

Claude Code

claude mcp add --transport http modelrunner https://mcp.modelrunner.run/mcp

Then ask your assistant, for example: “Run meta/musicgen on ModelRunner to generate sound”. MCP setup guide.

Model Detayları

Model Detayları

### Musicgen Modeli Hakkında AudioCraft’ın MusicGen modeli, 4 codebook’lu bir EnCodec tokenizer kullanarak 32 kHz’de yüksek kaliteli müzik üreten tek aşamalı, auto-regressive bir Transformer’dır. 20 000 saatlik lisanslı parça üzerinde eğitildi; tüm codebook’ları paralel olarak, saniyede yalnızca 50 autoregressive adımla tahmin eder — ayrı semantic embedding’lere gerek yoktur.

### Modeller ve Demolar - **Boyutlar:** small, medium, large, melody, stereo - **Demolar:** Hugging Face Space, Colab notebook, yerel Gradio uygulaması, Jupyter örnekleri

### Öne Çıkan Avantajlar - **Verimlilik:** Daha hızlı inference için paralel codebook tahmini - **Esneklik:** Birden fazla model boyutunda yalnızca metinle ya da metin+melodiyle koşullandırma - **Erişilebilirlik:** Çok az dependency ile 🤗 Transformers (v4.31.0+) üzerinden kullanılabilir