---
title: "Inpaint an Audio Segment"
method: POST
path: "/v1/inpaint"
---

# Inpaint an Audio Segment

`POST /v1/inpaint`

## Request

- Base URL: `https://api.musicgpt.com/api/public`
- URL: `https://api.musicgpt.com/api/public/v1/inpaint`
- Auth: API key in header `Authorization`

This endpoint allows users to replace a specific time segment of an audio clip using a textual prompt and optional lyrics. The inpainting operation blends new audio content into the selected range, guided by user-defined style and voice preferences.  

To use the inpaint feature, upload a song and specify the lyrics you want to replace in the field **'lyrics_section_to_replace'**. For best results, also provide the complete song lyrics in the **lyrics**.

## Request body `multipart/form-data`

- union
  - object
    - `audio_file` string, binary: Uploaded input audio file.
    - `audio_url` string, required: Input audio URL (supported format: YouTube URL).
    - `prompt` string, required: A description of how the replacement should sound.
    - `replace_start_at` number, float, required: Time in seconds to start replacing audio.
    - `replace_end_at` number, float, required: Time in seconds to stop replacing audio.
    - `lyrics` string: Lyrics to be used for inpainting.
    - `lyrics_section_to_replace` string: Lyrics to be used for the replaced portion(optional, max 3000 characters)
    - `gender` 'male' | 'female' | 'neutral': Voice style for the inpainted segment.
    - `num_outputs` number: The number of outputs to generate (1 or 2 only):default is 2.
    - `title` string: Title of the generated music track
    - `generate_album_cover` boolean: Whether to generate an album cover for the generated audio
    - `webhook_url` string: Callback URL for async processing results.
  - object
    - `audio_file` string, binary, required: Uploaded input audio file.
    - `audio_url` string: Input audio URL (supported format: YouTube URL).
    - `prompt` string, required: A description of how the replacement should sound.
    - `replace_start_at` number, float, required: Time in seconds to start replacing audio.
    - `replace_end_at` number, float, required: Time in seconds to stop replacing audio.
    - `lyrics` string: Lyrics to be used for inpainting.
    - `lyrics_section_to_replace` string: Lyrics to be used for the replaced portion(optional, max 3000 characters)
    - `gender` 'male' | 'female' | 'neutral': Voice style for the inpainted segment.
    - `num_outputs` number: The number of outputs to generate (1 or 2 only):default is 2.
    - `title` string: Title of the generated music track
    - `generate_album_cover` boolean: Whether to generate an album cover for the generated audio
    - `webhook_url` string: Callback URL for async processing results.

## Response `200`

Successfully initiated inpaint task

- object
  - `success` boolean
  - `message` string
  - `task_id` string
  - `conversion_id_1` string
  - `conversion_id_2` string
  - `eta` integer: Estimated processing time in seconds
  - `credit_estimate` number, float

## Other responses

- `422`: Validation Error
- `500`: Server Error

---

[API](https://skmtc.dev/musicgpt/apis/musicgpt-api.md) - [All operations](https://skmtc.dev/musicgpt/apis/musicgpt-api/llms.txt) - [OpenAPI document](https://skmtc.dev/musicgpt/apis/musicgpt-api/revisions/6753dccf4c5d?raw)
