Implementation:Elevenlabs Elevenlabs python CaptionStyleModel
| Metadata | Value |
|---|---|
| source | Elevenlabs_Elevenlabs_python |
| domain | Captions, Video Styling |
| last_updated | 2026-02-15 |
Overview
Description: CaptionStyleModel is a Pydantic model that defines the visual styling and animation properties for captions in ElevenLabs video or audio content. It provides granular control over text appearance (font, color, scale, alignment, weight, style), background styling (color, opacity), word highlighting, animation effects (section-level, word-level, and character-level), and layout parameters (width, placement, line-breaking rules).
Usage: This model is used when configuring caption styling for video or audio content that includes captions. It allows developers to customize every aspect of how captions appear on screen, from basic typography to advanced animation effects and positioning.
Code Reference
Source file: src/elevenlabs/types/caption_style_model.py
Class signature:
class CaptionStyleModel(UncheckedBaseModel):
...
Import statement:
from elevenlabs.types import CaptionStyleModel
I/O Contract
| Field | Type | Required | Description |
|---|---|---|---|
| template | Optional[CaptionStyleTemplateModel] | No | Predefined caption style template |
| text_font | Optional[str] | No | Font family for caption text |
| text_scale | Optional[float] | No | Scale factor for caption text size |
| text_color | Optional[str] | No | Color of the caption text |
| text_align | Optional[CaptionStyleModelTextAlign] | No | Text alignment for captions |
| text_style | Optional[CaptionStyleModelTextStyle] | No | Text style (e.g., italic) |
| text_weight | Optional[CaptionStyleModelTextWeight] | No | Font weight for caption text |
| background_enabled | Optional[bool] | No | Whether background is enabled behind captions |
| background_color | Optional[str] | No | Background color behind captions |
| background_opacity | Optional[float] | No | Opacity of the caption background |
| word_highlights_enabled | Optional[bool] | No | Whether word highlighting is enabled |
| word_highlights_color | Optional[str] | No | Color of highlighted words |
| word_highlights_background_color | Optional[str] | No | Background color of highlighted words |
| word_highlights_opacity | Optional[float] | No | Opacity of word highlights |
| section_animation | Optional[CaptionStyleSectionAnimationModel] | No | Animation for caption section transitions |
| word_animation | Optional[CaptionStyleWordAnimationModel] | No | Animation for individual word appearance |
| character_animation | Optional[CaptionStyleCharacterAnimationModel] | No | Animation for individual character appearance |
| width_pct | Optional[float] | No | Width of captions as a percentage of the screen |
| horizontal_placement | Optional[CaptionStyleHorizontalPlacementModel] | No | Horizontal placement of captions on screen |
| vertical_placement | Optional[CaptionStyleVerticalPlacementModel] | No | Vertical placement of captions on screen |
| auto_break_enabled | Optional[bool] | No | Whether automatic line breaking is enabled |
| max_lines_per_section | Optional[int] | No | Maximum number of lines per caption section |
| max_words_per_line | Optional[int] | No | Maximum number of words per caption line |
Usage Examples
from elevenlabs.types import CaptionStyleModel
# Create a custom caption style
caption_style = CaptionStyleModel(
text_font="Arial",
text_scale=1.2,
text_color="#FFFFFF",
background_enabled=True,
background_color="#000000",
background_opacity=0.7,
word_highlights_enabled=True,
word_highlights_color="#FFD700",
width_pct=0.8,
auto_break_enabled=True,
max_lines_per_section=2,
max_words_per_line=6,
)
# Check caption properties
if caption_style.word_highlights_enabled:
print(f"Word highlights color: {caption_style.word_highlights_color}")