API Platform

Quickstart: Single-Speaker Speech Generation

Synthesize a piece of text into speech in a single voice — well suited for narration, customer-service scripts, announcements, and audio content generation.

POST /v1/audio/speech

Endpoint

moss-tts

Model

  1. Create an API Key

    Open the API Key management platform, create an API Key, and save it as an environment variable. Do not write the API Key into client-side code or commit it to a repository.

    Example
    export MOSS_API_KEY="<your-api-key>"
    
  2. Prepare the request input

    Use model to specify the model and fill in the input fields required for single-speaker speech generation. For the reference voice, first create it with POST /v1/audio/voices, then use the resulting voice_id here.

    input: text to synthesize voice or voice_id: target voice response_format: output format, defaults to mp3 delivery_method: audio or url

    Example
    {
      "model": "moss-tts",
      "input": "Welcome to the Mossland API.",
      "voice_id": "<voice_id>",
      "response_format": "mp3",
      "delivery_method": "url"
    }
    
  3. Make your first request

    Send a request to /v1/audio/speech. When delivery_method=url, JSON with a result URL is returned synchronously.

    curl https://api.mosi.cn/v1/audio/speech \
      -H "Authorization: Bearer $MOSS_API_KEY" \
      -H "Content-Type: application/json" \
      -d @request.json
    
  4. Retrieve the result

    When delivery_method=url, read the result URL directly from the synchronous response JSON. If you passed async=true, the endpoint first returns a task_id, which you then use to query the task.

    curl https://api.mosi.cn/v1/audio/tasks/$TASK_ID \
      -H "Authorization: Bearer $MOSS_API_KEY"
    
  5. Verify success

    Sign of success: you obtain the result audio (delivery_method=audio) or the result URL (delivery_method=url), and can download or play the generated audio.

Next steps