Class: Tavus::Resources::Replicas

Inherits:
Object
  • Object
show all
Defined in:
lib/tavus/resources/replicas.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Replicas



6
7
8
# File 'lib/tavus/resources/replicas.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#create(train_video_url:, **options) ⇒ Hash

Create a new replica

Options Hash (**options):

  • :consent_video_url (String)

    Direct link to consent video

  • :callback_url (String)

    URL to receive callbacks on completion

  • :replica_name (String)

    Name for the replica

  • :model_name (String)

    Phoenix model version (default: phoenix-3)

  • :properties (Hash)

    Additional properties



19
20
21
22
# File 'lib/tavus/resources/replicas.rb', line 19

def create(train_video_url:, **options)
  body = options.merge(train_video_url: train_video_url)
  @client.post("/v2/replicas", body: body)
end

#delete(replica_id, hard: false) ⇒ Hash

Delete a replica



49
50
51
52
# File 'lib/tavus/resources/replicas.rb', line 49

def delete(replica_id, hard: false)
  params = hard ? { hard: true } : {}
  @client.delete("/v2/replicas/#{replica_id}", params: params)
end

#get(replica_id, verbose: false) ⇒ Hash

Get a single replica by ID



28
29
30
31
# File 'lib/tavus/resources/replicas.rb', line 28

def get(replica_id, verbose: false)
  params = verbose ? { verbose: true } : {}
  @client.get("/v2/replicas/#{replica_id}", params: params)
end

#list(**options) ⇒ Hash

List all replicas

Options Hash (**options):

  • :limit (Integer)

    Number of replicas to return per page

  • :page (Integer)

    Page number to return

  • :verbose (Boolean)

    Include additional replica data

  • :replica_type (String)

    Filter by type (user, system)

  • :replica_ids (String)

    Comma-separated list of replica IDs to filter



41
42
43
# File 'lib/tavus/resources/replicas.rb', line 41

def list(**options)
  @client.get("/v2/replicas", params: options)
end

#rename(replica_id, replica_name) ⇒ Hash

Rename a replica



58
59
60
# File 'lib/tavus/resources/replicas.rb', line 58

def rename(replica_id, replica_name)
  @client.patch("/v2/replicas/#{replica_id}/name", body: { replica_name: replica_name })
end