
개발자 허브
TwelveLabs를 통합하기 위한 가이드와 예제를 탐색하세요.
시맨틱 검색, 이상 탐지, 콘텐츠 추천 및 맞춤형 기능을 쉽게 구축할 수 있습니다. 우리 API는 당신의 비디오가 가진 잠재력을 최대한 발휘할 수 있도록 해줍니다.
TwelveLabs를 통합하기 위한 가이드와 예제를 탐색하세요.
Get your API keys from the dashboard page and ensure the TwelveLabs SDK is installed on your computer:
$
pip install twelvelabs
You can copy and paste the code below to analyze videos and generate text based on their content. Replace the placeholders surrounded by <> with your values.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from twelvelabs import TwelveLabs
from twelvelabs.indexes import IndexesCreateRequestModelsItem
from twelvelabs.tasks import TasksRetrieveResponse
client = TwelveLabs(api_key="<YOUR_API_KEY>")
index = client.indexes.create(
index_name="<YOUR_INDEX_NAME>",
models=[
IndexesCreateRequestModelsItem(
model_name="pegasus1.2", model_options=["visual", "audio"]
)
]
)
print(f"Created index: id={index.id}")
task = client.tasks.create(
index_id=index.id, video_url="<YOUR_VIDEO_URL>")
print(f"Created task: id={task.id}")
def on_task_update(task: TasksRetrieveResponse):
print(f" Status={task.status}")
task = client.tasks.wait_for_done(task_id=task.id, callback=on_task_update)
if task.status != "ready":
raise RuntimeError(f"Indexing failed with status {task.status}")
print(
f"Upload complete. The unique identifier of your video is {task.video_id}.")
gist = client.gist(video_id=task.video_id,types=["title", "topic", "hashtag"])
print(f"Title={gist.title}\nTopics={gist.topics}\nHashtags={gist.hashtags}")