# Captions ## List captions or subtitles `stream.captions.get(stridentifier, CaptionGetParams**kwargs) -> SyncSinglePage[Caption]` **get** `/accounts/{account_id}/stream/{identifier}/captions` Lists the available captions or subtitles for a specific video. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. ### Returns - `class Caption: …` - `generated: Optional[bool]` Whether the caption was generated via AI. - `label: Optional[str]` The language label displayed in the native language to users. - `language: Optional[str]` The language tag in BCP 47 format. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated caption. - `"ready"` - `"inprogress"` - `"error"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.stream.captions.get( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.generated) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "generated": true, "label": "Türkçe", "language": "tr", "status": "ready" } ] } ``` ## Domain Types ### Caption - `class Caption: …` - `generated: Optional[bool]` Whether the caption was generated via AI. - `label: Optional[str]` The language label displayed in the native language to users. - `language: Optional[str]` The language tag in BCP 47 format. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated caption. - `"ready"` - `"inprogress"` - `"error"` # Language ## List captions or subtitles for a provided language `stream.captions.language.get(strlanguage, LanguageGetParams**kwargs) -> Caption` **get** `/accounts/{account_id}/stream/{identifier}/captions/{language}` Lists the captions or subtitles for provided language. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `language: str` The language tag in BCP 47 format. ### Returns - `class Caption: …` - `generated: Optional[bool]` Whether the caption was generated via AI. - `label: Optional[str]` The language label displayed in the native language to users. - `language: Optional[str]` The language tag in BCP 47 format. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated caption. - `"ready"` - `"inprogress"` - `"error"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) caption = client.stream.captions.language.get( language="tr", account_id="023e105f4ecef8ad9ca31a8372d0c353", identifier="ea95132c15732412d22c1476fa83f27a", ) print(caption.generated) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "generated": true, "label": "Türkçe", "language": "tr", "status": "ready" } } ``` ## Generate captions or subtitles for a provided language via AI `stream.captions.language.create(strlanguage, LanguageCreateParams**kwargs) -> Caption` **post** `/accounts/{account_id}/stream/{identifier}/captions/{language}/generate` Generate captions or subtitles for provided language via AI. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `language: str` The language tag in BCP 47 format. ### Returns - `class Caption: …` - `generated: Optional[bool]` Whether the caption was generated via AI. - `label: Optional[str]` The language label displayed in the native language to users. - `language: Optional[str]` The language tag in BCP 47 format. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated caption. - `"ready"` - `"inprogress"` - `"error"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) caption = client.stream.captions.language.create( language="tr", account_id="023e105f4ecef8ad9ca31a8372d0c353", identifier="ea95132c15732412d22c1476fa83f27a", ) print(caption.generated) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "generated": true, "label": "Türkçe", "language": "tr", "status": "ready" } } ``` ## Upload captions or subtitles `stream.captions.language.update(strlanguage, LanguageUpdateParams**kwargs) -> Caption` **put** `/accounts/{account_id}/stream/{identifier}/captions/{language}` Uploads the caption or subtitle file to the endpoint for a specific BCP47 language. One caption or subtitle file per language is allowed. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `language: str` The language tag in BCP 47 format. - `file: str` The WebVTT file containing the caption or subtitle content. ### Returns - `class Caption: …` - `generated: Optional[bool]` Whether the caption was generated via AI. - `label: Optional[str]` The language label displayed in the native language to users. - `language: Optional[str]` The language tag in BCP 47 format. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated caption. - `"ready"` - `"inprogress"` - `"error"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) caption = client.stream.captions.language.update( language="tr", account_id="023e105f4ecef8ad9ca31a8372d0c353", identifier="ea95132c15732412d22c1476fa83f27a", file="@/Users/kyle/Desktop/tr.vtt", ) print(caption.generated) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "generated": true, "label": "Türkçe", "language": "tr", "status": "ready" } } ``` ## Delete captions or subtitles `stream.captions.language.delete(strlanguage, LanguageDeleteParams**kwargs) -> LanguageDeleteResponse` **delete** `/accounts/{account_id}/stream/{identifier}/captions/{language}` Removes the captions or subtitles from a video. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `language: str` The language tag in BCP 47 format. ### Returns - `str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) language = client.stream.captions.language.delete( language="tr", account_id="023e105f4ecef8ad9ca31a8372d0c353", identifier="ea95132c15732412d22c1476fa83f27a", ) print(language) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": "" } ``` ## Domain Types ### Language Delete Response - `str` # Vtt ## Return WebVTT captions for a provided language `stream.captions.language.vtt.get(strlanguage, VttGetParams**kwargs) -> VttGetResponse` **get** `/accounts/{account_id}/stream/{identifier}/captions/{language}/vtt` Return WebVTT captions for a provided language. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `language: str` The language tag in BCP 47 format. ### Returns - `str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) vtt = client.stream.captions.language.vtt.get( language="tr", account_id="023e105f4ecef8ad9ca31a8372d0c353", identifier="ea95132c15732412d22c1476fa83f27a", ) print(vtt) ``` ## Domain Types ### Vtt Get Response - `str`