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

# Create speech

> Read text aloud with Kokoro, Supertonic or OmniVoice. Returns mono 16-bit audio as a WAV file or raw PCM.

Reads text aloud with one of the [speech models](https://docs.sharemy.ai/models.md#speech). The audio is mono and 16-bit. The model names `tts-1`, `tts-1-hd` and `gpt-4o-mini-tts` all select `kokoro-q8`.

## Voices

| Model | `voice` |
| - | - |
| `kokoro-q8` (default), `kokoro-fp32` | A Kokoro voice id or alias. Default `af_heart`. |
| `supertonic` | `F1` to `F5` or `M1` to `M5`. Default `F1`. Reads English. |
| `omnivoice` | Ignores `voice`. |

Kokoro voices: `af_alloy`, `af_aoede`, `af_bella`, `af_heart`, `af_jessica`, `af_kore`, `af_nicole`, `af_nova`, `af_river`, `af_sarah`, `af_sky`, `am_adam`, `am_echo`, `am_eric`, `am_fenrir`, `am_liam`, `am_michael`, `am_onyx`, `am_puck`, `am_santa`, `bf_alice`, `bf_emma`, `bf_isabella`, `bf_lily`, `bm_daniel`, `bm_fable`, `bm_george`, `bm_lewis`.

Both Kokoro models accept these OpenAI voice names.

| Requested voice | Kokoro voice |
| - | - |
| `alloy` | `af_alloy` |
| `echo` | `am_echo` |
| `fable` | `bm_fable` |
| `onyx` | `am_onyx` |
| `nova` | `af_nova` |
| `shimmer`, `ash`, `ballad`, `coral`, `sage`, `verse` | `af_heart` |

OmniVoice can design or clone a voice in the Voices studio on sharemy.ai. The API does not offer that yet.

```bash theme={null}
curl https://sharemy.ai/v1/audio/speech \
  -H "Authorization: Bearer $SHAREMYAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "omnivoice", "input": "Hello from ShareMyAI."}' \
  --output speech.wav
```

## Formats

| `response_format` | `Content-Type` | What you get |
| - | - | - |
| `wav` (default) | `audio/wav` | A WAV file: 16-bit PCM, mono |
| `pcm` | `audio/pcm` | The same samples with no header: signed 16-bit little-endian, mono |

The sample rate depends on the model. The `X-Sample-Rate` response header gives it in Hz. You need it to play `pcm`. Browsers can read this header across origins.

## Price

Priced by the length of `input`, per 500 characters. See [Credits and pricing](https://docs.sharemy.ai/credits-and-pricing.md#speech).

## Differences from OpenAI

* **`response_format`:** only `wav` and `pcm`. `mp3`, `opus`, `aac` and `flac` are refused.
* **`model`** defaults to `kokoro-q8`, and `voice` is optional.
* **Ignored:** `instructions`, `stream_format`.
* **No streaming:** the audio comes back whole.


## OpenAPI

````yaml api-reference/openapi.json POST /v1/audio/speech
openapi: 3.1.0
info:
  title: ShareMyAI API
  version: 1.0.0
  description: >-
    OpenAI-shaped endpoints that run jobs on shared GPUs. Closing the connection
    cancels an unfinished synchronous job and returns its held credits. CORS
    allows any origin, echoes requested preflight headers and exposes Location,
    the request id, concurrency, retry, cost, balance, token cap and sample rate
    headers.
servers:
  - url: https://sharemy.ai
    description: ShareMyAI
security:
  - bearerAuth: []
tags:
  - name: Models
  - name: Chat
  - name: Images
  - name: Jobs
  - name: Audio
paths:
  /v1/audio/speech:
    post:
      tags:
        - Audio
      summary: Create speech
      description: Read text aloud. Returns mono 16-bit audio as a WAV file or as raw PCM.
      operationId: createSpeech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpeechRequest'
            example:
              model: kokoro-q8
              input: The quick brown fox jumped over the lazy dog.
              voice: af_heart
              response_format: wav
      responses:
        '200':
          description: The audio. The `X-Sample-Rate` header gives its sample rate in Hz.
          headers:
            X-Sample-Rate:
              description: >-
                Samples per second. Needed to play `pcm`, which has no header of
                its own.
              schema:
                type: integer
            x-request-id:
              $ref: '#/components/headers/x-request-id'
            x-ratelimit-limit-concurrent:
              $ref: '#/components/headers/x-ratelimit-limit-concurrent'
            x-ratelimit-remaining-concurrent:
              $ref: '#/components/headers/x-ratelimit-remaining-concurrent'
            X-ShareMyAI-Cost-Credits:
              $ref: '#/components/headers/X-ShareMyAI-Cost-Credits'
            X-ShareMyAI-Balance-Credits:
              $ref: '#/components/headers/X-ShareMyAI-Balance-Credits'
          content:
            audio/wav:
              schema:
                type: string
                contentMediaType: audio/wav
            audio/pcm:
              schema:
                type: string
                contentMediaType: audio/pcm
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientCredits'
        '403':
          $ref: '#/components/responses/Suspended'
        '405':
          $ref: '#/components/responses/MethodNotAllowed'
        '429':
          $ref: '#/components/responses/TooManyCalls'
        '499':
          $ref: '#/components/responses/Cancelled'
        '502':
          $ref: '#/components/responses/NetworkError'
        '503':
          $ref: '#/components/responses/NoProvider'
      x-codeSamples:
        - lang: bash
          label: curl
          source: |-
            curl https://sharemy.ai/v1/audio/speech \
              -H "Authorization: Bearer $SHAREMYAI_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{"model": "kokoro-q8", "voice": "af_heart", "input": "Hello from ShareMyAI."}' \
              --output speech.wav
        - lang: python
          label: Python
          source: >-
            import os

            from openai import OpenAI


            client = OpenAI(api_key=os.environ["SHAREMYAI_API_KEY"],
            base_url="https://sharemy.ai/v1")


            response = client.audio.speech.create(
                model="kokoro-q8",
                voice="af_heart",
                input="Hello from ShareMyAI.",
                response_format="wav",
            )

            response.write_to_file("speech.wav")
        - lang: javascript
          label: Node
          source: >-
            import fs from "node:fs";

            import OpenAI from "openai";


            const client = new OpenAI({ apiKey: process.env.SHAREMYAI_API_KEY,
            baseURL: "https://sharemy.ai/v1" });


            const response = await client.audio.speech.create({
              model: "kokoro-q8",
              voice: "af_heart",
              input: "Hello from ShareMyAI.",
              response_format: "wav",
            });

            fs.writeFileSync("speech.wav", Buffer.from(await
            response.arrayBuffer()));
components:
  schemas:
    SpeechRequest:
      type: object
      required:
        - input
      properties:
        model:
          type:
            - string
            - 'null'
          enum:
            - kokoro-q8
            - kokoro-fp32
            - supertonic
            - omnivoice
            - tts-1
            - tts-1-hd
            - gpt-4o-mini-tts
            - null
          default: kokoro-q8
          description: tts-1, tts-1-hd and gpt-4o-mini-tts select kokoro-q8.
        input:
          type: string
          minLength: 1
          maxLength: 4096
          description: The text to read, 1 to 4,096 characters.
        voice:
          type:
            - string
            - 'null'
          description: >-
            Kokoro accepts native ids and OpenAI names. alloy, echo, fable, onyx
            and nova map to af_alloy, am_echo, bm_fable, am_onyx and af_nova
            respectively. shimmer, ash, ballad, coral, sage and verse map to the
            default af_heart. Supertonic takes F1 to F5 or M1 to M5 and defaults
            to F1. OmniVoice ignores voice.
          examples:
            - af_heart
        speed:
          type:
            - number
            - 'null'
          minimum: 0.5
          maximum: 2
          default: 1
        response_format:
          type:
            - string
            - 'null'
          enum:
            - wav
            - pcm
            - null
          default: wav
          description: >-
            `wav`: a 16-bit mono WAV file. `pcm`: the same samples as raw signed
            16-bit little-endian mono, with no header. `mp3`, `opus`, `aac` and
            `flac` are not offered.
      description: Top-level null fields are treated as omitted.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
    ErrorDetail:
      type: object
      required:
        - message
        - type
        - param
        - code
      properties:
        message:
          type: string
          description: What went wrong, for a person to read.
        type:
          type: string
          description: >-
            402 uses insufficient_quota, other 4xx errors use
            invalid_request_error, and 5xx errors use api_error.
          enum:
            - invalid_request_error
            - insufficient_quota
            - api_error
        param:
          type:
            - string
            - 'null'
          description: The request field at fault, when there is one.
        code:
          type:
            - string
            - 'null'
          description: A stable code. The Errors and limits page lists them all.
          examples:
            - model_not_found
        price_credits:
          type: number
          description: Job price in credits on an insufficient_quota error.
        balance_credits:
          type: number
          description: Account balance in credits on an insufficient_quota error.
      if:
        properties:
          code:
            const: insufficient_quota
      then:
        required:
          - price_credits
          - balance_credits
  headers:
    x-request-id:
      description: Identifier for this API response.
      schema:
        type: string
    x-ratelimit-limit-concurrent:
      description: Job slots per account across all tokens.
      schema:
        type: integer
        const: 4
    x-ratelimit-remaining-concurrent:
      description: Free account slots when headers are sent.
      schema:
        type: integer
        minimum: 0
        maximum: 4
    X-ShareMyAI-Cost-Credits:
      description: >-
        Quoted price in credits when a job was accepted. For a Janus batch, the
        total for completed pictures.
      schema:
        type: number
    X-ShareMyAI-Balance-Credits:
      description: >-
        Balance in credits after the hold, from the last successful quote on a
        Janus batch.
      schema:
        type: number
    X-ShareMyAI-Max-Tokens:
      description: Only on chat requests whose output budget was capped.
      schema:
        type: integer
        const: 4096
    x-should-retry:
      description: >-
        Suppress automatic retries for insufficient_quota,
        content_policy_violation or no_provider.
      schema:
        type: string
        const: 'false'
    Allow:
      description: Methods available for the requested path, including OPTIONS.
      schema:
        type: string
    Retry-After:
      description: >-
        Seconds to wait. 2 on async submission and unfinished polls, 1 on a 429,
        and 30 on HTTP 503 no_provider.
      schema:
        type: integer
  responses:
    BadRequest:
      description: >-
        A field failed validation (invalid_value, model_not_found or
        unsupported_value), the body could not be read (null), a content check
        failed (content_policy_violation), or the job input was malformed
        (invalid_input).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: Choose a temperature from 0 to 2.
              type: invalid_request_error
              param: temperature
              code: invalid_value
      headers:
        x-request-id:
          $ref: '#/components/headers/x-request-id'
        x-ratelimit-limit-concurrent:
          $ref: '#/components/headers/x-ratelimit-limit-concurrent'
        x-ratelimit-remaining-concurrent:
          $ref: '#/components/headers/x-ratelimit-remaining-concurrent'
        X-ShareMyAI-Cost-Credits:
          $ref: '#/components/headers/X-ShareMyAI-Cost-Credits'
        X-ShareMyAI-Balance-Credits:
          $ref: '#/components/headers/X-ShareMyAI-Balance-Credits'
        X-ShareMyAI-Max-Tokens:
          $ref: '#/components/headers/X-ShareMyAI-Max-Tokens'
        x-should-retry:
          $ref: '#/components/headers/x-should-retry'
    Unauthorized:
      description: >-
        The message distinguishes a missing token, a key without the smai_
        prefix and an unknown or revoked ShareMyAI token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: >-
                Send your API token as Authorization: Bearer smai_…. Create one
                at https://sharemy.ai, account panel, API tokens.
              type: invalid_request_error
              param: null
              code: invalid_api_key
      headers:
        x-request-id:
          $ref: '#/components/headers/x-request-id'
        x-ratelimit-limit-concurrent:
          $ref: '#/components/headers/x-ratelimit-limit-concurrent'
        x-ratelimit-remaining-concurrent:
          $ref: '#/components/headers/x-ratelimit-remaining-concurrent'
    InsufficientCredits:
      description: The balance is less than the job's price.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: >-
                This costs 8.192 credits and your balance is 3.000 credits. Add
                credits at https://sharemy.ai.
              type: insufficient_quota
              param: null
              code: insufficient_quota
              price_credits: 8.192
              balance_credits: 3
      headers:
        x-request-id:
          $ref: '#/components/headers/x-request-id'
        x-ratelimit-limit-concurrent:
          $ref: '#/components/headers/x-ratelimit-limit-concurrent'
        x-ratelimit-remaining-concurrent:
          $ref: '#/components/headers/x-ratelimit-remaining-concurrent'
        X-ShareMyAI-Max-Tokens:
          $ref: '#/components/headers/X-ShareMyAI-Max-Tokens'
        x-should-retry:
          $ref: '#/components/headers/x-should-retry'
    Suspended:
      description: The account is suspended.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: >-
                This account is suspended. If you think that is a mistake,
                contact us.
              type: invalid_request_error
              param: null
              code: account_suspended
      headers:
        x-request-id:
          $ref: '#/components/headers/x-request-id'
        x-ratelimit-limit-concurrent:
          $ref: '#/components/headers/x-ratelimit-limit-concurrent'
        x-ratelimit-remaining-concurrent:
          $ref: '#/components/headers/x-ratelimit-remaining-concurrent'
        X-ShareMyAI-Cost-Credits:
          $ref: '#/components/headers/X-ShareMyAI-Cost-Credits'
        X-ShareMyAI-Balance-Credits:
          $ref: '#/components/headers/X-ShareMyAI-Balance-Credits'
        X-ShareMyAI-Max-Tokens:
          $ref: '#/components/headers/X-ShareMyAI-Max-Tokens'
    MethodNotAllowed:
      description: The path exists. Use a method listed in Allow (method_not_allowed).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      headers:
        x-request-id:
          $ref: '#/components/headers/x-request-id'
        x-ratelimit-limit-concurrent:
          $ref: '#/components/headers/x-ratelimit-limit-concurrent'
        x-ratelimit-remaining-concurrent:
          $ref: '#/components/headers/x-ratelimit-remaining-concurrent'
        Allow:
          $ref: '#/components/headers/Allow'
    TooManyCalls:
      description: >-
        Four job calls are already in flight across the account's tokens, or
        eligible machines stayed busy for 10 minutes. Both return
        rate_limit_exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: At most 4 API calls at once. Wait for one to finish.
              type: invalid_request_error
              param: null
              code: rate_limit_exceeded
      headers:
        x-request-id:
          $ref: '#/components/headers/x-request-id'
        x-ratelimit-limit-concurrent:
          $ref: '#/components/headers/x-ratelimit-limit-concurrent'
        x-ratelimit-remaining-concurrent:
          $ref: '#/components/headers/x-ratelimit-remaining-concurrent'
        X-ShareMyAI-Cost-Credits:
          $ref: '#/components/headers/X-ShareMyAI-Cost-Credits'
        X-ShareMyAI-Balance-Credits:
          $ref: '#/components/headers/X-ShareMyAI-Balance-Credits'
        X-ShareMyAI-Max-Tokens:
          $ref: '#/components/headers/X-ShareMyAI-Max-Tokens'
        Retry-After:
          $ref: '#/components/headers/Retry-After'
    Cancelled:
      description: >-
        The caller hung up before the job finished. The job was dropped and its
        credits returned.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      headers:
        x-request-id:
          $ref: '#/components/headers/x-request-id'
        x-ratelimit-limit-concurrent:
          $ref: '#/components/headers/x-ratelimit-limit-concurrent'
        x-ratelimit-remaining-concurrent:
          $ref: '#/components/headers/x-ratelimit-remaining-concurrent'
        X-ShareMyAI-Cost-Credits:
          $ref: '#/components/headers/X-ShareMyAI-Cost-Credits'
        X-ShareMyAI-Balance-Credits:
          $ref: '#/components/headers/X-ShareMyAI-Balance-Credits'
        X-ShareMyAI-Max-Tokens:
          $ref: '#/components/headers/X-ShareMyAI-Max-Tokens'
    NetworkError:
      description: >-
        The job failed on the network, for example after three machines in turn
        left or stopped answering. Its credits were returned.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: >-
                The machine running this left the network. (request
                69ba81e5-6a67-4cd5-a28b-2e023337b936)
              type: api_error
              param: null
              code: network_error
      headers:
        x-request-id:
          $ref: '#/components/headers/x-request-id'
        x-ratelimit-limit-concurrent:
          $ref: '#/components/headers/x-ratelimit-limit-concurrent'
        x-ratelimit-remaining-concurrent:
          $ref: '#/components/headers/x-ratelimit-remaining-concurrent'
        X-ShareMyAI-Cost-Credits:
          $ref: '#/components/headers/X-ShareMyAI-Cost-Credits'
        X-ShareMyAI-Balance-Credits:
          $ref: '#/components/headers/X-ShareMyAI-Balance-Credits'
        X-ShareMyAI-Max-Tokens:
          $ref: '#/components/headers/X-ShareMyAI-Max-Tokens'
    NoProvider:
      description: >-
        No machine offers the model at submission, or an accepted job has had no
        eligible machine for about a minute.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              message: >-
                No machine that runs this model is online right now. (request
                69ba81e5-6a67-4cd5-a28b-2e023337b936)
              type: api_error
              param: null
              code: no_provider
      headers:
        x-request-id:
          $ref: '#/components/headers/x-request-id'
        x-ratelimit-limit-concurrent:
          $ref: '#/components/headers/x-ratelimit-limit-concurrent'
        x-ratelimit-remaining-concurrent:
          $ref: '#/components/headers/x-ratelimit-remaining-concurrent'
        X-ShareMyAI-Cost-Credits:
          $ref: '#/components/headers/X-ShareMyAI-Cost-Credits'
        X-ShareMyAI-Balance-Credits:
          $ref: '#/components/headers/X-ShareMyAI-Balance-Credits'
        X-ShareMyAI-Max-Tokens:
          $ref: '#/components/headers/X-ShareMyAI-Max-Tokens'
        x-should-retry:
          $ref: '#/components/headers/x-should-retry'
        Retry-After:
          $ref: '#/components/headers/Retry-After'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        An API token from the account panel on sharemy.ai. Tokens start with
        `smai_`.

````

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