> ## Documentation Index
> Fetch the complete documentation index at: https://developers.t2000.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Make AI music

> One sentence in, an original track out. Claude crafts the prompt, Stable Audio 2.5 renders real, commercial-grade music — paid as you go in USDC.

Type a vibe, get a track. Your agent turns a one-line brief into a rich music prompt with Claude, then pays Stable Audio 2.5 to render the actual audio — a real, commercial-use `.wav` you can play and sell. \~\$0.42, no API keys, no subscriptions.

<Note>
  This recipe is the **creation half** of the Audric Store demo *"Make me a lo-fi beat called Midnight Rain and sell it for \$5."* The **store half** — persisting to Walrus, capping supply, and the 92%-to-creator USDC sale — lands with **Audric Store**.

  **Why pay for a model when a capable client could DIY?** An agent with a code sandbox (e.g. Claude Desktop) *can* synthesize a basic beat with numpy/ffmpeg for free — and will, if you let it. But that's a hand-built waveform, not generative music. When the point is a **real, sellable track** ("AI *made* the music"), you want a generative model — that's what the paid call buys here. For clients **without** a code sandbox (a browser/zkLogin app like Audric), the model endpoint is the *only* path. Phrase the prompt to ask for model generation when quality matters.
</Note>

***

## The prompt

```
Use t2 services. Use Stable Audio to generate a mellow lo-fi beat called "Midnight Rain" —
rainy-night vibe, ~30 seconds. Give me the audio to play.
```

***

## What runs

1. `POST /anthropic/v1/messages` — Claude turns the brief into a vivid music prompt (\~\$0.02)
2. `POST /fal/fal-ai/stable-audio-25/text-to-audio` — Stable Audio 2.5 renders the track (\~\$0.40)

***

## Run it

### Claude Desktop (MCP)

```bash theme={null}
npm install -g @t2000/cli && t2 init && t2 fund && t2 mcp install
```

Paste the prompt. Naming **Stable Audio** explicitly steers the agent to the model instead of synthesizing a waveform itself.

### SDK

```typescript theme={null}
import { T2000 } from '@t2000/sdk';
import { writeFileSync } from 'fs';

const agent = await T2000.create();
const brief = 'A mellow lo-fi hip-hop beat called "Midnight Rain", rainy-night mood, ~75 BPM';

// 1. Claude expands the brief into a richer music prompt.
const promptGen = await agent.pay({
  url: 'https://mpp.t2000.ai/anthropic/v1/messages',
  method: 'POST',
  headers: { 'anthropic-version': '2023-06-01' },
  body: JSON.stringify({
    model: 'claude-sonnet-4-5',
    max_tokens: 150,
    messages: [{
      role: 'user',
      content: `Write a single vivid text-to-music prompt (instruments, tempo, mood) for: ${brief}. Output ONLY the prompt.`,
    }],
  }),
});
const musicPrompt = (promptGen.body as { content: { text: string }[] }).content[0].text.trim();

// 2. Render with Stable Audio 2.5 — returns a hosted audio URL.
const track = await agent.pay({
  url: 'https://mpp.t2000.ai/fal/fal-ai/stable-audio-25/text-to-audio',
  method: 'POST',
  body: JSON.stringify({ prompt: musicPrompt, seconds_total: 30 }),
});

const { audio } = track.body as { audio: string };
const wav = await fetch(audio).then((res) => res.arrayBuffer());
writeFileSync('./midnight-rain.wav', Buffer.from(wav));
console.log('Track:', audio);
```

***

## Expected output

```
2 calls · ~$0.42 · ~10s · 0 taps
./midnight-rain.wav  (commercial-use, hosted)
```

***

## Extend it

* Need a cheaper take? **MusicGen via Replicate** (`/replicate/v1/predictions`, \$0.04) runs the open MusicGen model — pass its `version` + `{ prompt, duration }` and poll `/replicate/v1/predictions/status` for long renders
* Chain **fal.ai Flux** (`/fal/fal-ai/flux/dev`) for matching cover art and **ElevenLabs** (`/elevenlabs/v1/text-to-speech/:voiceId`) for a spoken intro
* Persist the track + cover to Walrus and mint it for sale — that's the upcoming **Audric Store** flow (creation → storage → capped USDC sale, 92% to the creator)
