---
title: "Generate MIDI from Audio"
method: POST
path: "/api/v1/midi/generate"
---

# Generate MIDI from Audio

`POST /api/v1/midi/generate`

Convert separated audio tracks into MIDI format with detailed note information for each instrument.

### Usage Guide
- Convert separated audio tracks into structured MIDI data containing pitch, timing, and velocity information
- Requires a completed vocal separation task ID (from the Vocal Removal API)
- Generates MIDI note data for multiple detected instruments including drums, bass, guitar, keyboards, and more
- Ideal for music transcription, notation, remixing, or educational analysis
- Best results on clean, well-separated audio tracks with clear instrument parts

### Prerequisites
- You must first use the Vocal & Instrument Stem Separation API with `type: split_stem` to separate your audio before generating MIDI

### Parameter Details
- `taskId` identifies a completed vocal separation task 
- `callBackUrl` receives MIDI generation completion notifications
- `audioId` (optional) specifies which separated audio track to generate MIDI from. Obtain this ID from the `originData` array in the Get Vocal Separation Details response. If not provided, MIDI will be generated from all separated tracks.

### Developer Notes
- MIDI generation typically takes 30-90 seconds depending on audio length and complexity
- The callback will contain detailed note data for each detected instrument
- Each note includes: pitch (MIDI note number), start (seconds), end (seconds), velocity (0-1)
- Not all instruments may be detected - depends on audio content
- Generated MIDI data is retained for 14 days

## Request body

- object
  - `taskId` string, required — Task ID from a completed vocal separation. This should be the taskId returned from the Vocal & Instrument Stem Separation endpoint.
  - `callBackUrl` string, uri, required — The URL to receive MIDI generation task completion updates. Required for all MIDI generation requests. - System will POST task status and MIDI note data to this URL when generation completes - Callback includes detailed note information for each detected instrument with pitch, timing, and velocity - Your callback endpoint should accept POST requests with JSON payload containing MIDI data - For detailed callback format and implementation guide, see [MIDI Generation Callbacks](/suno-api/generate-midi-callbacks) - Alternatively, use the Get MIDI Generation Details endpoint to poll task status
  - `audioId` string — Optional. Specifies which separated audio track to generate MIDI from. This audioId can be obtained from the `originData` array in the Get Vocal Separation Details endpoint response. Each item in `originData` contains an `id` field that can be used here. If not provided, MIDI will be generated from all separated tracks.

## Response `200`

MIDI generation task created successfully

- object
  - `code` integer — Response status code
  - `msg` string — Response message
  - `data` object — Response data containing task information
    - `taskId` string — Unique identifier for the MIDI generation task. Use this to query task status or receive callback results.

## Other responses

- `500` — Server error

---

[API](https://skmtc.net/sunoapi/apis/file-upload-api.md) · [All operations](https://skmtc.net/sunoapi/apis/file-upload-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/sunoapi/file-upload-api/versions/22d45ee33a4a/schema)
