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

# 建立語音

> Convert text into natural speech with the OpenAI-compatible audio speech interface. Returns a binary audio stream — save the response body directly to a file.



## OpenAPI

````yaml api-reference/openapi.json POST /v1/audio/speech
openapi: 3.1.0
info:
  title: DGrid AI Gateway API
  description: >-
    A single, unified API to access 200+ leading AI models. OpenAI-, Claude-,
    and Gemini-compatible endpoints for chat, completions, embeddings, images,
    audio, and moderations.
  version: 1.0.0
  contact:
    name: DGrid AI
    url: https://dgrid.ai
servers:
  - url: https://api.dgrid.ai
    description: DGrid AI Gateway
security:
  - bearerAuth: []
paths:
  /v1/audio/speech:
    post:
      tags:
        - Audio
      summary: Create speech
      description: >-
        Convert text into natural speech with the OpenAI-compatible audio speech
        interface. Returns a binary audio stream — save the response body
        directly to a file.
      operationId: createSpeech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
                - voice
              properties:
                model:
                  type: string
                  description: Voice model, such as `tts-1` or `tts-1-hd`.
                  example: tts-1
                input:
                  type: string
                  description: Text to synthesize, up to 4096 characters.
                voice:
                  type: string
                  enum:
                    - alloy
                    - echo
                    - fable
                    - onyx
                    - nova
                    - shimmer
                  description: Voice preset.
                response_format:
                  type: string
                  default: mp3
                  description: Output audio format.
                speed:
                  type: number
                  default: 1
                  minimum: 0.25
                  maximum: 4
                  description: Speaking speed.
            example:
              model: tts-1
              input: Hello from DGrid.
              voice: alloy
      responses:
        '200':
          description: Binary audio stream.
          content:
            audio/mpeg:
              schema:
                type: string
                format: binary
        '400':
          $ref: '#/components/responses/BadRequest'
components:
  responses:
    BadRequest:
      description: Invalid request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            param:
              type: string
            code:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your DGrid API key. All endpoints use `Authorization: Bearer
        <DGRID_API_KEY>`.

````