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

# Clone a voice

> Clone a voice from a reference audio clip. Use the returned voice `id` in your `/tts/bytes`, `/tts/sse`, and `/tts/websocket` requests.

WAV is recommended; FLAC, OGG, MP3, and M4A also work. Clips must be 1–300 s and the upload under 20 MB. The server trims leading and trailing silence, uses the first 20 s of speech, and normalizes loudness. 10–20 s of clean speech works best, and the voice takes on the clip's pace and pauses. The response returns before the voice's 48 kHz preview exists and has no `preview_file_url` field. The preview renders in the background after cloning, usually within a few seconds (a failed render is retried automatically within about 5 minutes). Until it's ready, `preview_file_url` is `null`. Poll `GET /voices/{id}?expand[]=preview_file_url`, or show the preview as pending.

Errors come in two shapes: audio validation errors are `{ "detail": "..." }`; `invalid_language`, `clone_failed`, and `db_unavailable` use `{ error, message }`.



## OpenAPI

````yaml api-reference/openapi.json POST /voices/clone
openapi: 3.1.0
info:
  title: Nineninesix TTS API
  description: >-
    Cartesia-compatible Text-to-Speech API for voice agents and real-time
    dialogue. Point the official Cartesia SDKs at this base URL and they just
    work.
  version: 0.5.1
  contact:
    name: Nineninesix Support
    email: ulan@nineninesix.ai
servers:
  - url: https://api.nineninesix.ai
    description: Production
security:
  - bearerAuth: []
  - apiKeyHeader: []
tags:
  - name: Speech
    description: Generate audio from text.
  - name: Voices
    description: List, fetch, and clone voices.
paths:
  /voices/clone:
    post:
      tags:
        - Voices
      summary: Clone a voice
      description: >-
        Clone a voice from a reference audio clip. Use the returned voice `id`
        in your `/tts/bytes`, `/tts/sse`, and `/tts/websocket` requests.


        WAV is recommended; FLAC, OGG, MP3, and M4A also work. Clips must be
        1–300 s and the upload under 20 MB. The server trims leading and
        trailing silence, uses the first 20 s of speech, and normalizes
        loudness. 10–20 s of clean speech works best, and the voice takes on the
        clip's pace and pauses. The response returns before the voice's 48 kHz
        preview exists and has no `preview_file_url` field. The preview renders
        in the background after cloning, usually within a few seconds (a failed
        render is retried automatically within about 5 minutes). Until it's
        ready, `preview_file_url` is `null`. Poll `GET
        /voices/{id}?expand[]=preview_file_url`, or show the preview as pending.


        Errors come in two shapes: audio validation errors are `{ "detail":
        "..." }`; `invalid_language`, `clone_failed`, and `db_unavailable` use
        `{ error, message }`.
      operationId: cloneVoice
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - name
                - clip
              properties:
                clip:
                  type: string
                  format: binary
                  description: >-
                    Reference audio to clone from. WAV recommended; FLAC, OGG,
                    MP3, and M4A also work. 1–300 s, under 20 MB. Only the first
                    20 s of speech (after silence trimming) is used.
                name:
                  type: string
                  description: A name for the cloned voice.
                language:
                  type: string
                  description: >-
                    A well-formed BCP-47 language tag, e.g. `en-US`, `en-GB`,
                    `es-MX`, `th-TH`, `ms-MY`. Stored as metadata (used for
                    listing and filtering); it doesn't change synthesis. The
                    value is canonicalized on save (`en-us` → `en-US`, `pt-br` →
                    `pt-BR`). Malformed tags (`en_US`, `en-USA`, `english_`,
                    `123`) are rejected with `invalid_language` (400).
                  example: en-US
                description:
                  type: string
                  description: A description of the voice.
                transcript:
                  type: string
                  description: >-
                    The exact words spoken in the clip. With a transcript, the
                    clone follows the speaker, including their pace, more
                    closely. It must match the audio exactly, and it's ignored
                    if the clip has 20 s or more of speech after silence
                    trimming, so send a clip under 20 s when you use it. Not a
                    Cartesia SDK field: pass it via `extra_body` (Python) or as
                    an extra key with a type cast (TypeScript).
      responses:
        '200':
          description: The newly created voice.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Voice'
        '400':
          description: >-
            The clip can't be decoded or is under 1 s (`{ detail }` shape — the
            message says "expected WAV" even for other supported formats), or
            `language` is not a well-formed BCP-47 tag (`invalid_language`, `{
            error, message }` shape).
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/CloneAudioError'
                  - $ref: '#/components/schemas/Error'
              examples:
                bad_clip:
                  summary: Clip can't be decoded
                  value:
                    detail: >-
                      Bad clip (expected WAV): could not decode audio: <decoder
                      message>
                too_short:
                  summary: Clip under 1 s
                  value:
                    detail: 'Bad clip: reference audio is 0.62s; need at least 1 s'
                invalid_language:
                  summary: language is not a BCP-47 tag
                  value:
                    error: invalid_language
                    message: language must be a BCP-47 tag like "en-US"; got "en_US"
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '413':
          description: The upload is over 20 MB or the clip is longer than 300 s.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CloneAudioError'
              examples:
                too_long:
                  summary: Clip over 300 s
                  value:
                    detail: 'Bad clip: reference audio is 312.4s; max 300s'
                too_large:
                  summary: Upload over 20 MB
                  value:
                    detail: clip exceeds 20 MB
        '502':
          description: The voice couldn't be created (`clone_failed`). Retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: clone_failed
                message: …
        '503':
          description: >-
            The cloning service is still starting (`{ detail }` shape), or voice
            storage is temporarily unavailable (`db_unavailable`, `{ error,
            message }` shape). Retry shortly.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/CloneAudioError'
                  - $ref: '#/components/schemas/Error'
              examples:
                starting:
                  summary: Cloning service is starting
                  value:
                    detail: TTS models not initialized
                db_unavailable:
                  summary: Voice storage unavailable
                  value:
                    error: db_unavailable
                    message: …
components:
  schemas:
    Voice:
      type: object
      properties:
        id:
          type: string
          format: uuid
          example: 5148a2db-5f7c-480c-8f7c-39c6414a4d5d
        is_owner:
          type: boolean
          description: '`true` if your org owns the voice (you cloned it).'
          example: false
        is_public:
          type: boolean
          description: '`true` for shared library voices.'
          example: true
        name:
          type: string
          example: Jessica
        description:
          type: string
          example: >-
            Polished, quick New York professional around thirty-five, warm
            underneath the hustle. Jessica makes a stressful thing feel
            manageable.
        gender:
          type: string
          enum:
            - masculine
            - feminine
            - gender_neutral
          example: feminine
        language:
          type: string
          description: BCP-47 dialect tag (e.g. `en-US`, `nl-NL`).
          example: en-US
        country:
          type: string
          description: Country code.
          example: US
        created_at:
          type: string
          format: date-time
          description: When the voice was created.
          example: '2026-08-14T18:26:40.876Z'
        preview_file_url:
          type:
            - string
            - 'null'
          description: >-
            Only present when the request sends `expand[]=preview_file_url`. A
            signed, browser-playable URL of the voice's preview, or `null` while
            a new clone's preview is still rendering. Not included in the clone
            response.
    CloneAudioError:
      type: object
      description: Audio validation error from `/voices/clone`.
      properties:
        detail:
          type: string
          description: Human-readable description.
          example: 'Bad clip (expected WAV): …'
    Error:
      type: object
      description: >-
        Standard HTTP error envelope for the TTS endpoints. `error_code` is the
        canonical machine-readable field; `error` mirrors it and `detail` is
        kept for backward-compatibility. (`/voices/clone` uses the shorter `{
        error, message }` shape, or `{ detail }` for audio validation errors.)
      properties:
        error:
          type: string
          description: Machine-readable error code (mirrors `error_code`).
          example: voice_not_found
        error_code:
          type: string
          description: Canonical machine-readable error code.
          example: voice_not_found
        message:
          type: string
          description: Human-readable description.
          example: voice not found
        detail:
          type: string
          description: Backward-compatible detail string; usually mirrors `message`.
          example: voice not found
  responses:
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: unauthorized
            message: invalid API key
    PaymentRequired:
      description: >-
        The org's balance is zero or below. Billing is postpaid: new requests
        start only while the balance is positive, so the last request can take
        it slightly below zero.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: payment_required
            message: insufficient credits
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Pass your API key as a Bearer token: `Authorization: Bearer sk_996_...`.'
    apiKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
      description: Alternatively, pass your API key in the `X-API-Key` header.

````

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