Finetuning.aiFinetuning.ai

cURL Examples

API examples using cURL

Check account info

curl https://pub.finetuning.ai/v1/me \
  -H "X-API-Key: $FINETUNING_API_KEY"

Create a generation

curl -X POST https://pub.finetuning.ai/v1/generations \
  -H "X-API-Key: $FINETUNING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tags": "upbeat electronic track with synth leads and driving bass",
    "duration": 60,
    "bpm": 128,
    "key": "C",
    "scale": "minor"
  }'

Get generation status

curl https://pub.finetuning.ai/v1/generations/gen_abc123xyz \
  -H "X-API-Key: $FINETUNING_API_KEY"

List all completed generations

curl "https://pub.finetuning.ai/v1/generations?status=completed&limit=20" \
  -H "X-API-Key: $FINETUNING_API_KEY"

Poll until complete and download

#!/bin/bash
GEN_ID="gen_abc123xyz"
API_KEY="$FINETUNING_API_KEY"

while true; do
  RESPONSE=$(curl -s "https://pub.finetuning.ai/v1/generations/$GEN_ID" \
    -H "X-API-Key: $API_KEY")

  STATUS=$(echo "$RESPONSE" | jq -r '.data.status')
  echo "Status: $STATUS"

  if [ "$STATUS" = "completed" ]; then
    AUDIO_URL=$(echo "$RESPONSE" | jq -r '.data.audioUrl')
    echo "Downloading: $AUDIO_URL"
    curl -o "output.mp3" "$AUDIO_URL"
    echo "Done!"
    break
  elif [ "$STATUS" = "failed" ]; then
    echo "Generation failed"
    echo "$RESPONSE" | jq '.data.errorMessage'
    break
  fi

  sleep 3
done

On this page