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

# Generate Audio

> Generate speech, music, or a sound effect from text (metered).

Pick `mode` first: `text_to_speech` (a voice saying your exact words —
`prompt` IS the script), `text_to_music`, or `text_to_sfx`. The model card on
`GET /v1/media/models` says which modes each model serves.

Synchronous: the render runs inside this call and there is no `wait: false`
task lane. Speech returns in seconds. Music and sound effects can be asked
for at up to 600 seconds of output and may take correspondingly longer; a
render that outruns this call's wait is asked to cancel and reported as a
retryable 503. Repeat that call with the same `idempotency_key`: it adopts
the existing provider job, so it returns the audio if the render finished
anyway and reports it cancelled if it did not — and it can never pay for a
second render. Only once it reports cancelled is a new request worth making
— and that one needs a NEW `idempotency_key` as well as a shorter duration or
fewer samples, since a changed payload under the old key is a 409
`idempotency_conflict`.

`results` carries one entry per delivered take (`num_samples`), `applied`
reports the knobs that actually ran, and `adjustments` names every field
that differed from the ask, with a reason — read them before describing the
output to a user.



## OpenAPI

````yaml /openapi/moda-public-api.yaml post /media/generate-audio
openapi: 3.1.0
info:
  title: Moda Public API
  description: >
    Programmatic access to Moda's canvas design platform. Create designs, export
    assets, manage brand kits, and run AI design tasks.


    ## Versioning


    Pin response shapes with a calendar-dated `Moda-Version` header (e.g.
    `2026-05-01`). **The pin is global** — it applies to every endpoint in the
    request, not just the one you adopted it for, so raising it to use a new
    endpoint also moves your other responses to that version's shapes.


    ### Migrating `2026-04-12` → `2026-05-01`


    - **Tasks** move from the flat `JobResponse` (`job_id`, `canvas_url`,
    `can_export`) to the canonical `Task` envelope. The export artifact is now
    under `result.export` as `{url, format, page_count}`; update any code that
    read the export URL from the old top-level fields.

    - **Multi-page PNG/JPEG exports are delivered as a single `.zip`** of
    per-page files (`page-1.png`, …), so `result.export.format` is `zip`. For
    one bundled document instead, request `format=pdf` or `pptx`; for a single
    image, pass `page_number`.
  version: 1.0.0
  x-moda-api-version: '2026-05-01'
servers:
  - url: https://api.moda.app/v1
    description: Production
security: []
tags:
  - name: canvases
    description: List, search, read, export, and share canvases
  - name: tasks
    description: Start and monitor AI design tasks
  - name: organizations
    description: List organizations and teams
  - name: credits
    description: Check credit balance and usage
  - name: brand-kits
    description: Manage brand kits
  - name: remix
    description: Duplicate and edit canvases
  - name: share-links
    description: Resolve share URLs to canvas identifiers
  - name: uploads
    description: Upload files for use as attachments
  - name: usage
    description: Aggregate API usage stats for the caller's team
  - name: embed
    description: Signed iframe embed sessions
  - name: web
    description: 'Metered web research: search and page reading'
  - name: websites
    description: >-
      Create, update, publish, screenshot, and manage hosted multi-page static
      sites
  - name: drive
    description: >-
      Organize the workspace: folders, the folder tree, and item
      move/rename/visibility/delete for folders, canvases, and files
paths:
  /media/generate-audio:
    post:
      tags:
        - media
      summary: Generate Audio
      description: >-
        Generate speech, music, or a sound effect from text (metered).


        Pick `mode` first: `text_to_speech` (a voice saying your exact words —

        `prompt` IS the script), `text_to_music`, or `text_to_sfx`. The model
        card on

        `GET /v1/media/models` says which modes each model serves.


        Synchronous: the render runs inside this call and there is no `wait:
        false`

        task lane. Speech returns in seconds. Music and sound effects can be
        asked

        for at up to 600 seconds of output and may take correspondingly longer;
        a

        render that outruns this call's wait is asked to cancel and reported as
        a

        retryable 503. Repeat that call with the same `idempotency_key`: it
        adopts

        the existing provider job, so it returns the audio if the render
        finished

        anyway and reports it cancelled if it did not — and it can never pay for
        a

        second render. Only once it reports cancelled is a new request worth
        making

        — and that one needs a NEW `idempotency_key` as well as a shorter
        duration or

        fewer samples, since a changed payload under the old key is a 409

        `idempotency_conflict`.


        `results` carries one entry per delivered take (`num_samples`),
        `applied`

        reports the knobs that actually ran, and `adjustments` names every field

        that differed from the ask, with a reason — read them before describing
        the

        output to a user.
      operationId: mediaGenerateAudio
      parameters:
        - $ref: '#/components/parameters/ModaVersion'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateAudioRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                additionalProperties: true
                type: object
                title: Response Mediagenerateaudio
        '401':
          description: Authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '402':
          description: Insufficient credits for a metered operation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '403':
          description: Permission denied for this scope.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '404':
          description: Resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '409':
          description: Conflict (idempotency / resource state).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '422':
          description: Request validation failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '500':
          description: Internal error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
      security:
        - API Key: []
components:
  parameters:
    ModaVersion:
      name: Moda-Version
      in: header
      required: false
      description: >-
        Calendar-dated API version pin. New integrations should pin `2026-05-01`
        to opt into the newest response shapes. For back-compat the server also
        accepts requests with no header and resolves them to the current default
        (today: `2026-04-12`); that default advances on each [sunset
        date](/api-reference/versioning). Any unsupported value returns 400
        `unsupported_version`.
      example: '2026-05-01'
      schema:
        type: string
        enum:
          - '2026-04-12'
          - '2026-05-01'
        default: '2026-05-01'
        example: '2026-05-01'
  schemas:
    GenerateAudioRequest:
      properties:
        prompt:
          type: string
          minLength: 1
          title: Prompt
          description: >-
            Sent to the selected model VERBATIM. For text_to_speech this IS the
            script — the words that get spoken, with no stage directions. For
            the other modes it describes the result: genre, instrumentation,
            mood, tempo, texture.
        model:
          type: string
          title: Model
          description: Concrete audio model id; see GET /v1/media/models.
        mode:
          type: string
          title: Mode
          description: >-
            text_to_speech, text_to_music, or text_to_sfx. Stated rather than
            derived — every mode takes exactly text, so there is no input role
            to derive it from. The model card on GET /v1/media/models says which
            modes each model serves.
        voice:
          anyOf:
            - type: string
            - type: 'null'
          title: Voice
          description: >-
            Speech only. Normally a preset name from the mode's voices on GET
            /v1/media/models; on a mode whose card sets voice_is_free_form,
            voices is empty and this takes any provider voice name or
            cloned-voice id instead, checked for shape here and resolved by the
            provider. Omit for the mode's default.
        duration_seconds:
          anyOf:
            - type: number
            - type: string
            - type: 'null'
          title: Duration Seconds
          description: >-
            Music and sound effects only, and it SNAPS into the mode's envelope
            with the adjustment reported. Speech has no duration control — a
            value passed there is dropped and reported rather than rejected.
        num_samples:
          anyOf:
            - type: integer
            - type: 'null'
          title: Num Samples
          description: >-
            Distinct takes to render, where the mode has a sample axis
            (max_samples on GET /v1/media/models). EVERY sample is billed, and a
            mode with a billing floor bills each short take at the floor.
        model_params:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Model Params
        idempotency_key:
          anyOf:
            - type: string
              maxLength: 200
            - type: 'null'
          title: Idempotency Key
          description: >-
            Keys the provider-job checkpoint: a retried call with the same key
            resumes the existing render instead of paying for a duplicate.
      additionalProperties: false
      type: object
      required:
        - prompt
        - model
        - mode
      title: GenerateAudioRequest
    ErrorEnvelope:
      properties:
        type:
          $ref: '#/components/schemas/ErrorType'
        code:
          type: string
          title: Code
          description: >-
            Stable machine string keyed to doc_url. Never changes once
            published.
        message:
          type: string
          title: Message
          description: >-
            Human-readable message, for developers. Not localized, not
            user-facing.
        doc_url:
          type: string
          title: Doc Url
          description: Permalink to the docs page for this code.
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Request Id
          description: Correlator for logs/Sentry/audit.
        causes:
          anyOf:
            - items:
                $ref: '#/components/schemas/ErrorEnvelope'
              type: array
            - type: 'null'
          title: Causes
          description: Aggregated upstream failures (e.g. per-page export errors).
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: >-
            Code-specific detail payload (e.g. validation field list). Callers
            should pass ``None`` rather than ``{}`` to omit the key from the
            response.
        retry_after_ms:
          anyOf:
            - type: integer
            - type: 'null'
          title: Retry After Ms
          description: Hint for rate-limited or transient errors.
        retryable:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Retryable
          description: >-
            Explicit retryability for this code, from the error-code registry:
            ``false`` means retrying the same request cannot succeed (fix the
            input / resource first); ``true`` means the condition is transient
            and a retry (with backoff / after the blocker clears) can succeed.
            Omitted for codes whose retryability is context-dependent — do not
            derive it from ``type`` or the HTTP status when this field is
            present.
      type: object
      required:
        - type
        - code
        - message
        - doc_url
      title: ErrorEnvelope
      description: >-
        Canonical error payload, nested under the top-level ``{"error": ...}``
        key.
    ErrorType:
      type: string
      enum:
        - invalid_request
        - authentication
        - permission
        - not_found
        - conflict
        - rate_limited
        - idempotency_conflict
        - unprocessable
        - upstream_error
        - internal_error
      title: ErrorType
      description: Closed set of high-level categories SDKs branch on.
  securitySchemes:
    API Key:
      type: http
      description: API key from Settings > Developer > REST API
      scheme: bearer

````