# Auto Subtitles — API Reference Model ID: `model_scenario-video-subtitles` --- ## Authentication - **API_KEY** and **API_SECRET** are found in your [Scenario Project Settings](https://app.scenario.com/team&tab=project_api_keys) under API Keys. - Set them as environment variables `SCENARIO_SDK_API_KEY` and `SCENARIO_SDK_API_SECRET` — both SDKs pick them up by default. - For raw HTTP (cURL), use Basic Auth: `Authorization: Basic base64(":")`. ### Install the SDK - JavaScript / TypeScript: `npm install @scenario-labs/sdk` - Python: `pip install scenario-sdk` --- ## Generate **Endpoint:** `POST https://api.cloud.scenario.com/v1/generate/custom/model_scenario-video-subtitles` ### Parameters | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | `video` | assetId | yes | - | Input video to add subtitles to. | | `initialPrompt` | string | - | - | [auto mode] Optional text prompt to bias the model's style/vocabulary. | | `fontColor` | string | - | `#FFFFFF` | Primary font color in #RRGGBB hex (e.g. '#FFFFFF' for white). | | `outlineColor` | string | - | `#000000` | Outline color in #RRGGBB hex. Default is black. | | `borderStyle` | string | - | `opaque-box` | How the border color is rendered around the text. 'Outline + Shadow': each glyph is stroked with border color and an optional drop shadow; the video behind the letters stays visible. 'Opaque Box': a filled rectangle (using border color, tinted by border color transparency) is drawn behind the text, covering the video. Border color transparency mostly matters with 'Opaque Box' — with 'Outline + Shadow' you usually want a fully opaque stroke. | | `outlineColorTransparency` | number | - | `0.2` | Outline / box transparency: 0.0 = fully opaque, 1.0 = fully transparent. | | `modelSize` | string | - | `small` | [auto mode] Whisper model size used for transcription. | | `language` | string | - | `` | ISO 639-1 language code (e.g. 'en', 'fr'). Leave empty for auto-detection. | | `task` | string | - | `transcribe` | [auto mode] 'transcribe' keeps the original language, 'translate' targets English. | | `maxSegmentDuration` | number | - | - | Limits the maximum time (in seconds) a single subtitle appears. When splitting long segments, the system uses proportional timing and prioritizes punctuation boundaries (.,!?). Typical: 5–7s. Automatically defined if omitted. | | `maxSegmentChars` | number | - | `42` | Limits the number of characters per subtitle cue. Applied alongside duration limits; the segment will split whenever either threshold is reached. Automatically defined if omitted. | | `fontName` | string | - | `Arial` | Subtitle font family. | | `fontSize` | number | - | `14` | Subtitle font size in points. | | `compressionLevel` | number | - | `23` | Video compression quality (CRF, lower = higher quality). | ### Example Requests **cURL** ```bash curl -X POST "https://api.cloud.scenario.com/v1/generate/custom/model_scenario-video-subtitles" \ -H "Authorization: Basic $(echo -n ':' | base64)" \ -H "Content-Type: application/json" \ --data-binary @- <<'EOF' { "video": "", "fontColor": "#FFFFFF", "outlineColor": "#000000", "borderStyle": "opaque-box", "outlineColorTransparency": 0.2, "modelSize": "small", "language": "", "task": "transcribe", "maxSegmentChars": 42, "fontName": "Arial", "fontSize": 14, "compressionLevel": 23 } EOF ``` **Python** ```python import os from scenario_sdk import Scenario client = Scenario( api_key=os.environ.get("SCENARIO_SDK_API_KEY"), api_secret=os.environ.get("SCENARIO_SDK_API_SECRET"), ) body = { "video": "", "fontColor": "#FFFFFF", "outlineColor": "#000000", "borderStyle": "opaque-box", "outlineColorTransparency": 0.2, "modelSize": "small", "language": "", "task": "transcribe", "maxSegmentChars": 42, "fontName": "Arial", "fontSize": 14, "compressionLevel": 23 } response = client.generate.run_model( model_id="model_scenario-video-subtitles", body=body, ) print(response) ``` **JavaScript** ```javascript import Scenario from "@scenario-labs/sdk"; const client = new Scenario({ apiKey: process.env["SCENARIO_SDK_API_KEY"], apiSecret: process.env["SCENARIO_SDK_API_SECRET"], }); const body = { "video": "", "fontColor": "#FFFFFF", "outlineColor": "#000000", "borderStyle": "opaque-box", "outlineColorTransparency": 0.2, "modelSize": "small", "language": "", "task": "transcribe", "maxSegmentChars": 42, "fontName": "Arial", "fontSize": 14, "compressionLevel": 23 }; const response = await client.generate.runModel("model_scenario-video-subtitles", { body }); console.info(response); ``` --- ## Retrieve Results After submitting a generation request, you receive a `jobId`. Poll the job until `job.status` is `"success"`. The generated asset IDs are in `job.metadata.assetIds`. **Endpoint:** `GET https://api.cloud.scenario.com/v1/jobs/{jobId}` ### Example Requests **cURL** ```bash curl -X GET "https://api.cloud.scenario.com/v1/jobs/" \ -H "Authorization: Basic $(echo -n ':' | base64)" ``` **Python** ```python job = client.jobs.retrieve(job_id="") print(job.status) print(job.metadata.asset_ids) ``` **JavaScript** ```javascript // Option 1 — wait on the response from runModel using the SDK helper const completed = await response.job.wait(); console.info(completed.status); console.info(completed.metadata?.assetIds); // Option 2 — retrieve a job by its ID const job = await client.jobs.retrieve(""); console.info(job.status); console.info(job.metadata?.assetIds); ``` **Example response:** ```json { "job": { "jobId": "job_abc123", "status": "success", "metadata": { "assetIds": [ "asset_abc123" ] } } } ``` > **Important:** Generated asset URLs are **temporary** and expire after a short period. Download and store any images you wish to keep before the URL expires. More info: [Content Delivery Network (CDN)](https://docs.scenario.com/get-started/documentation/content-delivery-network-cdn). --- *Generated by [Scenario](https://app.scenario.com)*