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

# Stream speech sentence-by-sentence

> Same request body as `POST /v1/tts`, but the response is delivered as each sentence finishes synthesizing — lower time-to-first-audio on long text. Auth and metering are identical to `/v1/tts`.

The body is a sequence of **frames**: a 4-byte big-endian length, followed by that many bytes of one complete WAV. Read a length, read that many bytes (one playable WAV chunk), repeat until the stream closes. The `X-Tokay-Stream: wav-frames-v1` header identifies the framing. Most callers should use the SDK's `geko.tts.stream()`, which wraps this as an async iterable — see the [streaming guide](/guides/streaming).



## OpenAPI

````yaml /openapi.json post /v1/tts/stream
openapi: 3.0.3
info:
  title: geko API
  version: 1.0.0
  description: >-
    Text-to-speech for Kazakh and beyond. Send text and a voice name; get back
    WAV audio (24 kHz, 16-bit PCM, mono). A thin, familiar HTTP API — call it
    from any language, or use the typed SDK and CLI.


    The catalog endpoints (`/v1/models`, `/v1/voices`, `/health`) are open.
    Synthesis endpoints require a bearer key — create one in the
    [console](https://app.geko.sh).
servers:
  - url: https://geko--tokay-serve-web.modal.run
security:
  - bearerAuth: []
paths:
  /v1/tts/stream:
    post:
      tags:
        - Speech
      summary: Stream speech sentence-by-sentence
      description: >-
        Same request body as `POST /v1/tts`, but the response is delivered as
        each sentence finishes synthesizing — lower time-to-first-audio on long
        text. Auth and metering are identical to `/v1/tts`.


        The body is a sequence of **frames**: a 4-byte big-endian length,
        followed by that many bytes of one complete WAV. Read a length, read
        that many bytes (one playable WAV chunk), repeat until the stream
        closes. The `X-Tokay-Stream: wav-frames-v1` header identifies the
        framing. Most callers should use the SDK's `geko.tts.stream()`, which
        wraps this as an async iterable — see the [streaming
        guide](/guides/streaming).
      operationId: streamSpeech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TtsRequest'
      responses:
        '200':
          description: A stream of length-prefixed WAV frames (`wav-frames-v1`).
          headers:
            X-Tokay-Stream:
              description: Framing identifier. Always `wav-frames-v1`.
              schema:
                type: string
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/OutOfCredits'
        '503':
          $ref: '#/components/responses/Unavailable'
      x-codeSamples:
        - lang: TypeScript
          label: SDK
          source: |-
            import { Geko } from "@gekoai/sdk";

            const geko = new Geko({ apiKey: process.env.GEKO_API_KEY });

            for await (const wav of geko.tts.stream({
              text: longText,
              voice: "Aigerim",
            })) {
              // each `wav` is a standalone, playable WAV chunk
              play(wav);
            }
components:
  schemas:
    TtsRequest:
      type: object
      required:
        - text
      properties:
        text:
          type: string
          description: Text to synthesize (up to ~5000 characters).
          example: Сәлеметсіз бе! Тапсырыс нөмірі 152, сомасы 5500 ₸.
        model:
          type: string
          default: tokay-kk-v1
          description: Model id.
        voice:
          type: string
          default: Aigerim
          description: >-
            Voice name from `GET /v1/voices`. Defaults to the model's default
            voice.
        speed:
          type: number
          default: 1
          minimum: 0.5
          maximum: 2
          description: Speed multiplier.
        nfe:
          type: integer
          default: 32
          description: 'Diffusion steps: 16 fast, 32 quality.'
        normalize:
          type: boolean
          default: true
          description: Expand numbers, currency, and dates into spoken Kazakh.
    Error:
      type: object
      properties:
        detail:
          type: string
          description: Human-readable error message.
  responses:
    BadRequest:
      description: Bad request — missing `text`, malformed body, or an invalid value.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            detail: text is required
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            detail: invalid API key
    NotFound:
      description: Unknown model or voice.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            detail: unknown voice
    OutOfCredits:
      description: Out of credits — top up in the console. Not retried by the SDK.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            detail: out of credits — top up in the geko console
    Unavailable:
      description: Auth backend temporarily unavailable (transient — retry).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            detail: service temporarily unavailable
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your geko API key (`sk-tokay-…`). Create and manage keys in the
        [console](https://app.geko.sh).

````