---
agentTools:
  projectIndex: https://elai.readme.io/llms.txt
---

# Generate speech for slides

Writes speech for the named slides from their on-canvas content, following `enhancement` as instructions. Use this for slides that have no speech yet; use rewrite-speech to change speech that already exists.

Replaces the retired `POST /gpt/{videoId}` and `POST /gpt/{videoId}/{slideId}`.

Writes speech for the named slides from their on-canvas content, following `enhancement` as
instructions. Use this for slides that have no speech yet — to change speech that already exists,
use [Rewrite speech for slides](https://elai.readme.io/reference/llm-rewrite-speech).

Replaces the retired `POST /gpt/{videoId}` and `POST /gpt/{videoId}/{slideId}`.

> 👍 `enhancement` is instruction text, not an enum
>
> The old endpoints took one of ten fixed values. Write the change you want in plain language:
>
> ```json
> { "slideIds": [1, 2, 3], "enhancement": "Warm, conversational, about 20 seconds per slide." }
> ```
>
> `enhancementPresets` is optional and recorded for analytics only — it does not affect the output.
> `enhancement` carries the actual instruction.

`slideIds` replaces the old per-slide URL: pass one id to act on one slide, or every id to cover
the whole video. Any id that isn't on the video returns **404** naming the missing ids.

Leave `fromEditor` unset. When false (the default) the generated speech is persisted server-side,
which is what an API caller wants; the editor sets it true because it owns persistence itself.

Requires LLM access on the account — **409** if unavailable.

# OpenAPI definition

````json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Elai Public API",
    "version": "1.0",
    "description": "Every endpoint below is served under `https://apis.elai.io/api/v1`.\n\n## Authentication\n\nSend your workspace API token as a bearer token on every request:\n\n```\nAuthorization: Bearer <your-api-token>\n```\n\nGenerate and rotate the token in the Elai web app under **Settings → API**, or through\n`POST /generateToken`. The token is scoped to one **workspace** and authenticates as that\nworkspace's admin user — it is not tied to an individual person, and it carries admin rights\ninside that workspace.\n\nA request with a missing, unknown or revoked token gets a bare `401` with no response body.\n\n> **Organizations on the Unlimited plan cannot use the API.** Their requests are rejected with the\n> same bare `401` as an invalid token, with nothing to distinguish the two. If a valid, freshly\n> generated token returns `401` on every endpoint, check the plan first.\n\n## Errors\n\nFailures carry a JSON body of the shape `{ \"message\": \"...\" }`. Validation failures on the newer\nendpoints may add an `errors` array naming the offending fields. `401` is the exception: it has no\nbody at all.\n\nBoth render endpoints are **fire-and-forget** — they queue work and return immediately, so a\n`200` means \"accepted\", not \"rendered\". Render failures surface only through the `video_error`\nwebhook, never as an HTTP error on the call that started the render.\n\n## Scope\n\nThis reference is generated from the running code rather than maintained by hand, so it cannot\nquietly fall behind the API it describes. It documents 96 operations across the\n`/api/v1` surface.\n\nEndpoints are grouped by subject in the sidebar. If something you need is missing, or an endpoint\ndoes not behave as described here, tell us.\n\n---\n\n_Generated from `chore/web-4760/api-v1-reference-build` at `5289745d` on 2026-09-04._"
  },
  "servers": [
    {
      "url": "https://apis.elai.io/api/v1"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "x-bearer-format": "bearer",
        "x-default": "SECRET_KEY"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Human-readable explanation of the failure."
          }
        }
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/llm/{videoId}/generate-speech": {
      "post": {
        "operationId": "llm-generate-speech",
        "summary": "Generate speech for slides",
        "description": "Writes speech for the named slides from their on-canvas content, following `enhancement` as instructions. Use this for slides that have no speech yet; use rewrite-speech to change speech that already exists.\n\nReplaces the retired `POST /gpt/{videoId}` and `POST /gpt/{videoId}/{slideId}`.",
        "parameters": [
          {
            "name": "videoId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Id of the video to modify."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "slideIds",
                  "enhancement"
                ],
                "properties": {
                  "slideIds": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "integer"
                    },
                    "description": "Ids of the slides to act on. Pass every slide id to cover the whole video."
                  },
                  "enhancement": {
                    "type": "string",
                    "description": "Free-form instruction text, e.g. \"Make this warmer and about 20% shorter.\" This is NOT an enum — the ten fixed values the retired /gpt endpoints accepted no longer exist."
                  },
                  "config": {
                    "type": "object",
                    "description": "Optional generation tuning. `count` is coerced to a number.",
                    "additionalProperties": true
                  },
                  "enhancementPresets": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Optional. The preset keys a UI offered (shorter / formal / custom-prompt). Recorded for analytics only; `enhancement` carries the actual instruction."
                  },
                  "fromEditor": {
                    "type": "boolean",
                    "default": false,
                    "description": "Leave false for API use. When true the caller owns persistence; when false the speech is saved server-side."
                  },
                  "generateSource": {
                    "type": "string",
                    "description": "Optional hint about what the speech should be derived from."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated video, the affected slides, and feedback context ids.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "video": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "slides": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "feedbackContexts": {
                      "type": "object",
                      "properties": {
                        "feedbackContextId": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "slideSpeechById": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`enhancement` is not a string, or `slideIds` is missing or empty.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "slideIds must be a non-empty array for rewrite operation"
                }
              }
            }
          },
          "404": {
            "description": "One or more slide ids do not exist on the video.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "Slides not found: 123, 456"
                }
              }
            }
          },
          "409": {
            "description": "LLM unavailable for this account — `llmDisabled` is set, or a non-paid organization has used its 5000-token allowance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "You have used all your tokens. Please upgrade to use LLM enhancements without limitations."
                }
              }
            }
          },
          "500": {
            "description": "The LLM call failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "message": "LLM service is temporarily unavailable. Please try again."
                }
              }
            }
          }
        },
        "tags": [
          "LLM"
        ]
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "tags": [
    {
      "name": "LLM",
      "description": "Generate and rewrite slide speech with an LLM."
    }
  ],
  "_id": {
    "buffer": {
      "0": 106,
      "1": 154,
      "2": 229,
      "3": 101,
      "4": 201,
      "5": 178,
      "6": 243,
      "7": 252,
      "8": 223,
      "9": 58,
      "10": 69,
      "11": 151
    }
  }
}
````