or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

audio-processing.mdconversational-ai.mddubbing.mdindex.mdmusic.mdrealtime.mdstudio.mdtext-to-speech.mdtranscription.mdvoices.mdworkspace.md

workspace.mddocs/

0

# Workspace & Account Management

1

2

## User Management

3

4

### user.get()

5

6

```typescript { .api }

7

get(options?: RequestOptions): Promise<User>

8

9

interface User {

10

subscription: Subscription;

11

isNewUser: boolean;

12

xiApiKey: string;

13

canUseDelayedPaymentMethods: boolean;

14

isOnboardingCompleted: boolean;

15

// Additional fields...

16

}

17

```

18

19

**Example:**

20

```typescript

21

const user = await client.user.get();

22

console.log("API Key:", user.xiApiKey);

23

console.log("Subscription:", user.subscription.tier);

24

```

25

26

## Usage Tracking

27

28

### usage.get()

29

30

```typescript { .api }

31

get(

32

request: {

33

startUnix: number;

34

endUnix: number;

35

includeWorkspaceMetrics?: boolean;

36

breakdownType?: string;

37

aggregationInterval?: string;

38

metric?: string;

39

},

40

options?: RequestOptions

41

): Promise<UsageCharactersResponseModel>

42

```

43

44

**Example:**

45

```typescript

46

const now = Math.floor(Date.now() / 1000);

47

const thirtyDaysAgo = now - (30 * 24 * 60 * 60);

48

49

const usage = await client.usage.get({

50

startUnix: thirtyDaysAgo,

51

endUnix: now,

52

includeWorkspaceMetrics: true

53

});

54

55

console.log("Characters used:", usage.characterCount);

56

```

57

58

## Workspace Management

59

60

### workspace.get()

61

62

```typescript { .api }

63

get(options?: RequestOptions): Promise<Workspace>

64

```

65

66

### workspace.update()

67

68

```typescript { .api }

69

update(

70

request: WorkspaceUpdateRequest,

71

options?: RequestOptions

72

): Promise<Workspace>

73

```

74

75

## Models

76

77

### models.list()

78

79

```typescript { .api }

80

list(options?: RequestOptions): Promise<Model[]>

81

82

interface Model {

83

modelId: string;

84

name: string;

85

canBeFinetuned: boolean;

86

canDoTextToSpeech: boolean;

87

canDoVoiceConversion: boolean;

88

canUseStyle: boolean;

89

canUseSpeakerBoost: boolean;

90

servesProVoices: boolean;

91

tokenCostFactor: number;

92

description?: string;

93

languages?: Language[];

94

maxCharactersRequestFreeUser?: number;

95

maxCharactersRequestSubscribedUser?: number;

96

// Additional fields...

97

}

98

```

99

100

**Example:**

101

```typescript

102

const models = await client.models.list();

103

104

models.forEach(model => {

105

console.log(`${model.name} (${model.modelId})`);

106

console.log(` TTS: ${model.canDoTextToSpeech}`);

107

console.log(` Languages: ${model.languages?.length}`);

108

});

109

```

110

111

## History Management

112

113

### history.list()

114

115

```typescript { .api }

116

list(

117

request?: {

118

pageSize?: number;

119

startAfterHistoryItemId?: string;

120

voiceId?: string;

121

modelId?: string;

122

dateBeforeUnix?: number;

123

dateAfterUnix?: number;

124

search?: string;

125

},

126

options?: RequestOptions

127

): Promise<GetSpeechHistoryResponse>

128

```

129

130

### history.get()

131

132

```typescript { .api }

133

get(

134

historyItemId: string,

135

options?: RequestOptions

136

): Promise<SpeechHistoryItemResponse>

137

```

138

139

### history.getAudio()

140

141

```typescript { .api }

142

getAudio(

143

historyItemId: string,

144

options?: RequestOptions

145

): Promise<ReadableStream<Uint8Array>>

146

```

147

148

### history.delete()

149

150

```typescript { .api }

151

delete(

152

historyItemId: string,

153

options?: RequestOptions

154

): Promise<DeleteHistoryItemResponse>

155

```

156

157

### history.download()

158

159

```typescript { .api }

160

download(

161

request: {

162

historyItemIds: string[];

163

outputFormat?: string;

164

},

165

options?: RequestOptions

166

): Promise<ReadableStream<Uint8Array>>

167

```

168

169

**Example:**

170

```typescript

171

import fs from "fs";

172

173

// List history

174

const history = await client.history.list({

175

pageSize: 20,

176

voiceId: "21m00Tcm4TlvDq8ikWAM"

177

});

178

179

// Get specific item

180

const item = await client.history.get(history.history[0].historyItemId);

181

182

// Download audio

183

const audio = await client.history.getAudio(item.historyItemId);

184

const output = fs.createWriteStream("history_item.mp3");

185

for await (const chunk of audio) {

186

output.write(chunk);

187

}

188

output.end();

189

190

// Delete item

191

await client.history.delete(item.historyItemId);

192

```

193

194

## Pronunciation Dictionaries

195

196

### pronunciationDictionaries.createFromFile()

197

198

```typescript { .api }

199

createFromFile(

200

request: {

201

name: string;

202

file: File | Blob;

203

description?: string;

204

workspaceAccess?: string;

205

},

206

options?: RequestOptions

207

): Promise<AddPronunciationDictionaryResponseModel>

208

```

209

210

### pronunciationDictionaries.createFromRules()

211

212

```typescript { .api }

213

createFromRules(

214

request: {

215

name: string;

216

rules: Array<{

217

type: string;

218

stringToReplace: string;

219

phoneme?: string;

220

alphabet?: string;

221

}>;

222

description?: string;

223

},

224

options?: RequestOptions

225

): Promise<AddPronunciationDictionaryResponseModel>

226

```

227

228

**Example:**

229

```typescript

230

// Create from rules

231

const dict = await client.pronunciationDictionaries.createFromRules({

232

name: "Tech Terms",

233

description: "Technical terminology pronunciations",

234

rules: [

235

{

236

type: "phoneme",

237

stringToReplace: "API",

238

phoneme: "eɪ piː aɪ",

239

alphabet: "ipa"

240

},

241

{

242

type: "alias",

243

stringToReplace: "ElevenLabs",

244

phoneme: "Eleven Labs"

245

}

246

]

247

});

248

249

// Use in TTS

250

const audio = await client.textToSpeech.convert("voiceId", {

251

text: "The API from ElevenLabs is great",

252

pronunciationDictionaryLocators: [{

253

pronunciationDictionaryId: dict.id,

254

versionId: dict.versionId

255

}]

256

});

257

```

258

259

## Service Accounts

260

261

### serviceAccounts.list()

262

263

```typescript { .api }

264

list(options?: RequestOptions): Promise<WorkspaceServiceAccountListResponseModel>

265

```

266

267

## Webhooks

268

269

### webhooks.list()

270

271

```typescript { .api }

272

list(

273

request?: { includeUsages?: boolean },

274

options?: RequestOptions

275

): Promise<WorkspaceWebhookListResponseModel>

276

```

277

278

### webhooks.constructEvent()

279

280

```typescript { .api }

281

constructEvent(

282

rawBody: string,

283

sigHeader: string,

284

secret: string

285

): Promise<any>

286

```

287

288

**Example:**

289

```typescript

290

// In webhook handler

291

app.post("/webhook", async (req, res) => {

292

const signature = req.headers["elevenlabs-signature"];

293

const rawBody = JSON.stringify(req.body);

294

295

try {

296

const event = await client.webhooks.constructEvent(

297

rawBody,

298

signature,

299

process.env.WEBHOOK_SECRET

300

);

301

302

console.log("Event type:", event.type);

303

console.log("Event data:", event.data);

304

305

res.sendStatus(200);

306

} catch (err) {

307

console.error("Webhook verification failed:", err);

308

res.sendStatus(400);

309

}

310

});

311

```

312

313

## Single-Use Tokens

314

315

### tokens.singleUse.create()

316

317

```typescript { .api }

318

create(

319

tokenType: "realtime_scribe",

320

options?: RequestOptions

321

): Promise<SingleUseTokenResponseModel>

322

```

323

324

**Example:**

325

```typescript

326

// Generate token for frontend

327

const token = await client.tokens.singleUse.create("realtime_scribe");

328

329

// Send to frontend

330

res.json({ token: token.token });

331

332

// Frontend can use token for limited-time access

333

// const frontendClient = new ElevenLabsClient({ apiKey: token.token });

334

```

335

336

## Usage Examples

337

338

### Check Subscription and Usage

339

340

```typescript

341

import { ElevenLabsClient } from "@elevenlabs/elevenlabs-js";

342

343

const client = new ElevenLabsClient({ apiKey: process.env.ELEVENLABS_API_KEY });

344

345

const user = await client.user.get();

346

console.log("Tier:", user.subscription.tier);

347

console.log("Character Limit:", user.subscription.characterLimit);

348

console.log("Characters Used:", user.subscription.characterCount);

349

350

const remaining = user.subscription.characterLimit - user.subscription.characterCount;

351

console.log("Remaining:", remaining);

352

```

353

354

### List Available Models

355

356

```typescript

357

const models = await client.models.list();

358

359

const ttsModels = models.filter(m => m.canDoTextToSpeech);

360

console.log("TTS Models:");

361

ttsModels.forEach(model => {

362

console.log(`- ${model.name}: ${model.description}`);

363

});

364

```

365

366

### Manage History

367

368

```typescript

369

// Get recent history

370

const history = await client.history.list({ pageSize: 10 });

371

372

// Download multiple items

373

const itemIds = history.history.slice(0, 3).map(h => h.historyItemId);

374

const archive = await client.history.download({

375

historyItemIds: itemIds,

376

outputFormat: "mp3_44100_128"

377

});

378

379

const zip = fs.createWriteStream("history_archive.zip");

380

for await (const chunk of archive) {

381

zip.write(chunk);

382

}

383

zip.end();

384

```

385

386

## Important Notes

387

388

- **User Info**: Access subscription, limits, API keys

389

- **Usage Tracking**: Monitor character usage by time range

390

- **Models**: Query available models and capabilities

391

- **History**: Track and download generated audio

392

- **Pronunciation**: Custom dictionaries for accurate speech

393

- **Webhooks**: Verify signatures for security

394

- **Tokens**: Time-limited tokens for frontend clients

395

- **Service Accounts**: Programmatic workspace access

396