> ## Documentation Index
> Fetch the complete documentation index at: https://docs.powertokens.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Text to Speech

> Call Ali `qwen3-tts-instruct-flash` through the unified `/v1/audio/speech` endpoint.

Response contract:
- non-streaming returns the official Ali JSON response;
- streaming returns `text/event-stream` and forwards Ali SSE payloads.



## OpenAPI

````yaml api-reference/en/zmodelAudio/ali/qwen3-tts-instruct-flash.json POST /v1/audio/speech
openapi: 3.0.1
info:
  title: Ali Text-to-Speech
  version: 1.0.0
  description: >-
    Ali channel text-to-speech capability for `/v1/audio/speech`. The project
    currently implements the official field subset for
    `qwen3-tts-instruct-flash` only.


    This document intentionally includes only the implemented official fields:
    `model`, `input`, `voice`, `instructions`, `optimize_instructions`, and
    `language_type`.


    Streaming follows the official Ali HTTP contract: clients must explicitly
    send `X-DashScope-SSE: enable` in the request header. This channel does not
    expose `stream_format`.


    Billing note: the gateway maps upstream `usage.characters` to unified
    `usage.prompt_tokens_details.audio_tokens`, keeps `usage.output_tokens` in
    `usage.completion_tokens_details.audio_tokens`, and stores both raw Ali
    usage and normalized usage snapshots in consume_detail for billing
    traceability.
servers:
  - url: https://api.powertokens.ai
    description: Baze API service endpoint
security: []
tags:
  - name: Ali Audio
    description: Ali text-to-speech capability
paths:
  /v1/audio/speech:
    post:
      tags:
        - Ali Audio
      summary: Ali text-to-speech
      description: >-
        Call Ali `qwen3-tts-instruct-flash` through the unified
        `/v1/audio/speech` endpoint.


        Response contract:

        - non-streaming returns the official Ali JSON response;

        - streaming returns `text/event-stream` and forwards Ali SSE payloads.
      operationId: aliAudioSpeech
      parameters:
        - name: X-DashScope-SSE
          in: header
          required: false
          description: >-
            Official Ali HTTP streaming switch. Send `enable` to receive
            `text/event-stream`.
          schema:
            type: string
            enum:
              - enable
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AliSpeechRequest'
            examples:
              basic:
                summary: Non-streaming request
                value:
                  model: qwen3-tts-instruct-flash
                  input: Introduce this product with a slightly faster speaking rate.
                  voice: Cherry
                  instructions: Speak faster with a brighter tone.
                  optimize_instructions: false
                  language_type: English
              stream:
                summary: Streaming request
                value:
                  model: qwen3-tts-instruct-flash
                  input: Today is a wonderful day to build something people love.
                  voice: Cherry
                  language_type: English
      responses:
        '200':
          description: >-
            Successful call. Non-streaming returns the official Ali JSON
            response; streaming returns Ali SSE payloads.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AliSpeechResponse'
            text/event-stream:
              schema:
                type: string
                description: >-
                  Ali SSE event stream. Each event body can be parsed as an Ali
                  audio response chunk.
        '400':
          description: Invalid request parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    AliSpeechRequest:
      type: object
      required:
        - model
        - input
        - voice
      properties:
        model:
          type: string
          description: 'Model name. Available options: `qwen3-tts-instruct-flash`.'
          enum:
            - qwen3-tts-instruct-flash
        input:
          type: string
          description: Text to synthesize. This field accepts multilingual input.
        voice:
          type: string
          description: Voice to use. See supported system voices.
          enum:
            - Cherry
            - Serena
            - Ethan
            - Chelsie
            - Momo
            - Vivian
            - Moon
            - Maia
            - Kai
            - Nofish
            - Bella
            - Eldric Sage
            - Mia
            - Mochi
            - Bellona
            - Vincent
            - Bunny
            - Neil
            - Elias
            - Arthur
            - Nini
            - Seren
            - Pip
            - Stella
        instructions:
          type: string
          description: >-
            Sets instructions. See instruction control.


            Default: none, no effect when not set.

            Maximum length: 1600 tokens.

            Supported languages: Chinese and English only.

            Scope: This feature is only supported by the
            qwen3-TTS-Instruct-Flash-Realtime series models.
        optimize_instructions:
          type: boolean
          description: >-
            Optimizes `instructions` semantically to improve the naturalness and
            expressiveness of voice synthesis.


            Default: `false`.

            Behavior: When set to `true`, the system semantically enhances and
            rewrites the `instructions` content to generate internal
            instructions better suited for voice synthesis.

            Recommended for high-quality, refined voice expression.

            Depends on the `instructions` parameter. If `instructions` is empty,
            this parameter has no effect.

            Scope: This feature is only supported by the
            qwen3-TTS-Instruct-Flash series models.
        language_type:
          type: string
          description: >-
            Language type for the synthesized audio. Defaults to `Auto`.


            - `Auto`: Suitable when the text contains multiple languages or the
            language is uncertain. The model automatically matches pronunciation
            for different language segments, but accuracy is not guaranteed.

            - Specified language: Suitable for single-language text. Specifying
            a language significantly improves synthesis quality, generally
            outperforming `Auto`.
          enum:
            - Auto
            - Chinese
            - English
            - German
            - Italian
            - Portuguese
            - Spanish
            - Japanese
            - Korean
            - French
            - Russian
    AliSpeechResponse:
      type: object
      properties:
        status_code:
          type: integer
          description: |-
            HTTP status code. Follows RFC 9110 definitions. For example:
            - 200: Request successful, normal response returned
            - 400: Client request parameter error
            - 401: Unauthorized access
            - 404: Resource not found
            - 500: Internal server error
        request_id:
          type: string
          description: >-
            Unique request identifier for this request, useful for
            troubleshooting.
        code:
          type: string
          description: Error code. Returned when the request fails.
        message:
          type: string
          description: Error message. Returned when the request fails.
        output:
          type: object
          description: Model output.
          properties:
            text:
              nullable: true
              description: Always null and can be ignored.
            finish_reason:
              type: string
              description: >-
                Generation status identifier. It is `null` while still
                generating; it becomes `stop` when the model naturally finishes
                or a stop condition is triggered.
            choices:
              nullable: true
              description: Always null and can be ignored.
            audio:
              type: object
              properties:
                data:
                  type: string
                  description: Base64 audio data for streaming output.
                url:
                  type: string
                  format: uri
                  description: Full audio file URL, valid for 24 hours.
                id:
                  type: string
                  description: Unique audio identifier.
                expires_at:
                  type: integer
                  description: UNIX timestamp of the URL expiration time.
        usage:
          type: object
          description: >-
            Token or character consumption for this request. qwen-TTS returns
            token consumption information, while qwen3-TTS-Flash returns
            character consumption information.
          properties:
            input_tokens:
              type: integer
              description: >-
                Input token count. For `qwen3-tts-flash`, this field is fixed at
                0.
            output_tokens:
              type: integer
              description: >-
                Output audio token count. For `qwen3-tts-flash`, this field is
                fixed at 0.
            total_tokens:
              type: integer
              description: Total token count. Only returned by `qwen-tts`.
            characters:
              type: integer
              description: Input character count. Only returned by `qwen3-tts-flash`.
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorObject'
    ErrorObject:
      type: object
      required:
        - message
        - type
        - param
        - code
      properties:
        message:
          type: string
        type:
          type: string
        param:
          type: string
        code:
          type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Token
      description: 'Pass `Authorization: Bearer <token>` in the request header.'

````