Client API Reference¶
Client¶
The main client for interacting with the ElevenLabs API.
Constructor¶
Creates a new client with optional configuration.
Options:
| Option | Description |
|---|---|
WithAPIKey(key string) |
Set API key |
WithBaseURL(url string) |
Set base URL |
WithHTTPClient(client *http.Client) |
Set HTTP client |
WithTimeout(timeout time.Duration) |
Set request timeout |
Example:
client, err := elevenlabs.NewClient(
elevenlabs.WithAPIKey("your-api-key"),
elevenlabs.WithTimeout(5 * time.Minute),
)
Service Accessors¶
| Method | Returns | Description |
|---|---|---|
TextToSpeech() |
*TextToSpeechService |
Text-to-speech operations |
Voices() |
*VoicesService |
Voice management |
Models() |
*ModelsService |
Model listing |
History() |
*HistoryService |
Generation history |
User() |
*UserService |
User/subscription info |
Dubbing() |
*DubbingService |
Video dubbing |
SoundEffects() |
*SoundEffectsService |
Sound effect generation |
Pronunciation() |
*PronunciationService |
Pronunciation dictionaries |
Projects() |
*ProjectsService |
Studio projects |
API() |
*api.Client |
Raw ogen client |
Constants¶
const Version = "0.1.0"
const DefaultBaseURL = "https://api.elevenlabs.io"
const DefaultModelID = "eleven_multilingual_v2"
TextToSpeechService¶
Generate¶
Generate speech with full control over options.
Simple¶
Generate speech with default settings.
VoicesService¶
List¶
Get¶
GetSettings¶
GetDefaultSettings¶
SoundEffectsService¶
Generate¶
func (s *SoundEffectsService) Generate(ctx context.Context, req *SoundEffectRequest) (*SoundEffectResponse, error)
Simple¶
GenerateLoop¶
func (s *SoundEffectsService) GenerateLoop(ctx context.Context, description string, durationSeconds float64) (io.Reader, error)
PronunciationService¶
List¶
func (s *PronunciationService) List(ctx context.Context, opts *PronunciationDictionaryListOptions) (*PronunciationDictionaryListResponse, error)
Get¶
func (s *PronunciationService) Get(ctx context.Context, dictionaryID string) (*PronunciationDictionary, error)
Create¶
func (s *PronunciationService) Create(ctx context.Context, req *CreatePronunciationDictionaryRequest) (*PronunciationDictionary, error)
CreateFromJSON¶
func (s *PronunciationService) CreateFromJSON(ctx context.Context, name, jsonFilePath string) (*PronunciationDictionary, error)
CreateFromMap¶
func (s *PronunciationService) CreateFromMap(ctx context.Context, name string, rules map[string]string) (*PronunciationDictionary, error)
RemoveRules¶
func (s *PronunciationService) RemoveRules(ctx context.Context, dictionaryID string, ruleStrings []string) error
Rename¶
Archive¶
ProjectsService¶
List¶
Create¶
Update¶
func (s *ProjectsService) Update(ctx context.Context, projectID string, req *UpdateProjectRequest) error
Delete¶
Convert¶
ListChapters¶
ConvertChapter¶
DeleteChapter¶
ListSnapshots¶
func (s *ProjectsService) ListSnapshots(ctx context.Context, projectID string) ([]*ProjectSnapshot, error)
DownloadSnapshotArchive¶
func (s *ProjectsService) DownloadSnapshotArchive(ctx context.Context, projectID, snapshotID string) (io.Reader, error)
Helper Functions¶
PronunciationRules¶
func LoadRulesFromJSON(filename string) (PronunciationRules, error)
func ParseRulesFromJSON(data []byte) (PronunciationRules, error)
func RulesFromMap(m map[string]string) PronunciationRules
func (rules PronunciationRules) ToPLS(language string) ([]byte, error)
func (rules PronunciationRules) ToPLSString(language string) (string, error)
func (rules PronunciationRules) SavePLS(filename, language string) error
func (rules PronunciationRules) Graphemes() []string
func (rules PronunciationRules) String() string
VoiceSettings¶
Returns default voice settings (Stability: 0.5, SimilarityBoost: 0.75).