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

# Layer and accompany

> Generate an instrument or accompaniment against the source audio.

Use the client from [request setup](/dev/guides/connect). These examples assume `api`, `userAddress`, and the returned `songId` are available. `api` includes the session token and selected account headers.

## Add an instrument

```javascript theme={null}
const job = await api.post('/api/editing/apply', {
  songId, userAddress, task: 'lego',
  prompt: 'A syncopated electric bass line',
  trackName: 'bass', trackClasses: ['bass'],
  globalCaption: 'Instrumental acid house with dry drums',
  modelQuality: 'base',
});
```

Layer requires a nonempty `trackName` and Base mode. `prompt` describes the part; `globalCaption` describes the song. Use `trackClasses` for instrument groups.

To layer against a mixed arrangement, render that context, [upload it](/dev/endpoints/editing/source) and set `srcAudioUrl`. A list of `legoContextTrackIds` does not replace audible source context. The `/layer` shortcut is available when you do not need seed, BPM, key or language controls.

## Create accompaniment

```javascript theme={null}
const job = await api.post('/api/editing/apply', {
  songId, userAddress, task: 'complete',
  prompt: 'Acoustic guitar and restrained drums behind the vocal',
  trackClasses: ['guitar', 'drums'],
  modelQuality: 'base',
});
```

Use the vocal or instrument you want to accompany as `srcAudioUrl` or the target `stemId`. Accompany also requires Base mode.

Use the polling function from [job handling](/dev/guides/jobs#generation-polling).

```javascript theme={null}
// Save job before polling so your product can resume after a reload.
const path = `/api/editing/status/${encodeURIComponent(job.taskId)}?` +
  new URLSearchParams({
    songId: job.songId, userAddress, task: job.task,
    ...(job.stemId ? { stemId: job.stemId } : {}),
  });
const result = await pollJob(() => api.get(path));
```

Keep the returned `taskId`, `songId`, `task`, and optional `stemId`. A polling timeout stops your client from waiting; it does not cancel the job.

A Layer candidate can become its own stem through [base activation](/dev/guides/edit/takes), leaving the master in place. To combine a Layer with Master permanently, render the original plus the candidate and use the [composition merge flow](/dev/guides/edit/merge).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.