---
title: "Convert audio file to different format"
method: POST
path: "/v1/file_convert"
---

# Convert audio file to different format

`POST /v1/file_convert`

## Request

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

Initiate a file conversion task using either an audio URL or file upload with optional format parameters and webhook callback.

## Request body `multipart/form-data`

- union
  - object
    - `audio_url` string, required: Input audio URL (supported format: YouTube URL).
    - `audio_file` string, binary: Audio file to upload and convert directly
    - `target_format` 'mp3' | 'wav' | 'flac' | 'ogg' | 'aac' | 'webm', required: Target format for conversion
    - `target_sr` 8000 | 16000 | 22050 | 24000 | 32000 | 44100 | 48000 | 96000 | 192000: Target sample rate in Hz (optional) - can be any of [8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000, 192000]
    - `target_bit_depth` 16 | 24 | 32: Target bit depth (16, 24, or 32)
    - `webhook_url` string: Callback URL for async processing results
  - object
    - `audio_url` string: Input audio URL (supported format: YouTube URL).
    - `audio_file` string, binary, required: Audio file to upload and convert directly
    - `target_format` 'mp3' | 'wav' | 'flac' | 'ogg' | 'aac' | 'webm', required: Target format for conversion
    - `target_sr` 8000 | 16000 | 22050 | 24000 | 32000 | 44100 | 48000 | 96000 | 192000: Target sample rate in Hz (optional) - can be any of [8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000, 192000]
    - `target_bit_depth` 16 | 24 | 32: Target bit depth (16, 24, or 32)
    - `webhook_url` string: Callback URL for async processing results

## Response `200`

Successfully initiated file conversion

- object
  - `success` boolean
  - `task_id` string
  - `conversion_id` string
  - `output_path` string
  - `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)
