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

# xAI TTS 1

> xAI TTS 1 API 可将最多 15,000 个字符的文本转换为语音，支持五种音色之一、BCP-47 语言代码或自动检测，以及行内演绎标签。可选择编码格式、采样率和 MP3 码率。

> [!TIP]
>
> 1. 提交后会返回 `task_id`。如果提供了 `callback_url`，当任务状态变为 `finished` 或 `failed` 时，系统会向 `callback_url` 发送 POST 请求。
> 2. 无论是否提供 `callback_url`，都可以通过统一的[查询任务状态](https://docs.poyo.ai/zh/api-manual/task-management/status.md)接口获取结果。

`xai-tts-1` 通过 fal 调用 xAI TTS，将文本转换为低延迟、富有表现力的语音音频。结果以任务 `files` 返回，与图像、视频、3D 和音频任务的标准响应结构一致。

## 模型

* **xai-tts-1** - xAI TTS v1 文本转语音生成

## 必填参数

* **text**：要转换为语音的文本
  * 长度：`1-15000` 个字符
  * 支持富有表现力的语音标签，例如 `[laugh]`、`[pause]`、`[sigh]`、`<whisper>text</whisper>` 和 `<slow>text</slow>`

## 可选参数

* **voice**：预设音色。支持的值：`eve`、`ara`、`rex`、`sal`、`leo`。默认：`eve`
* **language\_code**：BCP-47 语言代码，或 `auto` 表示自动检测。默认：`auto`
* **output\_format**：音频输出配置对象：
  * `codec`：`mp3`、`wav`、`pcm`、`mulaw` 或 `alaw`。默认：`mp3`
  * `sample_rate`：`8000`、`16000`、`22050`、`24000`、`44100` 或 `48000`。默认：`24000`
  * `bit_rate`：`32000`、`64000`、`96000`、`128000`、`192000` 或 `null`。仅适用于 MP3。默认：`128000`

## 示例

```json theme={"dark"}
{
  "model": "xai-tts-1",
  "callback_url": "https://your-domain.com/callback",
  "input": {
    "text": "Welcome to the xAI text to speech demo. [pause] <whisper>This line is softer.</whisper> [laugh] Now back to a clear product narration voice.",
    "voice": "eve",
    "language_code": "auto",
    "output_format": {
      "codec": "mp3",
      "sample_rate": 24000,
      "bit_rate": 128000
    }
  }
}
```

## 注意事项

### 支持的语言

支持的值：`auto`、`en`、`ar-EG`、`ar-SA`、`ar-AE`、`bn`、`zh`、`fr`、`de`、`hi`、`id`、`it`、`ja`、`ko`、`pt-BR`、`pt-PT`、`ru`、`es-MX`、`es-ES`、`tr`、`vi`。

* PoYo 对外公开的参数名是 `language_code`，在上游映射到 fal 的 `language` 字段。
* PoYo 对外公开的参数名是 `text`，在上游映射到 fal 的 `text` 字段。
* 通过标准任务状态 API 查询状态。
* 成功响应返回 `files`，其中生成的语音使用 `file_type: audio`。


## OpenAPI

````yaml zh/api-manual/music-series/xai-tts-1.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: PoYo AI - xAI TTS 1 API
  description: >-
    xAI TTS 1 API 将最多 15,000 个字符的文本转换为语音，可选五种音色之一，支持 BCP-47
    语言代码或自动检测，以及行内表达标签。可选择编解码器、采样率和 MP3 比特率。
  version: 1.0.0
servers:
  - url: https://api.poyo.ai
    description: 生产环境
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      tags:
        - xAI TTS 1
      summary: 提交 xAI TTS 1 任务
      description: 将文本转换为富有表现力的语音音频。
      operationId: submitXaiTts1Task
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              text-to-speech:
                summary: 文本转语音
                value:
                  model: xai-tts-1
                  callback_url: https://your-domain.com/callback
                  input:
                    text: >-
                      Welcome to the xAI text to speech demo. [pause]
                      <whisper>This line is softer.</whisper> [laugh] Now back
                      to a clear product narration voice.
                    voice: eve
                    language_code: auto
                    output_format:
                      codec: mp3
                      sample_rate: 24000
                      bit_rate: 128000
              telephony:
                summary: 电话场景优化输出
                value:
                  model: xai-tts-1
                  callback_url: https://your-domain.com/callback
                  input:
                    text: >-
                      Your verification code is ready. [pause] Please enter it
                      within five minutes.
                    voice: ara
                    language_code: en
                    output_format:
                      codec: mulaw
                      sample_rate: 8000
      responses:
        '200':
          description: 任务提交成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
        '400':
          description: 请求参数无效
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 未授权
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SubmitRequest:
      type: object
      required:
        - model
        - input
      properties:
        model:
          type: string
          description: 模型标识符。
          enum:
            - xai-tts-1
          example: xai-tts-1
        callback_url:
          type: string
          format: uri
          description: 接收结果通知的 Webhook 回调 URL
          example: https://your-domain.com/callback
        input:
          type: object
          required:
            - text
          additionalProperties: false
          properties:
            text:
              type: string
              description: >-
                要转换为语音的文本。支持 [laugh]、[pause]、[sigh]、<whisper>text</whisper> 和
                <slow>text</slow> 等表现力标签。
              minLength: 1
              maxLength: 15000
              example: Hello! [pause] <whisper>This is a softer line.</whisper>
            voice:
              type: string
              description: 用于语音生成的预设音色。
              enum:
                - eve
                - ara
                - rex
                - sal
                - leo
              default: eve
              example: eve
            language_code:
              type: string
              description: BCP-47 语言代码，或 auto 表示自动检测。
              enum:
                - auto
                - en
                - ar-EG
                - ar-SA
                - ar-AE
                - bn
                - zh
                - fr
                - de
                - hi
                - id
                - it
                - ja
                - ko
                - pt-BR
                - pt-PT
                - ru
                - es-MX
                - es-ES
                - tr
                - vi
              default: auto
              example: auto
            output_format:
              $ref: '#/components/schemas/OutputFormat'
    SubmitResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          example: 200
          enum:
            - 200
            - 400
            - 401
            - 402
            - 403
            - 404
            - 408
            - 429
            - 500
            - 502
            - 503
          description: >-
            业务状态码。`200` 表示成功，其他值都表示请求失败。请务必检查这个字段：部分参数校验错误会以 HTTP 200 返回，响应体里的
            `code` 为 `400`。


            - `200`：成功

            - `400`：请求参数无效

            - `401`：API Key 缺失或无效

            - `402`：积分不足

            - `403`：没有权限

            - `404`：资源不存在

            - `408`：请求超时

            - `429`：请求频率超限

            - `500`：服务器内部错误

            - `502`：上游服务错误

            - `503`：服务暂不可用


            详见[错误码](/zh/api-manual/error-codes)。
        data:
          type: object
          required:
            - task_id
            - status
            - created_time
          properties:
            task_id:
              type: string
              example: task-unified-1757165031-uyujaw3d
            status:
              type: string
              enum:
                - not_started
                - running
                - finished
                - failed
              example: not_started
              description: >-
                任务状态。提交后立即返回时始终为
                `not_started`。后续状态请通过[查询任务状态](/zh/api-manual/task-management/status)接口或
                `callback_url` 获取。


                - `not_started`：排队中，等待处理

                - `running`：生成中

                - `finished`：已完成，结果在 `files` 或 `output` 中

                - `failed`：失败，详情见 `error_message`
            created_time:
              type: string
              format: date-time
              example: '2026-06-25T10:30:00'
    ErrorResponse:
      type: object
      properties:
        code:
          type: integer
          enum:
            - 200
            - 400
            - 401
            - 402
            - 403
            - 404
            - 408
            - 429
            - 500
            - 502
            - 503
          description: >-
            业务状态码。`200` 表示成功，其他值都表示请求失败。请务必检查这个字段：部分参数校验错误会以 HTTP 200 返回，响应体里的
            `code` 为 `400`。


            - `200`：成功

            - `400`：请求参数无效

            - `401`：API Key 缺失或无效

            - `402`：积分不足

            - `403`：没有权限

            - `404`：资源不存在

            - `408`：请求超时

            - `429`：请求频率超限

            - `500`：服务器内部错误

            - `502`：上游服务错误

            - `503`：服务暂不可用


            详见[错误码](/zh/api-manual/error-codes)。
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
    OutputFormat:
      type: object
      additionalProperties: false
      description: 音频输出格式配置。
      properties:
        codec:
          type: string
          enum:
            - mp3
            - wav
            - pcm
            - mulaw
            - alaw
          default: mp3
          example: mp3
        sample_rate:
          type: integer
          enum:
            - 8000
            - 16000
            - 22050
            - 24000
            - 44100
            - 48000
          default: 24000
          example: 24000
        bit_rate:
          type: integer
          nullable: true
          enum:
            - 32000
            - 64000
            - 96000
            - 128000
            - 192000
            - null
          description: 比特率（bps）。仅适用于 MP3 编解码器。
          default: 128000
          example: 128000
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        所有 API 接口都需要 Bearer Token 认证。


        创建 API Key：登录 PoYo，进入 **仪表盘 → API
        密钥**（[poyo.ai/zh/dashboard/api-key](https://poyo.ai/zh/dashboard/api-key)），点击创建
        Key。


        在请求头中添加：


        ```

        Authorization: Bearer YOUR_API_KEY

        ```

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.