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

# Audio - Music

> Analyze an **audio file** to determine if it was generated by an AI *music* model.

This endpoint is only appropriate when you are looking for ai versus human generated music. Music means both singing (vocals) and instrumentals.

**Warning: This endpoint can take up two minutes for long duration audio files or if our backend is spinning up additional processing nodes. Please set a two minute timeout in your client.**



## OpenAPI

````yaml api-reference/openapi.yaml post /v1/reports/music
openapi: 3.1.0
info:
  title: AIORNOT API
  summary: |2-

            Welcome to AI or Not`s documentation, the developer guide to discerning digital authenticity!
            
  termsOfService: https://aiornot.com/terms-of-service
  contact:
    name: AIORNOT
    url: https://aiornot.com/
    email: support@aiornot.com
  version: 5.0.2
servers:
  - url: https://api.aiornot.com
    description: Production environment
security: []
paths:
  /v1/reports/music:
    post:
      tags:
        - Reports by Modality
      summary: Audio - Music
      description: >-
        Analyze an **audio file** to determine if it was generated by an AI
        *music* model.


        This endpoint is only appropriate when you are looking for ai versus
        human generated music. Music means both singing (vocals) and
        instrumentals.


        **Warning: This endpoint can take up two minutes for long duration audio
        files or if our backend is spinning up additional processing nodes.
        Please set a two minute timeout in your client.**
      operationId: >-
        get_music_report_reports_music_poalysis including confidence scores and
        model-specific insights. Supports common audio formats like MP3, WAVst
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  title: File
                  description: The audio file to analyze. Must be a valid audio file.
              required:
                - file
            encoding:
              file:
                contentType: audio/*
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MusicReportResponse'
      security:
        - HTTPBearer: []
      x-codeSamples:
        - lang: python
          label: Python
          source: |
            import os, requests


            # Set API key ENV variable or replace with your own API key
            API_KEY = os.getenv("AIORNOT_API_KEY")
            MUSIC_ENDPOINT = "https://api.aiornot.com/v1/reports/music"

            with open("audio.mp3", "rb") as audio_file:
                files = {"file": audio_file}
                resp = requests.post(
                    MUSIC_ENDPOINT, 
                    headers={"Authorization": f"Bearer {API_KEY}"},
                    files=files,
                    timeout=120
                )
                if resp.status_code != 200:
                    raise Exception(f"Failed to analyze image: {resp.status_code} {resp.text}")

                print(resp.json())
        - lang: curl
          label: cURL
          source: |
            curl --request POST \
              --url https://api.aiornot.com/v1/reports/music \
              --header 'Authorization: Bearer $AIORNOT_API_KEY' \
              --form 'file=@audio.mp3' \
              --max-time 120
        - lang: javascript
          label: JavaScript
          source: |
            const fs = require('fs');
            const FormData = require('form-data');
            const fetch = require('node-fetch');

            const API_KEY = process.env.AIORNOT_API_KEY;
            const MUSIC_ENDPOINT = 'https://api.aiornot.com/v1/reports/music';

            const form = new FormData();
            form.append('file', fs.createReadStream('audio.mp3'));

            fetch(MUSIC_ENDPOINT, {
              method: 'POST',
              headers: {
                'Authorization': `Bearer ${API_KEY}`,
                ...form.getHeaders()
              },
              body: form,
              timeout: 120000
            })
              .then(response => {
                if (!response.ok) {
                  throw new Error(`Failed to analyze music: ${response.status} ${response.statusText}`);
                }
                return response.json();
              })
              .then(data => console.log(data))
              .catch(error => console.error('Error:', error));
        - lang: php
          label: PHP
          source: |
            <?php

            $API_KEY = getenv('AIORNOT_API_KEY');
            $MUSIC_ENDPOINT = 'https://api.aiornot.com/v1/reports/music';

            $curl = curl_init();

            $audioFile = new CURLFile('audio.mp3', 'audio/mpeg', 'file');

            curl_setopt_array($curl, [
              CURLOPT_URL => $MUSIC_ENDPOINT,
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_TIMEOUT => 120,
              CURLOPT_POST => true,
              CURLOPT_POSTFIELDS => [
                'file' => $audioFile
              ],
              CURLOPT_HTTPHEADER => [
                "Authorization: Bearer $API_KEY"
              ],
            ]);

            $response = curl_exec($curl);
            $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
            $err = curl_error($curl);

            curl_close($curl);

            if ($err) {
              echo "cURL Error #:" . $err;
            } elseif ($httpCode !== 200) {
              echo "Failed to analyze music: HTTP $httpCode - $response";
            } else {
              $data = json_decode($response, true);
              print_r($data);
            }
        - lang: go
          label: Go
          source: |
            package main

            import (
              "bytes"
              "fmt"
              "io"
              "io/ioutil"
              "mime/multipart"
              "net/http"
              "os"
              "time"
            )

            func main() {
              APIKey := os.Getenv("AIORNOT_API_KEY")
              musicEndpoint := "https://api.aiornot.com/v1/reports/music"

              file, err := os.Open("audio.mp3")
              if err != nil {
                panic(err)
              }
              defer file.Close()

              var requestBody bytes.Buffer
              writer := multipart.NewWriter(&requestBody)

              part, err := writer.CreateFormFile("file", "audio.mp3")
              if err != nil {
                panic(err)
              }

              _, err = io.Copy(part, file)
              if err != nil {
                panic(err)
              }

              err = writer.Close()
              if err != nil {
                panic(err)
              }

              client := &http.Client{
                Timeout: 120 * time.Second,
              }

              req, err := http.NewRequest("POST", musicEndpoint, &requestBody)
              if err != nil {
                panic(err)
              }

              req.Header.Set("Authorization", "Bearer "+APIKey)
              req.Header.Set("Content-Type", writer.FormDataContentType())

              resp, err := client.Do(req)
              if err != nil {
                panic(err)
              }
              defer resp.Body.Close()

              body, err := ioutil.ReadAll(resp.Body)
              if err != nil {
                panic(err)
              }

              if resp.StatusCode != 200 {
                fmt.Printf("Failed to analyze music: %d %s\n", resp.StatusCode, string(body))
                return
              }

              fmt.Println(string(body))
            }
        - lang: java
          label: Java
          source: |
            import java.io.File;
            import java.io.IOException;
            import java.util.concurrent.TimeUnit;
            import okhttp3.*;

            public class MusicAnalysis {
                public static void main(String[] args) {
                    String apiKey = System.getenv("AIORNOT_API_KEY");
                    String musicEndpoint = "https://api.aiornot.com/v1/reports/music";
                    
                    OkHttpClient client = new OkHttpClient.Builder()
                        .readTimeout(120, TimeUnit.SECONDS)
                        .build();
                    
                    File audioFile = new File("audio.mp3");
                    
                    RequestBody requestBody = new MultipartBody.Builder()
                        .setType(MultipartBody.FORM)
                        .addFormDataPart("file", audioFile.getName(),
                            RequestBody.create(MediaType.parse("audio/mpeg"), audioFile))
                        .build();
                    
                    Request request = new Request.Builder()
                        .url(musicEndpoint)
                        .header("Authorization", "Bearer " + apiKey)
                        .post(requestBody)
                        .build();
                    
                    try {
                        Response response = client.newCall(request).execute();
                        if (!response.isSuccessful()) {
                            System.err.println("Failed to analyze music: " + response.code() + " " + response.body().string());
                        } else {
                            System.out.println(response.body().string());
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
components:
  schemas:
    MusicReportResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        created_at:
          type: string
          format: date-time
          title: Created At
        report:
          $ref: '#/components/schemas/ShareMusicReport'
      type: object
      required:
        - id
        - report
      title: MusicReportResponse
    ShareMusicReport:
      properties:
        verdict:
          $ref: '#/components/schemas/AIONGenerateVerdict'
        confidence:
          type: number
          title: Confidence
          description: Confidence score for whether this audio file is ai-generated.
          minimum: 0
          maximum: 1
          example: 0.95
        duration:
          type: integer
          title: Duration
          description: Duration of the audio file in seconds.
          example: 120
        total_bytes:
          type: integer
          title: Total Bytes
          description: Total size of the audio file in bytes.
          example: 362594
        md5:
          type: string
          title: MD5
          description: MD5 hash of the uploaded audio file.
          example: db36d923800f6ca6b7f87cff8a19d1d1
      type: object
      required:
        - verdict
        - confidence
        - duration
        - total_bytes
        - md5
      title: ShareMusicReport
    AIONGenerateVerdict:
      type: string
      enum:
        - ai
        - human
      title: AIONGenerateVerdict
      description: Generate verdict.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer
      description: >-
        Your [API key](https://www.aiornot.com/dashboard/api) as the `Bearer`
        token in the `Authorization` header.

````