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

# Stream text to speech

> Synthesize speech and stream the audio back as it is generated, for the lowest possible time-to-first-byte over HTTP. The response is a chunked stream of raw 16-bit little-endian PCM (`audio/L16`) at 44.1 kHz, mono.

Metadata is returned in response headers before the body streams: `X-inference-id`, `X-audio-url`, and `Credit-Utilized`. Because the HTTP status line is sent before generation begins, a mid-stream failure ends the stream early rather than changing the status code — always verify you received a complete stream.

**Cost:** 1 credit per input character, charged up front. If generation fails, the credits are refunded.



## OpenAPI

````yaml POST /v1/tts/stream
openapi: 3.1.0
info:
  title: Chariot AI API
  version: '1'
  description: >-
    Chariot AI is a text-to-speech (TTS) platform built for Indian and English
    voices. Convert text into natural-sounding speech over a simple REST call,
    an HTTP audio stream, or a low-latency WebSocket. This reference documents
    the public, API-key-authenticated endpoints. Speech-to-text (ASR) is coming
    soon.
  contact:
    name: Chariot AI Support
    email: support@chariot.in
    url: https://chariot.in
servers:
  - url: https://api.chariot.in
    description: Production
  - url: https://dev-api.chariot.in
    description: Development / sandbox
security:
  - APIKeyHeader: []
tags:
  - name: Text to Speech
    description: Convert text into speech synchronously or as a stream.
  - name: Voices
    description: List the voice catalog and manage your cloned (custom) voices.
  - name: Account
    description: Inspect your credit balance and usage.
paths:
  /v1/tts/stream:
    post:
      tags:
        - Text to Speech
      summary: Stream text to speech
      description: >-
        Synthesize speech and stream the audio back as it is generated, for the
        lowest possible time-to-first-byte over HTTP. The response is a chunked
        stream of raw 16-bit little-endian PCM (`audio/L16`) at 44.1 kHz, mono.


        Metadata is returned in response headers before the body streams:
        `X-inference-id`, `X-audio-url`, and `Credit-Utilized`. Because the HTTP
        status line is sent before generation begins, a mid-stream failure ends
        the stream early rather than changing the status code — always verify
        you received a complete stream.


        **Cost:** 1 credit per input character, charged up front. If generation
        fails, the credits are refunded.
      operationId: streamSpeech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TTSPayload'
      responses:
        '200':
          description: A chunked stream of raw PCM audio (16-bit LE, 44100 Hz, mono).
          headers:
            X-inference-id:
              description: Unique id for this generation.
              schema:
                type: string
                format: uuid
            X-audio-url:
              description: >-
                Persistent URL to the fully assembled WAV once the stream
                completes.
              schema:
                type: string
                format: uri
            Credit-Utilized:
              description: Credits charged for this request.
              schema:
                type: integer
          content:
            audio/L16:
              schema:
                type: string
                format: binary
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/InsufficientCreditsOrPlan'
        '404':
          $ref: '#/components/responses/VoiceNotFound'
        '422':
          $ref: '#/components/responses/ValidationError'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    TTSPayload:
      type: object
      required:
        - voice_id
        - text
      properties:
        voice_id:
          type: string
          format: uuid
          description: The voice to synthesize with. Get valid ids from `GET /v1/voices`.
          example: bac7d666-094d-4698-91fa-741d60fce662
        text:
          type: string
          description: >-
            The text to synthesize. 1 to 500 characters after trimming
            whitespace.
          minLength: 1
          maxLength: 500
          example: Hello from Chariot AI.
        model_type:
          $ref: '#/components/schemas/TTSModelType'
    TTSModelType:
      type: string
      description: The TTS model to use. Currently only `v0` is available.
      enum:
        - v0
      default: v0
    Error:
      type: object
      description: Standard error envelope returned by all endpoints.
      properties:
        statusCode:
          type: integer
          description: HTTP status code, echoed in the body.
        error:
          type: string
          description: Machine-readable error class name.
        message:
          type: string
          description: Human-readable description of what went wrong.
      required:
        - statusCode
        - error
        - message
  responses:
    Unauthorized:
      description: >-
        Authentication failed — the API key is missing, invalid, expired, or the
        request origin is not allowed for this key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            missing:
              summary: No credentials provided
              value:
                statusCode: 401
                error: UnauthorizedException
                message: No API key or user credentials provided
            invalid:
              summary: Invalid or unknown API key
              value:
                statusCode: 401
                error: UnauthorizedException
                message: Invalid API Key or user credentials
    InsufficientCreditsOrPlan:
      description: >-
        The request is authenticated but not permitted: the workspace has
        insufficient credits, or the plan does not include this product.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            insufficient_credits:
              summary: Not enough credits
              value:
                statusCode: 403
                error: InsufficientCreditsException
                message: Workspace has 4 credits; needs 128
            not_on_plan:
              summary: Product not available on plan
              value:
                statusCode: 403
                error: HTTPException
                message: >-
                  Product model tts.standard is not available on the current
                  plan
    VoiceNotFound:
      description: >-
        The requested voice does not exist or is not accessible to your
        workspace.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 404
            error: EntityNotFoundException
            message: >-
              Voice with id: 00000000-0000-0000-0000-000000000000 does not
              exist!
    ValidationError:
      description: >-
        The request failed validation. This includes malformed JSON, missing or
        wrongly typed fields, out-of-range values, and business-rule violations
        such as text length limits or a voice that is not ready for synthesis.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            text_too_long:
              summary: Text over the 500-character limit
              value:
                statusCode: 422
                error: ValidationException
                message: >-
                  Input text of length 812 is more than maximum character count
                  of 500 characters!
            voice_not_ready:
              summary: Voice still processing
              value:
                statusCode: 422
                error: ValidationException
                message: >-
                  Voice 3acc7441-4dce-4245-a365-0bae822c8c30 is not ready for
                  TTS yet!
    ServerError:
      description: >-
        An unexpected error occurred while processing the request. Any credits
        charged for a failed generation are refunded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            statusCode: 500
            error: ProcessException
            message: TTS prediction error! for input of length 128
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: chariotai-api-key
      description: >-
        Your Chariot AI API key, generated from the dashboard. Send it in the
        `chariotai-api-key` header on every request.

````