0
# Project Management
1
2
Complete account and project management functionality including API key management, usage tracking, team member management, and billing information access. The Manage module provides comprehensive administrative capabilities for Deepgram accounts and projects.
3
4
## Capabilities
5
6
### Manage Client
7
8
Synchronous and asynchronous clients for account and project management operations.
9
10
```python { .api }
11
class ManageClient:
12
# Project Management
13
def get_projects(self) -> ProjectsResponse: ...
14
def get_project(self, project_id: str) -> Project: ...
15
def update_project(self, project_id: str, options: ProjectOptions) -> Message: ...
16
def delete_project(self, project_id: str) -> Message: ...
17
18
# API Key Management
19
def get_keys(self, project_id: str) -> KeysResponse: ...
20
def get_key(self, project_id: str, key_id: str) -> KeyResponse: ...
21
def create_key(self, project_id: str, options: KeyOptions) -> KeyResponse: ...
22
def delete_key(self, project_id: str, key_id: str) -> Message: ...
23
24
# Team Member Management
25
def get_members(self, project_id: str) -> MembersResponse: ...
26
def remove_member(self, project_id: str, member_id: str) -> Message: ...
27
def get_member_scopes(self, project_id: str, member_id: str) -> ScopesResponse: ...
28
def update_member_scope(self, project_id: str, member_id: str, options: ScopeOptions) -> Message: ...
29
30
# Invitation Management
31
def get_invites(self, project_id: str) -> InvitesResponse: ...
32
def send_invite(self, project_id: str, options: InviteOptions) -> Message: ...
33
def delete_invite(self, project_id: str, email: str) -> Message: ...
34
35
# Usage and Billing
36
def get_usage(self, project_id: str, options: UsageRequestOptions) -> UsageResponse: ...
37
def get_usage_request(self, project_id: str, request_id: str) -> UsageRequest: ...
38
def get_usage_requests(self, project_id: str, options: UsageRequestOptions) -> UsageRequestsResponse: ...
39
def get_usage_summary(self, project_id: str, options: UsageSummaryOptions) -> UsageSummaryResponse: ...
40
def get_usage_fields(self, project_id: str, options: UsageFieldsOptions) -> UsageFieldsResponse: ...
41
def get_balances(self, project_id: str) -> BalancesResponse: ...
42
43
# Model Information
44
def get_models(self, project_id: str) -> ModelsResponse: ...
45
def get_model(self, project_id: str, model_id: str) -> ModelResponse: ...
46
47
class AsyncManageClient:
48
# All methods are async versions of ManageClient methods
49
async def get_projects(self) -> ProjectsResponse: ...
50
async def get_project(self, project_id: str) -> Project: ...
51
# ... (all other methods with async keyword)
52
```
53
54
### Options Classes
55
56
Configuration options for various management operations.
57
58
```python { .api }
59
class ProjectOptions:
60
def __init__(self, **kwargs): ...
61
name: str = None # Project name
62
company: str = None # Company name
63
64
class KeyOptions:
65
def __init__(self, **kwargs): ...
66
comment: str = None # Key description/comment
67
scopes: list = None # Key permissions/scopes
68
tags: list = None # Key tags for organization
69
time_to_live_in_seconds: int = None # Key expiration time
70
71
class ScopeOptions:
72
def __init__(self, **kwargs): ...
73
scope: str # Permission scope to assign/modify
74
75
class InviteOptions:
76
def __init__(self, **kwargs): ...
77
email: str # Email address to invite
78
scope: str # Permission scope for invitee
79
80
class UsageRequestOptions:
81
def __init__(self, **kwargs): ...
82
start: str = None # Start date (ISO format)
83
end: str = None # End date (ISO format)
84
limit: int = None # Number of results to return
85
status: str = None # Filter by request status
86
87
class UsageSummaryOptions:
88
def __init__(self, **kwargs): ...
89
start: str = None # Start date (ISO format)
90
end: str = None # End date (ISO format)
91
accessor: str = None # Filter by accessor
92
tag: str = None # Filter by tag
93
method: str = None # Filter by HTTP method
94
model: str = None # Filter by model
95
multichannel: bool = None # Filter by multichannel usage
96
interim_results: bool = None # Filter by interim results usage
97
punctuate: bool = None # Filter by punctuation usage
98
ner: bool = None # Filter by NER usage
99
diarize: bool = None # Filter by diarization usage
100
search: bool = None # Filter by search usage
101
redact: bool = None # Filter by redaction usage
102
alternatives: bool = None # Filter by alternatives usage
103
numerals: bool = None # Filter by numerals usage
104
smart_format: bool = None # Filter by smart formatting usage
105
106
class UsageFieldsOptions:
107
def __init__(self, **kwargs): ...
108
start: str = None # Start date (ISO format)
109
end: str = None # End date (ISO format)
110
```
111
112
### Response Types
113
114
#### Project Management Responses
115
116
```python { .api }
117
class ProjectsResponse:
118
"""List of projects response"""
119
projects: list[Project]
120
121
class Project:
122
"""Project information"""
123
project_id: str
124
name: str
125
company: str = None
126
created: str
127
updated: str = None
128
129
class Message:
130
"""Generic success/status message"""
131
message: str
132
```
133
134
#### API Key Management Responses
135
136
```python { .api }
137
class KeysResponse:
138
"""List of API keys response"""
139
api_keys: list[Key]
140
141
class KeyResponse:
142
"""Single API key response"""
143
api_key: Key
144
145
class Key:
146
"""API key information"""
147
api_key_id: str
148
key: str = None # Actual key value (only shown on creation)
149
comment: str = None
150
created: str
151
scopes: list[str]
152
tags: list[str] = None
153
```
154
155
#### Team Management Responses
156
157
```python { .api }
158
class MembersResponse:
159
"""Team members list response"""
160
members: list[Member]
161
162
class Member:
163
"""Team member information"""
164
member_id: str
165
email: str
166
first_name: str = None
167
last_name: str = None
168
scopes: list[str]
169
170
class ScopesResponse:
171
"""Member scopes response"""
172
scopes: list[str]
173
174
class InvitesResponse:
175
"""Pending invitations response"""
176
invites: list[Invite]
177
178
class Invite:
179
"""Invitation information"""
180
email: str
181
scope: str
182
sent: str
183
```
184
185
#### Usage and Billing Responses
186
187
```python { .api }
188
class UsageResponse:
189
"""Usage data response"""
190
start: str
191
end: str
192
resolution: Resolution
193
results: list[UsageRequest]
194
195
class UsageRequestsResponse:
196
"""Usage requests list response"""
197
page: int
198
limit: int
199
requests: list[UsageRequest]
200
201
class UsageRequest:
202
"""Individual usage request"""
203
request_id: str
204
created: str
205
path: str
206
accessor: str = None
207
response: dict = None
208
callback: Callback = None
209
210
class UsageSummaryResponse:
211
"""Usage summary response"""
212
start: str
213
end: str
214
resolution: Resolution
215
results: list[UsageSummaryResults]
216
217
class UsageFieldsResponse:
218
"""Available usage fields response"""
219
stt: STTDetails
220
tts: TTSDetails
221
222
class BalancesResponse:
223
"""Account balances response"""
224
balances: list[Balance]
225
226
class Balance:
227
"""Account balance information"""
228
balance_id: str
229
amount: float
230
units: str
231
purchase: str = None
232
```
233
234
#### Usage Detail Types
235
236
```python { .api }
237
class UsageSummaryResults:
238
"""Usage summary data"""
239
start: str
240
end: str
241
hours: float
242
total_hours: float
243
requests: int
244
tokens: int
245
246
class Resolution:
247
"""Usage data resolution"""
248
units: str
249
amount: int
250
251
class STTDetails:
252
"""Speech-to-text usage details"""
253
requests: int
254
hours: float
255
tokens: STTTokens
256
257
class TTSDetails:
258
"""Text-to-speech usage details"""
259
requests: int
260
characters: int
261
tokens: TTSTokens
262
263
class TTSMetadata:
264
"""TTS metadata information"""
265
model: str
266
characters: int
267
duration: float
268
269
class STTUsageDetails:
270
"""Detailed STT usage breakdown"""
271
model: str
272
language: str
273
version: str
274
uuid: str
275
batch: bool
276
streaming: bool
277
method: str
278
multichannel: bool
279
alternatives: int
280
numerals: bool
281
punctuate: bool
282
profanity_filter: bool
283
redaction: bool
284
diarization: bool
285
ner: bool
286
search: bool
287
keywords: bool
288
sentiment: bool
289
topics: bool
290
intents: bool
291
custom_topics: bool
292
custom_intents: bool
293
294
class TTSUsageDetails:
295
"""Detailed TTS usage breakdown"""
296
model: str
297
method: str
298
299
class STTTokens:
300
"""STT token usage"""
301
tokens: int
302
303
class TTSTokens:
304
"""TTS token usage"""
305
tokens: int
306
307
class UsageModel:
308
"""Usage model information"""
309
name: str
310
canonical_name: str
311
architecture: str
312
language: str = None
313
version: str
314
uuid: str
315
batch: bool
316
streaming: bool
317
```
318
319
#### Supporting Types
320
321
```python { .api }
322
class Callback:
323
"""Callback configuration"""
324
url: str
325
method: str = "POST"
326
327
class TokenDetail:
328
"""Token usage details"""
329
feature: str
330
input: int
331
output: int
332
model: str
333
334
class SpeechSegment:
335
"""Speech processing segment"""
336
start: float
337
end: float
338
confidence: float
339
text: str
340
341
class Config:
342
"""Configuration settings"""
343
key: str
344
value: str
345
```
346
347
#### Model Information Responses
348
349
```python { .api }
350
class ModelsResponse:
351
"""Available models list response"""
352
stt_models: list[ModelInfo]
353
tts_models: list[ModelInfo]
354
355
class ModelResponse:
356
"""Single model information response"""
357
name: str
358
canonical_name: str
359
architecture: str
360
languages: list[str] = None
361
version: str
362
uuid: str
363
batch: bool
364
streaming: bool
365
366
class ModelInfo:
367
"""Model information"""
368
name: str
369
canonical_name: str
370
architecture: str
371
language: str = None
372
version: str
373
uuid: str
374
batch: bool
375
streaming: bool
376
```
377
378
## Usage Examples
379
380
### Project Management
381
382
```python
383
from deepgram import DeepgramClient
384
385
client = DeepgramClient(api_key="your-api-key")
386
387
# List all projects
388
projects_response = client.manage.get_projects()
389
print(f"Found {len(projects_response.projects)} projects:")
390
391
for project in projects_response.projects:
392
print(f"- {project.name} (ID: {project.project_id})")
393
394
# Get detailed project info
395
project_details = client.manage.get_project(project.project_id)
396
print(f" Company: {project_details.company}")
397
print(f" Created: {project_details.created}")
398
```
399
400
### API Key Management
401
402
```python
403
from deepgram import DeepgramClient, KeyOptions
404
405
client = DeepgramClient(api_key="your-api-key")
406
project_id = "your-project-id"
407
408
# List existing keys
409
keys_response = client.manage.get_keys(project_id)
410
print(f"Existing keys: {len(keys_response.api_keys)}")
411
412
# Create a new API key
413
key_options = KeyOptions(
414
comment="Development key for testing",
415
scopes=["usage:read", "keys:read"],
416
tags=["development", "testing"],
417
time_to_live_in_seconds=86400 # 24 hours
418
)
419
420
new_key_response = client.manage.create_key(project_id, key_options)
421
print(f"Created new key: {new_key_response.api_key.api_key_id}")
422
print(f"Key value: {new_key_response.api_key.key}") # Only shown on creation
423
424
# Get key details
425
key_details = client.manage.get_key(project_id, new_key_response.api_key.api_key_id)
426
print(f"Key scopes: {key_details.api_key.scopes}")
427
print(f"Key tags: {key_details.api_key.tags}")
428
```
429
430
### Team Member Management
431
432
```python
433
from deepgram import DeepgramClient, InviteOptions, ScopeOptions
434
435
client = DeepgramClient(api_key="your-api-key")
436
project_id = "your-project-id"
437
438
# List team members
439
members_response = client.manage.get_members(project_id)
440
print(f"Team members: {len(members_response.members)}")
441
442
for member in members_response.members:
443
print(f"- {member.email} ({member.first_name} {member.last_name})")
444
print(f" Scopes: {member.scopes}")
445
446
# Send an invitation
447
invite_options = InviteOptions(
448
email="new.member@company.com",
449
scope="usage:read"
450
)
451
452
invite_response = client.manage.send_invite(project_id, invite_options)
453
print(f"Invitation sent: {invite_response.message}")
454
455
# List pending invitations
456
invites_response = client.manage.get_invites(project_id)
457
for invite in invites_response.invites:
458
print(f"Pending invite: {invite.email} ({invite.scope}) - sent {invite.sent}")
459
460
# Update member scope
461
member_id = "member-id"
462
scope_options = ScopeOptions(scope="admin")
463
scope_response = client.manage.update_member_scope(project_id, member_id, scope_options)
464
print(f"Scope updated: {scope_response.message}")
465
```
466
467
### Usage Tracking
468
469
```python
470
from deepgram import DeepgramClient, UsageRequestOptions, UsageSummaryOptions
471
from datetime import datetime, timedelta
472
473
client = DeepgramClient(api_key="your-api-key")
474
project_id = "your-project-id"
475
476
# Get usage for the last 30 days
477
end_date = datetime.now()
478
start_date = end_date - timedelta(days=30)
479
480
usage_options = UsageRequestOptions(
481
start=start_date.isoformat(),
482
end=end_date.isoformat(),
483
limit=100
484
)
485
486
usage_response = client.manage.get_usage(project_id, usage_options)
487
print(f"Usage period: {usage_response.start} to {usage_response.end}")
488
print(f"Found {len(usage_response.results)} usage records")
489
490
# Get usage summary
491
summary_options = UsageSummaryOptions(
492
start=start_date.isoformat(),
493
end=end_date.isoformat()
494
)
495
496
summary_response = client.manage.get_usage_summary(project_id, summary_options)
497
for result in summary_response.results:
498
print(f"Period: {result.start} to {result.end}")
499
print(f" Hours: {result.hours:.2f}")
500
print(f" Requests: {result.requests}")
501
print(f" Tokens: {result.tokens}")
502
503
# Get available usage fields
504
fields_response = client.manage.get_usage_fields(project_id, usage_options)
505
print(f"STT requests this period: {fields_response.stt.requests}")
506
print(f"STT hours this period: {fields_response.stt.hours}")
507
print(f"TTS requests this period: {fields_response.tts.requests}")
508
print(f"TTS characters this period: {fields_response.tts.characters}")
509
```
510
511
### Account Balances
512
513
```python
514
from deepgram import DeepgramClient
515
516
client = DeepgramClient(api_key="your-api-key")
517
project_id = "your-project-id"
518
519
# Get account balances
520
balances_response = client.manage.get_balances(project_id)
521
522
print("Account Balances:")
523
for balance in balances_response.balances:
524
print(f"- Balance ID: {balance.balance_id}")
525
print(f" Amount: {balance.amount} {balance.units}")
526
if balance.purchase:
527
print(f" Purchase: {balance.purchase}")
528
```
529
530
### Model Information
531
532
```python
533
from deepgram import DeepgramClient
534
535
client = DeepgramClient(api_key="your-api-key")
536
project_id = "your-project-id"
537
538
# Get available models
539
models_response = client.manage.get_models(project_id)
540
541
print("Speech-to-Text Models:")
542
for model in models_response.stt_models:
543
print(f"- {model.name} ({model.canonical_name})")
544
print(f" Architecture: {model.architecture}")
545
print(f" Version: {model.version}")
546
print(f" Batch: {model.batch}, Streaming: {model.streaming}")
547
if model.language:
548
print(f" Language: {model.language}")
549
550
print("\nText-to-Speech Models:")
551
for model in models_response.tts_models:
552
print(f"- {model.name} ({model.canonical_name})")
553
print(f" Architecture: {model.architecture}")
554
print(f" Version: {model.version}")
555
```
556
557
### Async Management Operations
558
559
```python
560
import asyncio
561
from deepgram import DeepgramClient
562
563
async def async_management_example():
564
client = DeepgramClient(api_key="your-api-key")
565
project_id = "your-project-id"
566
567
# Perform multiple operations concurrently
568
tasks = [
569
client.manage.asyncmanage.get_projects(),
570
client.manage.asyncmanage.get_keys(project_id),
571
client.manage.asyncmanage.get_members(project_id),
572
client.manage.asyncmanage.get_balances(project_id)
573
]
574
575
projects, keys, members, balances = await asyncio.gather(*tasks)
576
577
print(f"Projects: {len(projects.projects)}")
578
print(f"API Keys: {len(keys.api_keys)}")
579
print(f"Team Members: {len(members.members)}")
580
print(f"Account Balances: {len(balances.balances)}")
581
582
# Run async example
583
asyncio.run(async_management_example())
584
```
585
586
### Error Handling
587
588
```python
589
from deepgram import DeepgramClient, DeepgramApiError, KeyOptions
590
591
client = DeepgramClient(api_key="your-api-key")
592
project_id = "your-project-id"
593
594
try:
595
# Attempt to create a key with invalid options
596
key_options = KeyOptions(
597
comment="Test key",
598
scopes=["invalid:scope"] # This may cause an error
599
)
600
601
response = client.manage.create_key(project_id, key_options)
602
print(f"Key created: {response.api_key.api_key_id}")
603
604
except DeepgramApiError as e:
605
print(f"API Error: {e}")
606
print("Please check your project ID and key permissions")
607
except Exception as e:
608
print(f"Unexpected error: {e}")
609
```