### Compose response example Source: https://github.com/beatoven/public-api/blob/main/docs/api-spec.md Example response from the compose request. It indicates that the asynchronous composition process has started and provides a task_id for tracking. ```json { "status": "started", "task_id": "ccb84650-7b4a-4d00-9f80-8a6427ca21aa_1" } ``` -------------------------------- ### Install Beatoven SDK from git Source: https://github.com/beatoven/public-api/blob/main/sdk/readme.md Installs the Python package directly from the GitHub repository using pip. ```python !python -m pip install -e "git+https://github.com/Beatoven/public-api.git/#subdirectory=sdk" ``` -------------------------------- ### Import SDK and check version Source: https://github.com/beatoven/public-api/blob/main/sdk/readme.md Imports the beatoven_sdk module and retrieves the SDK version to verify installation. ```python import beatoven_sdk beatoven_sdk.get_version() ``` -------------------------------- ### Composition status response example Source: https://github.com/beatoven/public-api/blob/main/docs/api-spec.md Example response from the status endpoint. The status field can be 'composing', 'running', or 'composed'. When 'composed', the meta object contains the track and stems URLs. ```json { "status": "composed", "meta": { "project_id": "3ade3151-372d-4ac8-b1ef-866a67ef0875", "track_id": "ccb84650-7b4a-4d00-9f80-8a6427ca21aa", "prompt": { "text": "30 seconds peaceful lo-fi chill hop track" }, "version": 1, "track_url":"", "chords": "", "melody": "", "percussion": "" } } } ``` -------------------------------- ### Get existing track by ID Source: https://github.com/beatoven/public-api/blob/main/sdk/readme.md Fetches an existing track using its ID, returning a tuple of track_id and track_url. The example uses the first track from the list_all_tracks result. ```python track_id, track_url = await beatoven_sdk.get_track_by_id(tracks[0]["id"]) ``` -------------------------------- ### POST /api/v1/tracks/compose Source: https://github.com/beatoven/public-api/blob/main/docs/api-spec.md Composes a track based on a text prompt. This endpoint starts an asynchronous composition process and returns a task ID. ```APIDOC ## POST /api/v1/tracks/compose ### Description Composes a track based on a text prompt. This endpoint starts an asynchronous composition process and returns a task ID. ### Method POST ### Endpoint /api/v1/tracks/compose ### Parameters #### Request Body - **prompt** (object) - Required - The prompt for the track. Contains a `text` field with the description. - **format** (string) - Optional - Format of the generated assets. Can be `mp3`, `aac`, or `wav`. Default is `wav`. - **looping** (boolean) - Optional - Control the extent of looping in the track. Set `true` for higher amount of looping. Default is `false`. ### Request Example { "prompt": { "text": "30 seconds peaceful lo-fi chill hop track" }, "format": "wav", "looping": false } ### Response #### Success Response (200) - **status** (string) - The status of the request, e.g., "started". - **task_id** (string) - The ID of the asynchronous task. #### Response Example { "status": "started", "task_id": "ccb84650-7b4a-4d00-9f80-8a6427ca21aa_1" } ``` -------------------------------- ### GET /api/v1/tasks/ Source: https://github.com/beatoven/public-api/blob/main/docs/api-spec.md Queries the progress of a composition task using the task ID returned from the compose endpoint. ```APIDOC ## GET /api/v1/tasks/ ### Description Queries the progress of a composition task using the task ID returned from the compose endpoint. ### Method GET ### Endpoint /api/v1/tasks/ ### Parameters #### Path Parameters - **task_id** (string) - Required - The task ID returned in the response of the composition request. ### Response #### Success Response (200) - **status** (string) - The status of the task. Can be `composing`, `running`, or `composed`. - **meta** (object) - Metadata about the composed track, including project_id, track_id, prompt, version, track_url, and stems_url. #### Response Example { "status": "composed", "meta": { "project_id": "3ade3151-372d-4ac8-b1ef-866a67ef0875", "track_id": "ccb84650-7b4a-4d00-9f80-8a6427ca21aa", "prompt": { "text": "30 seconds peaceful lo-fi chill hop track" }, "version": 1, "track_url": "", "stems_url": { "bass": "", "chords": "", "melody": "", "percussion": "" } } } ``` -------------------------------- ### Set Beatoven API key environment variable Source: https://github.com/beatoven/public-api/blob/main/sdk/readme.md Sets the BEATOVEN_API_KEY environment variable, which is required for SDK authentication. The key should be obtained by contacting hello@beatoven.ai. ```python import os os.environ["BEATOVEN_API_KEY"] = "" ``` -------------------------------- ### Compose new track Source: https://github.com/beatoven/public-api/blob/main/sdk/readme.md Creates a new track with specified title, duration, genre, tempo, and mood. Returns a tuple of track_id and track_url. ```python track_id, track_url = await beatoven_sdk.create_new_track( title="my sdk track", track_duration=30000, track_genre="cinematic", track_tempo="medium", mood="happy", ) ``` -------------------------------- ### List all tracks Source: https://github.com/beatoven/public-api/blob/main/sdk/readme.md Asynchronously retrieves a list of all tracks associated with the API key. ```python tracks = await beatoven_sdk.list_all_tracks() ``` -------------------------------- ### Output of download track Source: https://github.com/beatoven/public-api/blob/main/sdk/readme.ipynb Expected output when the download is successful. ```text Output: Composed! you can find your track at `composed_track.mp3` ``` -------------------------------- ### Download track Source: https://github.com/beatoven/public-api/blob/main/sdk/readme.md Downloads the composed track to a local file named 'composed_track.mp3' using aiohttp and aiofiles. Prints a confirmation message upon success. ```python import aiofiles import aiohttp track_file_path = os.path.join(os.getcwd(), "composed_track.mp3") async with aiohttp.ClientSession() as session: async with session.get(track_url) as response: if response.status == 200: async with aiofiles.open(track_file_path, "wb+") as f: await f.write(await response.read()) print("Composed! you can find your track at `composed_track.mp3`") ``` -------------------------------- ### Compose track request payload Source: https://github.com/beatoven/public-api/blob/main/docs/api-spec.md JSON payload for POST /api/v1/tracks/compose. The prompt.text is required. The format field is optional and defaults to 'wav'. The looping field is optional and defaults to false. ```json { "prompt": { "text": "30 seconds peaceful lo-fi chill hop track" }, "format": "wav", // optional "looping": false // optional } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.