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

# Synthesize speech from text

> OpenAI-compatible text to speech. The response body is the raw audio.

`voice` takes the provider's own voice ids, never OpenAI aliases; GET
/v1/models lists the voices and endpoint for each speech model.

Formats differ by model because the providers do. `xai/grok-voice-tts-1.0`
encodes natively (mp3, wav, pcm) and bills $15.00 per 1M input characters,
capped at 15,000 characters per request. `google/gemini-3.1-flash-tts-preview`
emits 24 kHz mono PCM only, so it serves wav (a header over that PCM) and pcm,
and bills tokens at $1.00/1M in and $20.00/1M out.




## OpenAPI

````yaml /openapi.yaml post /v1/audio/speech
openapi: 3.1.0
info:
  title: Impossibl AI API
  version: 0.0.1
  description: >
    The Impossibl AI API is one API for all AI providers, OpenAI-compatible
    across OpenAI,

    Anthropic, Google, xAI, and more (`GET /v1/models` lists the full catalog),

    billed from a prepaid credit balance.


    Provider usage is billed at provider list prices with no usage markup.

    Prepaid credit purchases charge a separate fixed 5% platform fee before tax.


    **Agent quickstart**

    1. `POST /v1/accounts` — create a funded account; you get an API key and a
       signup-bonus balance in one call (no human step required).
    2. Call `POST /v1/chat/completions`, `POST /v1/responses`, or
       `POST /v1/audio/transcriptions` with
       `Authorization: Bearer <key>` and a `provider/model` id from `GET /v1/models`.
    3. Credits are deducted per request by token or audio-duration usage; check
    `GET /v1/account`.
servers:
  - url: https://api.impossibl.com
    description: Production
  - url: http://localhost:8787
    description: Local dev
security:
  - BearerKey: []
paths:
  /v1/audio/speech:
    post:
      summary: Synthesize speech from text
      description: >
        OpenAI-compatible text to speech. The response body is the raw audio.


        `voice` takes the provider's own voice ids, never OpenAI aliases; GET

        /v1/models lists the voices and endpoint for each speech model.


        Formats differ by model because the providers do.
        `xai/grok-voice-tts-1.0`

        encodes natively (mp3, wav, pcm) and bills $15.00 per 1M input
        characters,

        capped at 15,000 characters per request.
        `google/gemini-3.1-flash-tts-preview`

        emits 24 kHz mono PCM only, so it serves wav (a header over that PCM)
        and pcm,

        and bills tokens at $1.00/1M in and $20.00/1M out.
      operationId: createSpeech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
                - voice
              properties:
                model:
                  type: string
                  enum:
                    - xai/grok-voice-tts-1.0
                    - google/gemini-3.1-flash-tts-preview
                input:
                  type: string
                  description: Text to speak. Both models accept inline expressive tags.
                voice:
                  type: string
                  description: A voice id the chosen model supports (see GET /v1/models).
                  example: eve
                response_format:
                  type: string
                  enum:
                    - mp3
                    - wav
                    - pcm
                  description: >
                    Defaults to the model's native format: mp3 for xai, wav for
                    google.

                    A format the model cannot produce is a 400, never a
                    substitution.
                speed:
                  type: number
                  minimum: 0.7
                  maximum: 1.5
                  default: 1
                  description: >
                    Playback rate, xai/grok-voice-tts-1.0 only. Gemini has no
                    rate

                    control, so any value other than 1 is a 400 there rather
                    than a

                    silently ignored parameter.
      responses:
        '200':
          description: The synthesized audio.
          content:
            audio/mpeg:
              schema:
                type: string
                format: binary
            audio/wav:
              schema:
                type: string
                format: binary
            audio/pcm:
              schema:
                type: string
                format: binary
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientCredits'
        '404':
          $ref: '#/components/responses/UnknownModel'
        '502':
          $ref: '#/components/responses/UpstreamError'
        '503':
          $ref: '#/components/responses/ProviderNotConfigured'
components:
  responses:
    BadRequest:
      description: Malformed request (bad JSON, or missing required fields).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: '`model` and `messages` are required'
              type: invalid_request_error
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: Invalid API key
              type: authentication_error
    InsufficientCredits:
      description: The account's credit balance is empty. Top up to continue.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: Insufficient credits. Top up to continue.
              type: insufficient_quota
    UnknownModel:
      description: The requested `model` id is not in the registry (see GET /v1/models).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: 'Unknown model: foo/bar'
              type: invalid_request_error
    UpstreamError:
      description: The upstream provider returned an error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: 'permission-denied: ...'
              type: upstream_error
    ProviderNotConfigured:
      description: The provider for this model has no API key configured on the gateway.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: 'Provider not configured: missing OPENAI_API_KEY'
              type: provider_not_configured
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
              description: >-
                One of authentication_error, invalid_request_error,
                insufficient_quota, upstream_error, provider_not_configured.
  securitySchemes:
    BearerKey:
      type: http
      scheme: bearer
      description: Gateway API key (`imp-rt-...`) from POST /v1/accounts or /v1/keys.

````