- Submit the request. You get back an operation
idandstatus: "processing". - Wait until
statusisreadyorfailed, by polling the same endpoint (or by receiving a webhook). - Download the audio from the signed URL in the result.
Step 1: Get your API key
API keys are issued from your account dashboard, under Developer → API keys. A key is shown once, when you create it, so save it somewhere safe. Keys start withspk_; the prefix is part of the key.
Put the key in an environment variable, so it never appears in your code:
Step 2: Save the reference client
Copy the file for your language from The reference client into a new folder:- Python: save it as
soundpiece.py, then runpip install requests. - JavaScript: save it as
soundpiece.mjs. It needs Node.js 18 or later and nothing else.
Step 3: Generate a song
Save this program next to the client and run it. Generating a song usually takes a minute or two.run returns the finished song object. It looks like this:
ididentifies the operation. You can poll it again later withGET /v1/create.new_song?id=....idempotency_keyis the key the client sent with your request. Sending the same key again returns this same operation instead of starting new work; see keeping a key across re-runs.outputshas one entry per variation. Setn_variations(1 to 3) in the request for more.urlis a signed download link for a FLAC file (44.1 kHz). It needs no API key, and stops working atexpires_at. Poll the operation again for a fresh one.
run raises a SoundpieceError carrying the result’s error.code and error.message; see Errors.
Next steps
The same pattern works for every endpoint. Swap the endpoint name and the request body:
Each endpoint has a guide with a complete example, its result, its errors and its cost; follow the links in the table. The exact fields are in the API Reference, e.g.
create.new_song (submit). Before you go to production, work through the production checklist.