Getting startedYour first request

Your first request

This example uses speech synthesis to walk through the full asynchronous job flow: submit a job, check its status and fetch the result. Requests go to the API Base URL https://shixux.com/api. Run them on your server and replace yb_xxx_yyy with your API Key.

1. Submit a job

curl -X POST 'https://shixux.com/api/v1/tts' \
  -H 'X-API-Key: yb_xxx_yyy' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: tts-order-1001' \
  -d '{"text":"Hello from Shixu.","voice_preset_id":"vp_000000000000000000000001"}'

The request body contains the text to synthesize and one voice. This example uses a preset voice. To use your own voice, upload it first.

The API returns 202 with the job. Save its id, such as job_xxx. Idempotency-Key makes retries safe: if you resend the same request after a network problem with the same value, no duplicate job is created. See Asynchronous jobs.

2. Check the job status

curl 'https://shixux.com/api/v1/jobs/job_xxx' \
  -H 'X-API-Key: yb_xxx_yyy'

While the job is queued or processing, check again after a few seconds and lengthen the interval over time. Fetch the result once the status is succeeded. If it is failed, read error_code and error_message; reserved credits are refunded automatically. Do not submit a new generation request in place of checking the status.

3. Fetch the result

curl 'https://shixux.com/api/v1/jobs/job_xxx/result' \
  -H 'X-API-Key: yb_xxx_yyy'

Download the audio from result_url. expires_in is the lifetime of the download URL in seconds, and retained_until is when the result file stops being retained. Call this endpoint again to get a new URL after the old one expires.

Next steps

On this page