API Documentation

Generate music via REST API. Send a text prompt or raw geometry parameters, receive audio (WAV, MP3) or MIDI. All generation is deterministic — identical parameters always produce identical output.

Base URL

https://resonant4music.ai/api/v1

Generate Music

Submit a generation job. Returns a job ID for polling.

POST /generate

Request Body

ParameterTypeDescription
promptstringText description of desired music (e.g. "tense chase scene"). Either prompt or params required.
paramsobjectDirect geometry parameters (see below). Either prompt or params required.
duration_secondsfloatDuration in seconds (1–300). Default: 30
tempofloatBPM (40–300). Default: 120
formatstringwav, mp3, or midi. Default: wav

Geometry Parameters

ParameterTypeRangeDescription
nint2–2000Complexity — number of geometric elements
kint1–n/2Texture — step size controlling interval structure
omegafloat-10 to 10Movement — rotation speed of the geometry
xifloat-10 to 10Depth — vertical perturbation
psifloat0 to 2πPhase — shifts the tonal center
lock_psi_tauboolLock phase to tempo grid for rhythmic patterns

Example — Text Prompt

curl -X POST https://resonant4music.ai/api/v1/generate \ -H "Content-Type: application/json" \ -d '{ "prompt": "jazzy late night café", "duration_seconds": 30, "format": "mp3" }' # Response { "job_id": "a3f8c2e91b04", "status": "pending" }

Example — Direct Parameters

curl -X POST https://resonant4music.ai/api/v1/generate \ -H "Content-Type: application/json" \ -d '{ "params": {"n": 120, "k": 49, "omega": 2.5, "xi": 1.8}, "duration_seconds": 30 }'

Check Job Status

Poll for generation completion. Jobs typically complete in a few seconds.

GET /jobs/{job_id}

Response

{ "job_id": "a3f8c2e91b04", "status": "complete", "download_url": "/api/v1/jobs/a3f8c2e91b04/download" }

Status values: pendingprocessingcomplete | failed

Download Audio

GET /jobs/{job_id}/download

Returns the generated audio file. Content-Type matches the requested format.

Quick Preview

Synchronous generation of a short (5s) preview clip. Returns audio directly — no job polling needed.

POST /preview

Example

curl -X POST https://resonant4music.ai/api/v1/preview \ -H "Content-Type: application/json" \ -d '{"prompt": "calm piano"}' \ --output preview.wav

List Presets

Get all available curated presets — moods, genres, and scenes mapped to optimized geometry parameters.

GET /presets

Response

{ "presets": [ { "id": "calm", "name": "Calm", "description": "Gentle, meditative tones...", "tags": ["peaceful", "meditation", "ambient"] }, ... ] }

60+ presets covering moods, genres, scenes, and experimental textures.

Error Handling

Errors return standard HTTP status codes with a JSON body:

{ "detail": "Provide either 'prompt' or 'params'" }
StatusMeaning
400Bad request — missing or invalid parameters
404Job not found
409Job not yet complete (for download endpoint)
422Validation error — parameter out of range

Tips