Enrich content

Apply a domain-specific lens to get richer, more detailed analysis of your videos. Use instructions to shift the perspective - brand strategy, compliance, accessibility, SEO - and a schema to capture the enriched results.

Prerequisites

  • Complete the Quickstart to create a knowledge store with at least one item in ready status.
  • Read Create a response to understand the request and response format.

When to use this

  • Default extraction is not detailed enough for your use case
  • You need domain-specific metadata that was not captured at index time
  • You want to augment existing understanding with a new analytical lens

Enrich through a domain lens

Combine instructions to set the analytical perspective with a schema to capture the enriched output. This example analyzes videos through a brand strategy lens.

1import json
2import requests
3
4API_KEY = "YOUR_API_KEY"
5BASE_URL = "https://api.twelvelabs.io/v1.3"
6HEADERS = {"x-api-key": API_KEY, "Content-Type": "application/json"}
7STORE_ID = "your_knowledge_store_id"
8
9enrichment_schema = {
10 "type": "object",
11 "properties": {
12 "enrichments": {
13 "type": "array",
14 "items": {
15 "type": "object",
16 "properties": {
17 "video_reference": {"type": "string"},
18 "original_summary": {"type": "string"},
19 "enriched_analysis": {"type": "string"},
20 "new_insights": {"type": "array", "items": {"type": "string"}},
21 "tags": {"type": "array", "items": {"type": "string"}}
22 }
23 }
24 }
25 }
26}
27
28response = requests.post(
29 f"{BASE_URL}/responses",
30 headers=HEADERS,
31 json={
32 "model": "jockey1.0",
33 "instructions": "You are a brand strategist. Analyze videos through the lens of brand perception and marketing effectiveness.",
34 "input": [
35 {
36 "type": "message",
37 "role": "user",
38 "content": "For each video, provide enriched analysis focusing on brand messaging effectiveness, audience engagement signals, and production quality."
39 }
40 ],
41 "knowledge_store_id": STORE_ID,
42 "text": {"format": {"type": "json_schema", "name": "content_enrichment", "schema": enrichment_schema}}
43 }
44)
45
46result = response.json()
47for output in result["output"]:
48 if output["type"] == "message":
49 for content in output["content"]:
50 data = json.loads(content["text"])
51 for e in data["enrichments"]:
52 print(f"\n{e['video_reference']}")
53 print(f" Analysis: {e['enriched_analysis']}")
54 print(f" Insights: {', '.join(e['new_insights'])}")
55 print(f" Tags: {', '.join(e['tags'])}")

Example enrichment contexts

Swap the instructions to enrich for different purposes - the schema stays the same:

ContextInstructions
Accessibility”Analyze for accessibility: describe visual elements for screen readers, note caption quality, identify audio-only content”
Compliance”Review for regulatory compliance: identify claims, disclaimers, required disclosures”
Education”Analyze pedagogical effectiveness: identify learning objectives, teaching methods, assessment opportunities”
SEO”Extract SEO metadata: keywords, descriptions, suggested titles, topic clusters”

Variations

  • Comparative: “Enrich by comparing each video to the collection average”
  • Gap analysis: “What aspects of these videos are under-documented?”
  • Audience-specific: Change instructions to enrich for different target audiences

Jupyter notebook

Download the notebook to run this recipe interactively.

See also