tavus

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package tavus provides a Tavus Conversational Video provider for omniavatar.

Tavus enables real-time AI avatar video generation that integrates with LiveKit for audio streaming and video output.

Quick Start

Import this package to auto-register the tavus provider:

import (
    "github.com/plexusone/omniavatar"
    _ "github.com/plexusone/omniavatar/providers/tavus"
)

func main() {
    provider, err := omniavatar.GetAvatarProvider("tavus",
        omniavatar.WithAPIKey(os.Getenv("TAVUS_API_KEY")),
        omniavatar.WithExtension("pal_id", palID))
}

Configuration

The tavus provider accepts the following extensions:

  • pal_id (string, optional): PAL (Personalized AI Likeness) ID. Defaults to stock avatar.
  • face_id (string, optional): Face override ID.

API Key

Get your Tavus API key from https://docs.tavus.io

Index

Constants

View Source
const DefaultPalID = "pb87e71797da"

DefaultPalID is the stock Tavus PAL for testing.

Variables

This section is empty.

Functions

func NewProviderFromConfig

func NewProviderFromConfig(cfg registry.ProviderConfig) (avatar.Provider, error)

NewProviderFromConfig creates a Tavus provider from registry config.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the tavus-go SDK for avatar session management.

func NewClient

func NewClient(cfg ClientConfig) (*Client, error)

NewClient creates a new Tavus API client using the tavus-go SDK.

func (*Client) CreateConversation

CreateConversation creates a new conversation with the Tavus API.

func (*Client) EndConversation

func (c *Client) EndConversation(ctx context.Context, conversationID string) error

EndConversation ends an active conversation.

func (*Client) SDK

func (c *Client) SDK() *tavussdk.Client

SDK returns the underlying tavus-go SDK client for advanced usage.

type ClientConfig

type ClientConfig struct {
	// APIKey is the Tavus API key.
	// Required.
	APIKey string

	// BaseURL is the Tavus API base URL.
	// Default: https://tavusapi.com
	BaseURL string

	// HTTPClient is an optional custom HTTP client.
	// Default: http.Client with 30s timeout
	HTTPClient *http.Client
}

ClientConfig configures the Tavus API client.

type Config

type Config struct {
	// APIKey is the Tavus API key.
	// Required.
	APIKey string

	// BaseURL is the Tavus API base URL.
	// Default: https://tavusapi.com
	BaseURL string

	// PalID is the PAL (Personalized AI Likeness) to use.
	// Default: stock avatar (DefaultPalID)
	PalID string

	// FaceID is an optional face override.
	FaceID string
}

Config configures the Tavus avatar provider.

type CreateConversationRequest

type CreateConversationRequest struct {
	// PalID is the PAL (Personalized AI Likeness) to use.
	// Required.
	PalID string

	// FaceID is an optional face override.
	FaceID string

	// LiveKitURL is the LiveKit WebSocket URL for the avatar to connect to.
	LiveKitURL string

	// LiveKitToken is the JWT token for the avatar to join the room.
	LiveKitToken string

	// ConversationName is an optional name for the conversation.
	// Auto-generated if not provided.
	ConversationName string
}

CreateConversationRequest is the request to create a conversation.

type CreateConversationResponse

type CreateConversationResponse struct {
	// ConversationID is the unique identifier for the conversation.
	ConversationID string

	// ConversationURL is the URL for the conversation (if available).
	ConversationURL string
}

CreateConversationResponse is the response from creating a conversation.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements avatar.Provider for Tavus.

func NewProvider

func NewProvider(cfg Config) (*Provider, error)

NewProvider creates a new Tavus avatar provider.

func (*Provider) CreateSession

func (p *Provider) CreateSession(cfg avatar.SessionConfig) (avatar.Session, error)

CreateSession creates a new Tavus avatar session.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session implements avatar.Session for Tavus avatars.

func NewSession

func NewSession(cfg SessionConfig) (*Session, error)

NewSession creates a new Tavus avatar session.

func (*Session) AudioOutput

func (s *Session) AudioOutput() avatar.AudioDestination

AudioOutput returns the audio destination for streaming TTS audio.

func (*Session) Close

func (s *Session) Close(ctx context.Context) error

Close disconnects the avatar and cleans up resources.

func (*Session) ConversationID

func (s *Session) ConversationID() string

ConversationID returns the Tavus conversation ID.

func (*Session) EmitError

func (s *Session) EmitError(err error)

EmitError emits an error event.

func (*Session) EmitPlaybackFinished

func (s *Session) EmitPlaybackFinished(position float64, interrupted bool)

EmitPlaybackFinished emits a playback finished event.

func (*Session) EmitPlaybackStarted

func (s *Session) EmitPlaybackStarted()

EmitPlaybackStarted emits a playback started event.

func (*Session) Identity

func (s *Session) Identity() string

Identity returns the avatar participant identity.

func (*Session) Provider

func (s *Session) Provider() string

Provider returns the provider name.

func (*Session) Room

func (s *Session) Room() *lksdk.Room

Room returns the LiveKit room reference.

func (*Session) SetAudioOutput

func (s *Session) SetAudioOutput(out avatar.AudioDestination)

SetAudioOutput sets the audio destination.

func (*Session) SetCallbacks

func (s *Session) SetCallbacks(callbacks *avatar.SessionCallbacks)

SetCallbacks registers event callbacks for the session.

func (*Session) Start

func (s *Session) Start(ctx context.Context, opts any) error

Start initializes the Tavus avatar session.

The opts parameter must be *omniavatar.LiveKitStartOptions.

func (*Session) WaitForJoin

func (s *Session) WaitForJoin(ctx context.Context, timeout time.Duration) error

WaitForJoin blocks until the avatar participant joins the room.

type SessionConfig

type SessionConfig struct {
	// Client is the Tavus API client.
	// Required.
	Client *Client

	// PalID is the PAL (Personalized AI Likeness) to use.
	// Required.
	PalID string

	// FaceID is an optional face override.
	FaceID string

	// AudioConfig configures the audio format.
	AudioConfig avatar.AudioConfig
}

SessionConfig configures a Tavus avatar session.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL