Skip to content

Latest commit

 

History

History
483 lines (303 loc) · 14.3 KB

File metadata and controls

483 lines (303 loc) · 14.3 KB

Visit Tavus

Tavus

We're an AI video research company making personalized video possible at scale. Generate videos of yourself, and never record again! Available via web app & developer APIs.

Table of Contents

Requirements

Python >=3.7

Installation

Getting Started

from pprint import pprint
from tavus_python_sdk import Tavus, ApiException

tavus = Tavus(
    api_key="YOUR_API_KEY",
)

try:
    # Create Replica
    create_new_replica_response = tavus.replicas.create_new_replica(
        train_video_url="string_example",
        callback_url="string_example",
        replica_name="string_example",
    )
    print(create_new_replica_response)
except ApiException as e:
    print("Exception when calling ReplicasApi.create_new_replica: %s\n" % e)
    pprint(e.body)
    pprint(e.headers)
    pprint(e.status)
    pprint(e.reason)
    pprint(e.round_trip_time)

Async

async support is available by prepending a to any method.

import asyncio
from pprint import pprint
from tavus_python_sdk import Tavus, ApiException

tavus = Tavus(
    api_key="YOUR_API_KEY",
)


async def main():
    try:
        # Create Replica
        create_new_replica_response = await tavus.replicas.acreate_new_replica(
            train_video_url="string_example",
            callback_url="string_example",
            replica_name="string_example",
        )
        print(create_new_replica_response)
    except ApiException as e:
        print("Exception when calling ReplicasApi.create_new_replica: %s\n" % e)
        pprint(e.body)
        pprint(e.headers)
        pprint(e.status)
        pprint(e.reason)
        pprint(e.round_trip_time)


asyncio.run(main())

Raw HTTP Response

To access raw HTTP response values, use the .raw namespace.

from pprint import pprint
from tavus_python_sdk import Tavus, ApiException

tavus = Tavus(
    api_key="YOUR_API_KEY",
)

try:
    # Create Replica
    create_new_replica_response = tavus.replicas.raw.create_new_replica(
        train_video_url="string_example",
        callback_url="string_example",
        replica_name="string_example",
    )
    pprint(create_new_replica_response.body)
    pprint(create_new_replica_response.body["replica_id"])
    pprint(create_new_replica_response.body["status"])
    pprint(create_new_replica_response.headers)
    pprint(create_new_replica_response.status)
    pprint(create_new_replica_response.round_trip_time)
except ApiException as e:
    print("Exception when calling ReplicasApi.create_new_replica: %s\n" % e)
    pprint(e.body)
    pprint(e.headers)
    pprint(e.status)
    pprint(e.reason)
    pprint(e.round_trip_time)

Reference

tavus.replicas.create_new_replica

This endpoint creates a new Replica that can be used to generate personalized videos.

The only required body parameter is train_video_url. This url must be a download link such as a presigned S3 url. Please ensure you pass in a video that meets the requirements for training.

Replica training will fail without the following consent statement being present at the beginning of the video:

I, [FULL NAME], am currently speaking and consent Tavus to create an AI clone of me by using the audio and video samples I provide. I understand that this AI clone can be used to create videos that look and sound like me.

Learn more about the consent statement here.

Learn more about training a personal Replica here.

🛠️ Usage

create_new_replica_response = tavus.replicas.create_new_replica(
    train_video_url="string_example",
    callback_url="string_example",
    replica_name="string_example",
)

⚙️ Parameters

train_video_url: str

A direct link to a publicly accessible storage location such as an S3 bucket. This video will be used for replica training.

callback_url: str

A url that will receive a callback on completion of replica training or on error.

replica_name: str

A name for the replica.

⚙️ Request Body

ReplicasCreateNewReplicaRequest

🔄 Return

ReplicasCreateNewReplicaResponse

🌐 Endpoint

/v2/replicas post

🔙 Back to Table of Contents


tavus.replicas.delete_by_replica_id

This endpoint deletes a single Replica by its unique identifier. Once deleted, this Replica can not be used to generate videos.

🛠️ Usage

tavus.replicas.delete_by_replica_id(
    replica_id="replica_id_example",
)

⚙️ Parameters

replica_id: str

🌐 Endpoint

/v2/replicas/{replica_id} delete

🔙 Back to Table of Contents


tavus.replicas.get_replica_by_id

This endpoint returns a single Replica by its unique identifier.

Included in the response body is a training_progress string that represents the progress of the Replica training. If there are any errors during training, the status will be error and the error_message will be populated.

🛠️ Usage

get_replica_by_id_response = tavus.replicas.get_replica_by_id(
    replica_id="replica_id_example",
)

⚙️ Parameters

replica_id: str

🔄 Return

ReplicasGetReplicaByIdResponse

🌐 Endpoint

/v2/replicas/{replica_id} get

🔙 Back to Table of Contents


tavus.replicas.list

This endpoint returns a list of all replicas that have been created by the API Key in use. In the response, a root level data key will contain the list of Replicas.

🛠️ Usage

list_response = tavus.replicas.list()

🔄 Return

ReplicasListResponse

🌐 Endpoint

/v2/replicas get

🔙 Back to Table of Contents


tavus.replicas.rename_replica_by_id

This endpoint renames a single Replica by its unique identifier.

🛠️ Usage

tavus.replicas.rename_replica_by_id(
    replica_name="string_example",
    replica_id="replica_id_example",
)

⚙️ Parameters

replica_name: str
replica_id: str

⚙️ Request Body

ReplicasRenameReplicaByIdRequest

🌐 Endpoint

/v2/replicas/{replica_id}/name patch

🔙 Back to Table of Contents


tavus.videos.create_video_from_replica_and_script

This endpoint generates a new video using a Replica and a script.

The only required body parameters are replica_id and script. The replica_id is a unique identifier for the Replica that will be used to generate the video. The script is the text that will be spoken by the Replica in the video.

If a background_url is provided, Tavus will record a video of the website and use it as the background for the video. If a background_source_url is provided, where the URL points to a download link such as a presigned S3 URL, Tavus will use the video as the background for the video. If neither are provided, the video will consist of a full screen Replica.

To learn more about generating videos with Replicas, see here.

To learn more about writing an effective script for your video, see Scripting prompting.

🛠️ Usage

create_video_from_replica_and_script_response = (
    tavus.videos.create_video_from_replica_and_script(
        replica_id="r783537ef5",
        script="Hello from Tavus! Enjoy your new replica",
        background_source_url="string_example",
        background_url="string_example",
        video_name="My First Video",
    )
)

⚙️ Parameters

replica_id: str

A unique identifier for the replica that will be used to generate the video.

script: str

A script to be used for the video.

background_source_url: str

A direct link to a video that is publicly accessible via a storage location such as an S3 bucket. This will be used as the background for the video. The video must be publicly accessible.

background_url: str

A link to a website. This will be used as the background for the video. The website must be publicly accessible and properly formed.

video_name: str

A name for the video.

⚙️ Request Body

VideosCreateVideoFromReplicaAndScriptRequest

🔄 Return

VideosCreateVideoFromReplicaAndScriptResponse

🌐 Endpoint

/v2/videos post

🔙 Back to Table of Contents


tavus.videos.delete_by_video_id

This endpoint deletes a single video by its unique identifier.

🛠️ Usage

tavus.videos.delete_by_video_id(
    video_id="video_id_example",
)

⚙️ Parameters

video_id: str

🌐 Endpoint

/v2/videos/{video_id} delete

🔙 Back to Table of Contents


tavus.videos.get_all

This endpoint returns a list of all videos that have been generated by the API Key in use.

🛠️ Usage

get_all_response = tavus.videos.get_all()

🔄 Return

VideosGetAllResponse

🌐 Endpoint

/v2/videos get

🔙 Back to Table of Contents


tavus.videos.get_by_video_id

This endpoint returns a single video by its unique identifier.

The response body will contain a status string that represents the status of the video. If the video is ready, the response body will also contain a download_url, stream_url, and hosted_url that can be used to download, stream, and view the video respectively.

🛠️ Usage

get_by_video_id_response = tavus.videos.get_by_video_id(
    video_id="video_id_example",
)

⚙️ Parameters

video_id: str

🔄 Return

VideosGetByVideoIdResponse

🌐 Endpoint

/v2/videos/{video_id} get

🔙 Back to Table of Contents


tavus.videos.update_name

This endpoint renames a single video by its unique identifier.

🛠️ Usage

tavus.videos.update_name(
    video_name="string_example",
    video_id="video_id_example",
)

⚙️ Parameters

video_name: str
video_id: str

⚙️ Request Body

VideosUpdateNameRequest

🌐 Endpoint

/v2/videos/{video_id}/name patch

🔙 Back to Table of Contents


Author

This Python package is automatically generated by Konfig