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

# Generate MIDI

> Extract structured MIDI note data from a completed Suno vocal separation task.

> [!TIP]
>
> 1. After submission, a `task_id` will be returned. If you provided a `callback_url`, when the task status becomes `finished` or `failed`, a POST request will be sent to the `callback_url`.
> 2. Regardless of whether `callback_url` is provided, you can retrieve the response result through the unified [Query Music Detail](https://docs.poyo.ai/api-manual/music-series/query-music-detail.md) endpoint.

Generate MIDI extracts per-instrument note data from a song that has already been separated with [Separate Vocals](https://docs.poyo.ai/api-manual/music-series/vocal-remover/separate-vocals.md) or [Stem Split](https://docs.poyo.ai/api-manual/music-series/vocal-remover/stem-split.md).

## Models

* **generate-midi** — Extract MIDI note data from a separated track

## Required parameters

* `task_id` (string): `task_id` of a finished Separate Vocals or Stem Split task from your account.

## Output

The result is returned as `midi_data` by [Query Music Detail](https://docs.poyo.ai/api-manual/music-series/query-music-detail.md) and in the music callback. `midi_data` is a JSON object with `state` and an `instruments` array as returned by the provider. No downloadable `.mid` file is produced.

## Examples

* **Generate MIDI from a separation task** — sets `task_id`.

## Notes

* Run Separate Vocals or Stem Split first. Other task types are rejected with "It is necessary to first call the separation of vocals and instruments."
* An unknown `task_id`, or one from another account, returns "Parent task not found".
* Validation errors are returned in the response body with `code: 400` even when the HTTP status is 200. Always check `code`.


## OpenAPI

````yaml api-manual/music-series/generate-midi.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: Generate MIDI
  description: Extract MIDI note data from a completed Suno vocal separation task.
  version: 1.0.0
servers:
  - url: https://api.poyo.ai
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      summary: Submit a Generate MIDI task
      operationId: submit_generate_midi
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              basic:
                summary: Generate MIDI from a separation task
                value:
                  model: generate-midi
                  callback_url: https://your-domain.com/callback
                  input:
                    task_id: task-unified-1757165031-uyujaw3d
      responses:
        '200':
          description: Task submitted successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SubmitRequest:
      type: object
      additionalProperties: false
      required:
        - model
        - input
      properties:
        model:
          type: string
          enum:
            - generate-midi
          description: Public model identifier.
        callback_url:
          type: string
          format: uri
          description: Optional webhook URL for task completion or failure notifications.
        input:
          type: object
          additionalProperties: false
          required:
            - task_id
          properties:
            task_id:
              type: string
              description: >-
                `task_id` of a finished Separate Vocals or Stem Split task that
                belongs to your account.
    SubmitResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          example: 200
        data:
          type: object
          required:
            - task_id
            - status
            - created_time
          properties:
            task_id:
              type: string
              example: task-unified-1793176000-example
            status:
              type: string
              enum:
                - not_started
              example: not_started
            created_time:
              type: string
              format: date-time
              example: '2026-10-28T10:30:00'
    ErrorResponse:
      type: object
      required:
        - code
        - error
      properties:
        code:
          type: integer
          example: 400
        error:
          type: object
          required:
            - message
            - type
          properties:
            message:
              type: string
              example: Invalid request parameters
            type:
              type: string
              example: validation_error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````

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