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

# Speak text

> Text in, audio out. **Returns raw audio bytes, not the JSON envelope** — the one endpoint in the platform that does. `format` says what the text *is*, not what comes back: `markdown` is rendered into something worth hearing before synthesis, `plain` is spoken as given.




## OpenAPI

````yaml /openapi.yaml post /v1/voice/speak
openapi: 3.1.0
info:
  title: Patchwork API
  version: 1.0.0
  description: >
    Public data-plane API. Two products today: Identify (bare account
    resolution) and Loom (threads, runs, and outcomes). Every response is a JSON
    envelope — `status: success` with `data`, or `status: error` with `error`.
  contact:
    url: https://usepatchwork.co
servers:
  - url: https://api.usepatchwork.co
security:
  - bearerAuth: []
tags:
  - name: Identify
    description: Resolve an account or wallet to the institution and rails behind it.
  - name: Extract
    description: >-
      Turn a document into structured data, and manage the schema types that
      shape it.
  - name: Loom
    description: Threads, messages, runs, and outcomes for an embedded agent.
  - name: Files
    description: Upload bytes once, get a durable handle, reference it from any product.
  - name: Voice
    description: Transcribe an utterance, speak a reply, list the available voices.
  - name: MCP
    description: >-
      The grants your users hold when they reach an agent from their own AI
      client.
paths:
  /v1/voice/speak:
    post:
      tags:
        - Voice
      summary: Speak text
      description: >
        Text in, audio out. **Returns raw audio bytes, not the JSON envelope** —
        the one endpoint in the platform that does. `format` says what the text
        *is*, not what comes back: `markdown` is rendered into something worth
        hearing before synthesis, `plain` is spoken as given.
      operationId: speakVoice
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
        - $ref: '#/components/parameters/PatchworkSubject'
        - $ref: '#/components/parameters/PatchworkConnection'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - text
              properties:
                text:
                  type: string
                  description: What to say.
                format:
                  type: string
                  enum:
                    - markdown
                    - plain
                  default: markdown
                  description: What the text is. Anything else is `voice_invalid_format`.
                voice_id:
                  type: string
                  description: >-
                    A voice from `/v1/voice/voices`. The platform default
                    applies when omitted.
                language:
                  type: string
                  description: Optional language hint.
      responses:
        '200':
          description: Audio bytes. `Content-Type` is whatever the provider produced.
          headers:
            Patchwork-Voice-Cache:
              description: >-
                Whether the clip came from cache, so repeated playback costs
                nothing.
              schema:
                type: string
                enum:
                  - hit
                  - miss
          content:
            audio/mpeg:
              schema:
                type: string
                format: binary
        '401':
          description: Missing or invalid credentials.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: >-
            `voice_invalid_format` if `format` is not `markdown` or `plain`;
            `voice_empty_text` if nothing is left to speak after rendering.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: >-
            `voice_provider_error` — the provider failed. Retrying is
            reasonable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: '`voice_unavailable` — no voice provider configured.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: >
        Makes this POST safe to retry. The first call does the work and its
        response is stored; a retry with the same key returns that stored
        response with `Idempotency-Replayed: true`, without charging again. Same
        key with a different body is rejected. Keys expire after 24 hours.
      schema:
        type: string
        maxLength: 255
    PatchworkSubject:
      name: Patchwork-Subject
      in: header
      required: false
      description: >
        Relay only. Opaque subject id, chosen by you and never resolved by
        Patchwork. Partitions threads and memory within your workspace. Direct
        tokens carry `sub` instead — do not send this header on a session token.

        **Required** on every subject-scoped resource: threads, messages, runs,
        outcomes, confirmations and realtime. Omitting it is `subject_required`,
        never a wider result. The value is used exactly as given — never trimmed
        or normalised — so a stray space creates a second partition and is
        refused as `invalid_subject`.
      schema:
        type: string
    PatchworkConnection:
      name: Patchwork-Connection
      in: header
      required: false
      description: >
        Connection id or name the agent may call. Required in relay when the
        agent has unpinned customer tools. Direct tokens may carry `conn`
        instead.
      schema:
        type: string
  schemas:
    Error:
      type: object
      required:
        - status
        - error
      properties:
        status:
          type: string
          const: error
        error:
          type: object
          required:
            - message
            - code
          properties:
            message:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: Stable machine-readable code.
            details:
              description: Optional extra context.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        Identify accepts a workspace API key (`sk_…`). Loom accepts either a
        short-lived session token (direct) or a workspace API key (relay).

````

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