API Documentation

Vobile/Pex AI Song Detector API Documentation

The AI Song Detector API lets you check whether an audio file contains AI-generated music.

The uploaded file must contain music, ideally a single song. Please avoid files with UGC compilations, voiceovers, long mixes, DJ sets, mashups, or other mixed content.

The model produces one prediction for the entire file.

To use the API:

  1. Request an access token via OAuth 2.0 Client Credentials.

  2. Upload an audio file to the detection endpoint. All common audio file formats are supported.

  3. Receive a JSON result describing whether the file contains AI-generated music.

The API returns exactly one result per request. Batch processing is not supported. Submit each file separately.


1. Authentication

The API uses OAuth 2.0 Client Credentials. You will need a CLIENT_ID and CLIENT_SECRET.

The generated access token must be included in every request to the detection endpoint.

Token Endpoint

POST

https://api.ae.pex.com/oauth2/token

  • Auth: HTTP Basic Auth

  • Body: grant_type=client_credentials

Examples

import requests

token_url = "https://api.ae.pex.com/oauth2/token"
auth = ("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")

token_resp = requests.post(token_url, data={"grant_type": "client_credentials"}, auth=auth)
token_resp.raise_for_status()
access_token = token_resp.json()["access_token"]

2. AI Song Detector Endpoint

POST

https://api.ae.pex.com/v1/ai-detector/detect

Requirements

  • Authorization: Bearer <access_token>

  • Content-Type: multipart/form-data

  • Body: file=@your_audio_file

File constraints

  • Supported formats: Most common audio formats (MP3, MP4/M4A, WAV, FLAC, AAC, OGG, WEBM, etc.).

  • Maximum file size: 100 MB.

  • Minimum duration: 15 seconds.

  • Maximum duration: 15 minutes.

  • Stereo, mono, and variable bitrates are supported.

Files shorter or longer than the limits will return too_short or too_long in the response status. Files containing a lot of silence or non-music parts may return not_enough_music.


Examples

import requests

url = "https://api.ae.pex.com/v1/ai-detector/detect"
headers = {"Authorization": f"Bearer {access_token}"}

with open("song.mp3", "rb") as f:
    resp = requests.post(url, headers=headers, files={"file": f})

resp.raise_for_status()
print(resp.json())

3. Response Format

A successful request (HTTP 200 OK) with status ok returns a JSON object such as:

{
  "request_id": 806957142976735233,
  "status": "ok",
  "message": "ok",
  "is_ai": true,
  "ai_score": 0.9992
}

Response Fields

Field
Type
Description

request_id

integer

Unique ID for this request.

status

string

Processing status (see full list below).

message

string

Human-readable explanation of the status.

is_ai

boolean

Whether the model classifies the song as AI-generated.

Present only if status is ok.

ai_score

number

Confidence score [0–1]. It represents the model's confidence that the audio is AI-generated. It is not a probability.

Present only if status is ok.


4. Status Codes

status
Description

ok

Processing completed successfully. Fields is_ai and ai_score are provided.

invalid_file

The file is not recognized as a valid media file, is corrupted, or the container cannot be parsed.

no_audio

The media file is valid, but contains no extractable audio track.

too_short

Audio is shorter than 15 seconds.

too_long

Audio is longer than 15 minutes.

not_enough_music

Audio exists, but does not contain enough music content for reliable classification.

error

Other processing error.


5. HTTP Error Handling

The API uses standard error responses:

Status
Explanation

200

Request processed. The response body contains a status field that may indicate errors (e.g., invalid_file, too_short).

400

Invalid request (missing file, incorrect field name, etc.).

401

Missing or invalid OAuth token.

413

File too large (over 100 MB).

429

Too Many Requests - retry with backoff.

500

Unexpected server error. You may retry if temporary.

502

Bad Gateway. The server may be overloaded - retry with backoff.

503

Service temporarily overloaded - retry with backoff.

Example error response

{
  "status": "error",
  "message": "Service temporarily unavailable. Please retry later."
}

6. Full Example

This code illustrates how to use both steps (Authentication and use of AI Song Detector Endpoint), including error handling.

import json
import requests
import time

CLIENT_ID = "YOUR_CLIENT_ID"
CLIENT_SECRET = "YOUR_CLIENT_SECRET"
INPUT_FILE = "/path/to/yout/file.mp3"

TOKEN_URL = "https://api.ae.pex.com/oauth2/token"
DETECT_URL = "https://api.ae.pex.com/v1/ai-detector/detect"


def get_access_token(client_id, client_secret):
    auth = (client_id, client_secret)
    resp = requests.post(TOKEN_URL, data={"grant_type": "client_credentials"}, auth=auth)
    resp.raise_for_status()
    return resp.json()["access_token"]


def detect_ai_song(access_token, file_name):
    headers = {"Authorization": f"Bearer {access_token}"}

    while True:
        # call AI Song Detector
        with open(file_name, "rb") as f:
            resp = requests.post(DETECT_URL, headers=headers, files={"file": f})

        # Return the result
        if resp.status_code == 200:
            return resp.json()

        # Retry on some errors 
        if resp.status_code in [408, 429, 500, 502, 504, 520, 521, 522, 523, 524]:
            # Log the retryable error
            print(f"HTTP status {resp.status_code}, retrying...")

            # Sleep for 30 seconds
            time.sleep(30)

        else:
            # Raise the non-retryable error 
            resp.raise_for_status()


def main():
    # Get the access token
    access_token = get_access_token(CLIENT_ID, CLIENT_SECRET)

    # Call AI Song Detector
    result = detect_ai_song(access_token, INPUT_FILE)

    # Print the result
    print(json.dumps(result, indent=2))


if __name__ == '__main__':
    main() 

7. Support

If you encounter problems, please contact your Pex representative and include:

  • the request_id (if present),

  • timestamp,

  • HTTP status code,

  • the approximate file duration.

Last updated