@deepgram/sdk 4.3.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +183 -39
  2. package/dist/main/lib/fetch.d.ts +7 -1
  3. package/dist/main/lib/fetch.d.ts.map +1 -1
  4. package/dist/main/lib/fetch.js +2 -2
  5. package/dist/main/lib/fetch.js.map +1 -1
  6. package/dist/main/lib/types/AgentLiveSchema.d.ts +1 -0
  7. package/dist/main/lib/types/AgentLiveSchema.d.ts.map +1 -1
  8. package/dist/main/lib/types/DeepgramClientOptions.d.ts +5 -2
  9. package/dist/main/lib/types/DeepgramClientOptions.d.ts.map +1 -1
  10. package/dist/main/lib/version.d.ts +1 -1
  11. package/dist/main/lib/version.js +1 -1
  12. package/dist/main/packages/AbstractClient.d.ts +2 -1
  13. package/dist/main/packages/AbstractClient.d.ts.map +1 -1
  14. package/dist/main/packages/AbstractClient.js +19 -8
  15. package/dist/main/packages/AbstractClient.js.map +1 -1
  16. package/dist/main/packages/AbstractLiveClient.d.ts.map +1 -1
  17. package/dist/main/packages/AbstractLiveClient.js +13 -5
  18. package/dist/main/packages/AbstractLiveClient.js.map +1 -1
  19. package/dist/main/packages/AbstractRestClient.d.ts.map +1 -1
  20. package/dist/main/packages/AbstractRestClient.js +2 -1
  21. package/dist/main/packages/AbstractRestClient.js.map +1 -1
  22. package/dist/module/lib/fetch.d.ts +7 -1
  23. package/dist/module/lib/fetch.d.ts.map +1 -1
  24. package/dist/module/lib/fetch.js +2 -2
  25. package/dist/module/lib/fetch.js.map +1 -1
  26. package/dist/module/lib/types/AgentLiveSchema.d.ts +1 -0
  27. package/dist/module/lib/types/AgentLiveSchema.d.ts.map +1 -1
  28. package/dist/module/lib/types/DeepgramClientOptions.d.ts +5 -2
  29. package/dist/module/lib/types/DeepgramClientOptions.d.ts.map +1 -1
  30. package/dist/module/lib/version.d.ts +1 -1
  31. package/dist/module/lib/version.js +1 -1
  32. package/dist/module/packages/AbstractClient.d.ts +2 -1
  33. package/dist/module/packages/AbstractClient.d.ts.map +1 -1
  34. package/dist/module/packages/AbstractClient.js +19 -8
  35. package/dist/module/packages/AbstractClient.js.map +1 -1
  36. package/dist/module/packages/AbstractLiveClient.d.ts.map +1 -1
  37. package/dist/module/packages/AbstractLiveClient.js +13 -5
  38. package/dist/module/packages/AbstractLiveClient.js.map +1 -1
  39. package/dist/module/packages/AbstractRestClient.d.ts.map +1 -1
  40. package/dist/module/packages/AbstractRestClient.js +2 -1
  41. package/dist/module/packages/AbstractRestClient.js.map +1 -1
  42. package/dist/umd/deepgram.js +1 -1
  43. package/package.json +1 -1
  44. package/src/lib/fetch.ts +12 -2
  45. package/src/lib/types/AgentLiveSchema.ts +1 -0
  46. package/src/lib/types/DeepgramClientOptions.ts +5 -2
  47. package/src/lib/version.ts +1 -1
  48. package/src/packages/AbstractClient.ts +18 -10
  49. package/src/packages/AbstractLiveClient.ts +17 -5
  50. package/src/packages/AbstractRestClient.ts +3 -1
package/README.md CHANGED
@@ -4,9 +4,11 @@
4
4
 
5
5
  Official JavaScript SDK for [Deepgram](https://www.deepgram.com/). Power your apps with world-class speech and Language AI models.
6
6
 
7
+ - [Documentation](#documentation)
7
8
  - [Migrating from earlier versions](#migrating-from-earlier-versions)
8
9
  - [V2 to V3](#v2-to-v3)
9
10
  - [V3.\* to V3.4](#v3-to-v34)
11
+ - [V3.\* to V4](#v3-to-v4)
10
12
  - [Installation](#installation)
11
13
  - [UMD](#umd)
12
14
  - [ESM](#esm)
@@ -23,17 +25,19 @@ Official JavaScript SDK for [Deepgram](https://www.deepgram.com/). Power your ap
23
25
  - [Override fetch transmitter](#override-fetch-transmitter)
24
26
  - [Proxy requests in the browser](#proxy-requests-in-the-browser)
25
27
  - [Set custom headers for fetch](#set-custom-headers-for-fetch)
26
- - [Transcription (Synchronous)](#transcription-synchronous)
28
+ - [Pre-Recorded (Synchronous)](#pre-recorded-synchronous)
27
29
  - [Remote Files](#remote-files)
28
30
  - [Local Files](#local-files)
29
- - [Transcription (Asynchronous / Callbacks)](#transcription-asynchronous--callbacks)
31
+ - [Browser](#browser)
32
+ - [Pre-Recorded (Asynchronous / Callbacks)](#pre-recorded-asynchronous--callbacks)
30
33
  - [Remote Files](#remote-files-1)
31
34
  - [Local Files](#local-files-1)
32
- - [Transcription (Live / Streaming)](#transcription-live--streaming)
33
- - [Live Audio](#live-audio)
35
+ - [Browser](#browser-1)
36
+ - [Streaming Audio](#streaming-audio)
34
37
  - [Transcribing to captions](#transcribing-to-captions)
35
38
  - [Voice Agent](#voice-agent)
36
- - [Text to Speech](#text-to-speech)
39
+ - [Text to Speech Rest](#text-to-speech-rest)
40
+ - [Text to Speech Streaming](#text-to-speech-streaming)
37
41
  - [Text Intelligence](#text-intelligence)
38
42
  - [Authentication](#authentication)
39
43
  - [Get Token Details](#get-token-details)
@@ -67,7 +71,7 @@ Official JavaScript SDK for [Deepgram](https://www.deepgram.com/). Power your ap
67
71
  - [Get All Balances](#get-all-balances)
68
72
  - [Get Balance](#get-balance)
69
73
  - [Models](#models)
70
- - [Get All Models](#get-all-models)
74
+ - [Get All Project Models](#get-all-project-models)
71
75
  - [Get Model](#get-model)
72
76
  - [On-Prem APIs](#on-prem-apis)
73
77
  - [List On-Prem credentials](#list-on-prem-credentials)
@@ -79,6 +83,10 @@ Official JavaScript SDK for [Deepgram](https://www.deepgram.com/). Power your ap
79
83
  - [Debugging and making changes locally](#debugging-and-making-changes-locally)
80
84
  - [Getting Help](#getting-help)
81
85
 
86
+ ## Documentation
87
+
88
+ You can learn more about the Deepgram API at [developers.deepgram.com](https://developers.deepgram.com/docs).
89
+
82
90
  ## Migrating from earlier versions
83
91
 
84
92
  ### V2 to V3
@@ -89,7 +97,9 @@ We have published [a migration guide on our docs](https://developers.deepgram.co
89
97
 
90
98
  We recommend using only documented interfaces, as we strictly follow semantic versioning (semver) and breaking changes may occur for undocumented interfaces. To ensure compatibility, consider pinning your versions if you need to use undocumented interfaces.
91
99
 
92
- The Agent interfaces have been updated to use the new Voice Agent V1 API.
100
+ ### V3.\* to V4
101
+
102
+ The Voice Agent interfaces have been updated to use the new Voice Agent V1 API. Please refer to our [Documentation](https://developers.deepgram.com/docs/voice-agent-v1-migration) on Migration to new V1 Agent API.
93
103
 
94
104
  ## Installation
95
105
 
@@ -143,6 +153,8 @@ You can now use type="module" `<script>`s to import deepgram from CDNs, like:
143
153
 
144
154
  ## Initialization
145
155
 
156
+ All of the examples below will require createClient.
157
+
146
158
  ```js
147
159
  import { createClient } from "@deepgram/sdk";
148
160
  // - or -
@@ -270,10 +282,12 @@ const deepgram = createClient("proxy", {
270
282
  });
271
283
  ```
272
284
 
273
- ## Transcription (Synchronous)
285
+ ## Pre-Recorded (Synchronous)
274
286
 
275
287
  ### Remote Files
276
288
 
289
+ Transcribe audio from a URL.
290
+
277
291
  ```js
278
292
  const { result, error } = await deepgram.listen.prerecorded.transcribeUrl(
279
293
  {
@@ -285,10 +299,12 @@ const { result, error } = await deepgram.listen.prerecorded.transcribeUrl(
285
299
  );
286
300
  ```
287
301
 
288
- [See our API reference for more info](https://developers.deepgram.com/reference/pre-recorded).
302
+ [See our API reference for more info](https://developers.deepgram.com/reference/speech-to-text-api/listen).
289
303
 
290
304
  ### Local Files
291
305
 
306
+ Transcribe audio from a file.
307
+
292
308
  ```js
293
309
  const { result, error } = await deepgram.listen.prerecorded.transcribeFile(
294
310
  fs.createReadStream("./examples/spacewalk.wav"),
@@ -309,12 +325,33 @@ const { result, error } = await deepgram.listen.prerecorded.transcribeFile(
309
325
  );
310
326
  ```
311
327
 
312
- [See our API reference for more info](https://developers.deepgram.com/reference/pre-recorded).
328
+ [See our API reference for more info](https://developers.deepgram.com/reference/speech-to-text-api/listen).
329
+
330
+ ### Browser
313
331
 
314
- ## Transcription (Asynchronous / Callbacks)
332
+ Transcribe audio from a file in the browser.
333
+
334
+ ```js
335
+ const transcribeFile = async () => {
336
+ const { result, error } = await _deepgram.listen.prerecorded.transcribeFile(
337
+ fs.readFileSync("./examples/nasa.mp4"),
338
+ {
339
+ model: "nova",
340
+ }
341
+ );
342
+ };
343
+ ```
344
+
345
+ [See our API reference for more info](https://developers.deepgram.com/reference/speech-to-text-api/listen).
346
+
347
+ [See our Example for more info](./examples/browser-prerecorded/index.html).
348
+
349
+ ## Pre-Recorded (Asynchronous / Callbacks)
315
350
 
316
351
  ### Remote Files
317
352
 
353
+ Transcribe audio from a URL.
354
+
318
355
  ```js
319
356
  import { CallbackUrl } from "@deepgram/sdk";
320
357
 
@@ -329,10 +366,14 @@ const { result, error } = await deepgram.listen.prerecorded.transcribeUrlCallbac
329
366
  );
330
367
  ```
331
368
 
332
- [See our API reference for more info](https://developers.deepgram.com/reference/pre-recorded).
369
+ [See our API reference for more info](https://developers.deepgram.com/reference/speech-to-text-api/listen).
370
+
371
+ [See our Example for more info](./examples/node-prerecorded/index.js).
333
372
 
334
373
  ### Local Files
335
374
 
375
+ Transcribe audio from a file.
376
+
336
377
  ```js
337
378
  import { CallbackUrl } from "@deepgram/sdk";
338
379
 
@@ -359,11 +400,34 @@ const { result, error } = await deepgram.listen.prerecorded.transcribeFileCallba
359
400
  );
360
401
  ```
361
402
 
362
- [See our API reference for more info](https://developers.deepgram.com/reference/pre-recorded).
403
+ [See our API reference for more info](https://developers.deepgram.com/reference/speech-to-text-api/listen).
363
404
 
364
- ## Transcription (Live / Streaming)
405
+ ### Browser
365
406
 
366
- ### Live Audio
407
+ Transcribe audio from a URL in the browser.
408
+
409
+ ```js
410
+ // browser code
411
+ const transcribeUrl = async () => {
412
+ const { result, error } = await _deepgram.listen.prerecorded.transcribeUrl(
413
+ {
414
+ url: "https://dpgr.am/spacewalk.wav",
415
+ },
416
+ {
417
+ model: "nova",
418
+ }
419
+ );
420
+ };
421
+ // browser code
422
+ ```
423
+
424
+ [See our API reference for more info](https://developers.deepgram.com/reference/speech-to-text-api/listen).
425
+
426
+ [See our Example for more info](./examples/browser-prerecorded/index.html).
427
+
428
+ ## Streaming Audio
429
+
430
+ Transcribe streaming audio.
367
431
 
368
432
  ```js
369
433
  const dgConnection = deepgram.listen.live({ model: "nova" });
@@ -379,12 +443,38 @@ dgConnection.on(LiveTranscriptionEvents.Open, () => {
379
443
  });
380
444
  ```
381
445
 
382
- To see an example, [check out our Node.js example](https://github.com/deepgram-devs/node-live-example) or our [Browser example](https://github.com/deepgram-devs/js-live-example).
446
+ [See our API reference for more info](https://developers.deepgram.com/reference/speech-to-text-api/listen-streaming).
447
+
448
+ [See our Example for more info](https://github.com/deepgram-devs/node-live-example).
449
+
450
+ ### Browser
451
+
452
+ Transcribe streaming audio in the browser.
453
+
454
+ ```js
455
+ // browser code
456
+
457
+ const connection = deepgram.listen.live({
458
+ model: "nova-3",
459
+ language: "en-US",
460
+ smart_format: true,
461
+ interim_results: true,
462
+ utterance_end_ms: 1000,
463
+ vad_events: true,
464
+ endpointing: 300,
465
+ });
466
+
467
+ // browser code
468
+ ```
469
+
470
+ [See our API reference for more info](https://developers.deepgram.com/reference/speech-to-text-api/listen-streaming).
383
471
 
384
- [See our API reference for more info](https://developers.deepgram.com/reference/streaming).
472
+ [See Our Example for more info](https://github.com/deepgram-devs/js-live-example).
385
473
 
386
474
  ## Transcribing to captions
387
475
 
476
+ Transcribe audio to captions.
477
+
388
478
  ```js
389
479
  import { webvtt /* , srt */ } from "@deepgram/captions";
390
480
 
@@ -405,6 +495,8 @@ const vttOutput = webvtt(result);
405
495
 
406
496
  ## Voice Agent
407
497
 
498
+ Configure a Voice Agent.
499
+
408
500
  ```js
409
501
  import { createClient } from "@deepgram/sdk";
410
502
  import { AgentEvents } from "@deepgram/sdk";
@@ -423,27 +515,36 @@ agent.on(AgentEvents.Open, () => {
423
515
  audio: {
424
516
  input: {
425
517
  encoding: "linear16",
426
- sampleRate: 16000,
518
+ sampleRate: 24000,
427
519
  },
428
520
  output: {
429
- encoding: "linear16",
430
- container: "wav",
431
- sampleRate: 24000,
521
+ encoding: "mp3",
522
+ sample_rate: 24000,
523
+ bitrate: 48000,
524
+ container: "none",
432
525
  },
433
526
  },
434
527
  agent: {
528
+ language: "en",
435
529
  listen: {
436
- model: "nova-3",
437
- },
438
- speak: {
439
- model: "aura-2-thalia-en",
530
+ provider: {
531
+ type: "deepgram",
532
+ model: "nova-3",
533
+ },
440
534
  },
441
535
  think: {
442
536
  provider: {
443
- type: "anthropic",
537
+ type: "open_ai",
538
+ model: "gpt-4-mini",
539
+ temperature: 0.7,
540
+ },
541
+ prompt: "You are a helpful AI assistant. Keep responses brief and friendly.",
542
+ },
543
+ speak: {
544
+ provider: {
545
+ type: "deepgram",
546
+ model: "aura-2-thalia-en",
444
547
  },
445
- model: "claude-3-haiku-20240307",
446
- instructions: "You are a helpful AI assistant. Keep responses brief and friendly.",
447
548
  },
448
549
  },
449
550
  });
@@ -496,17 +597,23 @@ For a complete implementation, you would need to:
496
597
  3. Handle any function calls if your agent uses them
497
598
  4. Add proper error handling and connection management
498
599
 
499
- [See our API reference for more info](https://developers.deepgram.com/reference/voice-agent-api/agent)
600
+ [See our API reference for more info](https://developers.deepgram.com/reference/voice-agent-api/agent).
601
+
602
+ [See our Example for more info](./examples/node-agent-live/index.js).
500
603
 
501
- ## Text to Speech
604
+ ## Text to Speech Rest
502
605
 
503
- ### Rest
606
+ Convert text into speech using the REST API.
504
607
 
505
608
  ```js
506
609
  const { result } = await deepgram.speak.request({ text }, { model: "aura-2-thalia-en" });
507
610
  ```
508
611
 
509
- ### Websocket
612
+ [See our API reference for more info](https://developers.deepgram.com/reference/text-to-speech-api/speak).
613
+
614
+ [See our Example for info](./examples/node-speak/index.js)
615
+
616
+ ## Text to Speech Streaming
510
617
 
511
618
  ```js
512
619
  const dgConnection = deepgram.speak.live({ model: "aura-2-thalia-en" });
@@ -526,10 +633,14 @@ dgConnection.on(LiveTTSEvents.Open, () => {
526
633
  });
527
634
  ```
528
635
 
529
- [See our API reference for more info](https://developers.deepgram.com/reference/text-to-speech-api).
636
+ [See our API reference for more info](https://developers.deepgram.com/reference/text-to-speech-api/speak-streaming).
637
+
638
+ [See our Example for info](./examples/node-speak-live/index.js).
530
639
 
531
640
  ## Text Intelligence
532
641
 
642
+ Analyze Text.
643
+
533
644
  ```js
534
645
  const text = `The history of the phrase 'The quick brown fox jumps over the
535
646
  lazy dog'. The earliest known appearance of the phrase was in The Boston
@@ -550,7 +661,9 @@ const { result, error } = await deepgram.read.analyzeText(
550
661
  );
551
662
  ```
552
663
 
553
- [See our API reference for more info](https://developers.deepgram.com/reference/analyze-text).
664
+ [See our API reference for more info](https://developers.deepgram.com/reference/text-intelligence-api/text-read).
665
+
666
+ [See our Example for info](./examples/node-read/index.js).
554
667
 
555
668
  ## Authentication
556
669
 
@@ -564,6 +677,19 @@ const { result, error } = await deepgram.manage.getTokenDetails();
564
677
 
565
678
  [See our API reference for more info](https://developers.deepgram.com/reference/authentication)
566
679
 
680
+ ### Grant Token
681
+
682
+ Creates a temporary token with a 30-second TTL.
683
+
684
+ ```js
685
+ const { result, error } = await deepgram.auth.grantToken();
686
+ const deepgramWithToken = createClient({ accessToken: result.access_token });
687
+ ```
688
+
689
+ This example shows how to use the temporary token to authenticate a client instance. Note that you _must_ pass an `accessToken` property to use a temporary token. Passing the token as a raw string will error, as the SDK will treat it as an API key and use the incorrect header prefix.
690
+
691
+ [See our API reference for more info](https://developers.deepgram.com/reference/token-based-auth-api/grant-token).
692
+
567
693
  ## Projects
568
694
 
569
695
  ### Get Projects
@@ -596,7 +722,7 @@ const { result, error } = await deepgram.manage.updateProject(projectId, options
596
722
 
597
723
  [See our API reference for more info](https://developers.deepgram.com/reference/update-project).
598
724
 
599
- ## Delete Project
725
+ ### Delete Project
600
726
 
601
727
  Delete a project.
602
728
 
@@ -778,6 +904,16 @@ const { result, error } = await deepgram.manage.getProjectUsageFields(projectId,
778
904
 
779
905
  [See our API reference for more info](https://developers.deepgram.com/reference/get-fields).
780
906
 
907
+ ### Summarize Usage
908
+
909
+ `Deprecated` Retrieves the usage for a specific project. Use Get Project Usage Breakdown for a more comprehensive usage summary.
910
+
911
+ ```js
912
+ const { result, error } = await deepgram.manage.getProjectUsage(projectId, options);
913
+ ```
914
+
915
+ [See our API reference for more info](https://developers.deepgram.com/reference/management-api/usage/get).
916
+
781
917
  ## Billing
782
918
 
783
919
  ### Get All Balances
@@ -802,7 +938,7 @@ const { result, error } = await deepgram.manage.getProjectBalance(projectId, bal
802
938
 
803
939
  ## Models
804
940
 
805
- ### Get All Models
941
+ ### Get All Project Models
806
942
 
807
943
  Retrieves all models available for a given project.
808
944
 
@@ -810,7 +946,7 @@ Retrieves all models available for a given project.
810
946
  const { result, error } = await deepgram.manage.getAllModels(projectId, {});
811
947
  ```
812
948
 
813
- [See our API reference for more info](https://developers.deepgram.com/reference/management-api/models/list)
949
+ [See our API reference for more info](https://developers.deepgram.com/reference/management-api/projects/list-models).
814
950
 
815
951
  ### Get Model
816
952
 
@@ -826,6 +962,8 @@ const { result, error } = await deepgram.manage.getModel(projectId, modelId);
826
962
 
827
963
  ### List On-Prem credentials
828
964
 
965
+ Lists sets of distribution credentials for the specified project.
966
+
829
967
  ```js
830
968
  const { result, error } = await deepgram.onprem.listCredentials(projectId);
831
969
  ```
@@ -834,6 +972,8 @@ const { result, error } = await deepgram.onprem.listCredentials(projectId);
834
972
 
835
973
  ### Get On-Prem credentials
836
974
 
975
+ Returns a set of distribution credentials for the specified project.
976
+
837
977
  ```js
838
978
  const { result, error } = await deepgram.onprem.getCredentials(projectId, credentialId);
839
979
  ```
@@ -842,6 +982,8 @@ const { result, error } = await deepgram.onprem.getCredentials(projectId, creden
842
982
 
843
983
  ### Create On-Prem credentials
844
984
 
985
+ Creates a set of distribution credentials for the specified project.
986
+
845
987
  ```js
846
988
  const { result, error } = await deepgram.onprem.createCredentials(projectId, options);
847
989
  ```
@@ -850,6 +992,8 @@ const { result, error } = await deepgram.onprem.createCredentials(projectId, opt
850
992
 
851
993
  ### Delete On-Prem credentials
852
994
 
995
+ Deletes a set of distribution credentials for the specified project.
996
+
853
997
  ```js
854
998
  const { result, error } = await deepgram.onprem.deleteCredentials(projectId, credentialId);
855
999
  ```
@@ -858,9 +1002,9 @@ const { result, error } = await deepgram.onprem.deleteCredentials(projectId, cre
858
1002
 
859
1003
  ## Backwards Compatibility
860
1004
 
861
- Older SDK versions will receive Priority 1 (P1) bug support only. Security issues, both in our code and dependencies, are promptly addressed. Significant bugs without clear workarounds are also given priority attention.
1005
+ We follow semantic versioning (semver) to ensure a smooth upgrade experience. Within a major version (like 4._), we will maintain backward compatibility so your code will continue to work without breaking changes. When we release a new major version (like moving from 3._ to 4.\*), we may introduce breaking changes to improve the SDK. We'll always document these changes clearly in our release notes to help you upgrade smoothly.
862
1006
 
863
- We strictly follow semver, and will not introduce breaking changes to the publicly documented interfaces of the SDK. **Use internal and undocumented interfaces without pinning your version, at your own risk.**
1007
+ Older SDK versions will receive Priority 1 (P1) bug support only. Security issues, both in our code and dependencies, are promptly addressed. Significant bugs without clear workarounds are also given priority attention.
864
1008
 
865
1009
  ## Development and Contributing
866
1010
 
@@ -6,6 +6,11 @@ import type { Fetch } from "./types";
6
6
  * @returns A fetch function that can be used to make HTTP requests.
7
7
  */
8
8
  export declare const resolveFetch: (customFetch?: Fetch) => Fetch;
9
+ interface FetchWithAuthOptions {
10
+ apiKey?: string;
11
+ customFetch?: Fetch;
12
+ accessToken?: string;
13
+ }
9
14
  /**
10
15
  * Resolves a fetch function that includes an "Authorization" header with the provided API key.
11
16
  *
@@ -13,7 +18,7 @@ export declare const resolveFetch: (customFetch?: Fetch) => Fetch;
13
18
  * @param customFetch - An optional custom fetch function to use instead of the global fetch function.
14
19
  * @returns A fetch function that can be used to make HTTP requests with the provided API key in the "Authorization" header.
15
20
  */
16
- export declare const fetchWithAuth: (apiKey: string, customFetch?: Fetch) => Fetch;
21
+ export declare const fetchWithAuth: ({ apiKey, customFetch, accessToken, }: Readonly<FetchWithAuthOptions>) => Fetch;
17
22
  /**
18
23
  * Resolves the appropriate Response object to use, either the global Response object if available, or the Response object from the cross-fetch library if the global Response object is not available.
19
24
  *
@@ -25,4 +30,5 @@ export declare const resolveResponse: () => Promise<{
25
30
  error(): Response;
26
31
  redirect(url: string | URL, status?: number | undefined): Response;
27
32
  }>;
33
+ export {};
28
34
  //# sourceMappingURL=fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,iBAAkB,KAAK,KAAG,KAYlD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,WAAY,MAAM,gBAAgB,KAAK,KAAG,KAanE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;EAM3B,CAAC"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,iBAAkB,KAAK,KAAG,KAYlD,CAAC;AAEF,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,0CAIvB,SAAS,oBAAoB,CAAC,KAAG,KAanC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;EAM3B,CAAC"}
@@ -65,13 +65,13 @@ exports.resolveFetch = resolveFetch;
65
65
  * @param customFetch - An optional custom fetch function to use instead of the global fetch function.
66
66
  * @returns A fetch function that can be used to make HTTP requests with the provided API key in the "Authorization" header.
67
67
  */
68
- const fetchWithAuth = (apiKey, customFetch) => {
68
+ const fetchWithAuth = ({ apiKey, customFetch, accessToken, }) => {
69
69
  const fetch = (0, exports.resolveFetch)(customFetch);
70
70
  const HeadersConstructor = (0, helpers_1.resolveHeadersConstructor)();
71
71
  return (input, init) => __awaiter(void 0, void 0, void 0, function* () {
72
72
  const headers = new HeadersConstructor(init === null || init === void 0 ? void 0 : init.headers);
73
73
  if (!headers.has("Authorization")) {
74
- headers.set("Authorization", `Token ${apiKey}`);
74
+ headers.set("Authorization", accessToken ? `Bearer ${accessToken}` : `Token ${apiKey}`);
75
75
  }
76
76
  return fetch(input, Object.assign(Object.assign({}, init), { headers }));
77
77
  });
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAsD;AACtD,8DAAqC;AAGrC;;;;;GAKG;AACI,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAS,EAAE;IACzD,IAAI,MAAa,CAAC;IAElB,IAAI,WAAW,EAAE;QACf,MAAM,GAAG,WAAW,CAAC;KACtB;SAAM,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;QACvC,MAAM,GAAG,qBAA8B,CAAC;KACzC;SAAM;QACL,MAAM,GAAG,KAAK,CAAC;KAChB;IAED,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;AACtC,CAAC,CAAC;AAZW,QAAA,YAAY,gBAYvB;AAEF;;;;;;GAMG;AACI,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,WAAmB,EAAS,EAAE;IAC1E,MAAM,KAAK,GAAG,IAAA,oBAAY,EAAC,WAAW,CAAC,CAAC;IACxC,MAAM,kBAAkB,GAAG,IAAA,mCAAyB,GAAE,CAAC;IAEvD,OAAO,CAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IA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AAW,CAAC,CAAC;IACxC,MAAM,kBAAkB,GAAG,IAAA,mCAAyB,GAAE,CAAC;IAEvD,OAAO,CAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,CAAC,CAAC;QAEtD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;YACjC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,CAAC,UAAU,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;SACzF;QAED,OAAO,KAAK,CAAC,KAAK,kCAAO,IAAI,KAAE,OAAO,IAAG,CAAC;IAC5C,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,aAAa,iBAiBxB;AAEF;;;;GAIG;AACI,MAAM,eAAe,GAAG,GAAS,EAAE;IACxC,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;QACnC,OAAO,CAAC,wDAAa,aAAa,GAAC,CAAC,CAAC,QAAQ,CAAC;KAC/C;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AANW,QAAA,eAAe,mBAM1B"}
@@ -73,6 +73,7 @@ interface AgentLiveSchema extends Record<string, unknown> {
73
73
  };
74
74
  }[];
75
75
  prompt?: string;
76
+ context_length?: number | "max";
76
77
  };
77
78
  /**
78
79
  * Optional message the agent will say at the start of the connection.
@@ -1 +1 @@
1
- {"version":3,"file":"AgentLiveSchema.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/AgentLiveSchema.ts"],"names":[],"mappings":"AAAA,aAAK,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3D;;GAEG;AACH,UAAU,eAAgB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAA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C;SACH,CAAC;QACF;;WAEG;QACH,KAAK,CAAC,EAAE;YACN,QAAQ,EAAE,QAAQ,CAAC;YACnB;;eAEG;YACH,QAAQ,CAAC,EAAE;gBACT,GAAG,EAAE,MAAM,CAAC;gBACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;aAClC,CAAC;YACF,SAAS,CAAC,EAAE;gBACV,IAAI,CAAC,EAAE,MAAM,CAAC;gBACd,WAAW,CAAC,EAAE,MAAM,CAAC;gBACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBACrC,QAAQ,CAAC,EAAE;oBACT,GAAG,CAAC,EAAE,MAAM,CAAC;oBACb,MAAM,CAAC,EAAE,MAAM,CAAC;oBAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;iBAClC,CAAC;aACH,EAAE,CAAC;YACJ,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,cAAc,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;SACjC,CAAC;QACF;;WAEG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,YAAY,EAAE,eAAe,EAAE,CAAC"}
@@ -21,7 +21,8 @@ interface ITransport<C, O> {
21
21
  options?: O;
22
22
  }
23
23
  export declare type DefaultNamespaceOptions = {
24
- key: string;
24
+ key?: string | IKeyFactory;
25
+ accessToken?: string | IKeyFactory;
25
26
  fetch: {
26
27
  options: {
27
28
  url: TransportUrl;
@@ -34,7 +35,8 @@ export declare type DefaultNamespaceOptions = {
34
35
  };
35
36
  } & NamespaceOptions;
36
37
  export interface NamespaceOptions {
37
- key?: string;
38
+ key?: string | IKeyFactory;
39
+ accessToken?: string | IKeyFactory;
38
40
  fetch?: ITransport<IFetch, TransportFetchOptions>;
39
41
  websocket?: ITransport<IWebSocket, TransportWebSocketOptions>;
40
42
  }
@@ -56,6 +58,7 @@ export declare type DefaultClientOptions = {
56
58
  */
57
59
  export interface DeepgramClientOptions {
58
60
  key?: string | IKeyFactory;
61
+ accessToken?: string | IKeyFactory;
59
62
  global?: NamespaceOptions & {
60
63
  url?: string;
61
64
  headers?: {
@@ -1 +1 @@
1
- {"version":3,"file":"DeepgramClientOptions.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/DeepgramClientOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE9C,oBAAY,WAAW,GAAG,MAAM,MAAM,CAAC;AACvC,oBAAY,MAAM,GAAG,OAAO,KAAK,CAAC;AAClC,oBAAY,UAAU,GAAG,OAAO,SAAS,CAAC;AAE1C,UAAU,qBAAsB,SAAQ,gBAAgB,EAAE,YAAY;CAAG;AACzE,UAAU,yBAA0B,SAAQ,gBAAgB;IAC1D,gBAAgB,CAAC,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CAC7C;AAED,aAAK,YAAY,GAAG,MAAM,CAAC;AAE3B,UAAU,gBAAgB;IACxB,GAAG,CAAC,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE;QACN,GAAG,EAAE,YAAY,CAAC;KACnB,CAAC;CACH;AAED,UAAU,UAAU,CAAC,CAAC,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,OAAO,CAAC,EAAE,CAAC,CAAC;CACb;AAED,oBAAY,uBAAuB,GAAG;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE;QACL,OAAO,EAAE;YAAE,GAAG,EAAE,YAAY,CAAA;SAAE,CAAC;KAChC,CAAC;IACF,SAAS,EAAE;QACT,OAAO,EAAE;YAAE,GAAG,EAAE,YAAY,CAAA;SAAE,CAAC;KAChC,CAAC;CACH,GAAG,gBAAgB,CAAC;AAErB,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC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GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACnC,MAAM,CAAC,EAAE,gBAAgB,GAAG;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE;YAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAA;KAAE,CAAC;IACjF,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAEzB;;OAEG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB;;OAEG;IACH,wBAAwB,CAAC,EAAE,KAAK,CAAC;IAEjC;;OAEG;IACH,SAAS,CAAC,EAAE;QACV,GAAG,EAAE,IAAI,GAAG,MAAM,CAAC;KACpB,CAAC;CACH"}
@@ -1,2 +1,2 @@
1
- export declare const version = "4.3.0";
1
+ export declare const version = "4.5.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = "4.3.0";
4
+ exports.version = "4.5.0";
5
5
  //# sourceMappingURL=version.js.map
@@ -14,7 +14,8 @@ export declare const noop: () => void;
14
14
  */
15
15
  export declare abstract class AbstractClient extends EventEmitter {
16
16
  protected factory: Function | undefined;
17
- protected key: string;
17
+ protected key: string | undefined;
18
+ protected accessToken: string | undefined;
18
19
  protected options: DefaultClientOptions;
19
20
  namespace: string;
20
21
  version: string;
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractClient.d.ts","sourceRoot":"","sources":["../../../src/packages/AbstractClient.ts"],"names":[],"mappings":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O,MAAM,IAAI,YAAW,CAAC;AAE7B;;;;;;;;;GASG;AACH,8BAAsB,cAAe,SAAQ,YAAY;IACvD,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,SAAS,CAAa;IACpD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAa;IAC9C,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAa;IACtD,SAAS,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACjC,SAAS,EAAE,MAAM,CAAY;IAC7B,OAAO,EAAE,MAAM,CAAQ;IACvB,OAAO,EAAE,MAAM,CAAe;IAC9B,MAAM,EAAE,QAAQ,CAAQ;IAE/B;;;;;;;;;OASG;gBACS,OAAO,EAAE,qBAAqB;IAwC1C;;;;;OAKG;IACI,CAAC,CAAC,OAAO,GAAE,MAAa,GAAG,IAAI;IAMtC;;;;;;OAMG;IACH,IAAI,gBAAgB,IAAI,uBAAuB,CAU9C;IAED;;;;;;;OAOG;IACI,aAAa,CAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAA8B,EAC7D,oBAAoB,CAAC,EAAE;QACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,GACA,GAAG;IA4BN;;;;OAIG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;CAGjD"}
@@ -31,25 +31,36 @@ class AbstractClient extends events_1.EventEmitter {
31
31
  constructor(options) {
32
32
  super();
33
33
  this.factory = undefined;
34
+ this.key = undefined;
35
+ this.accessToken = undefined;
34
36
  this.namespace = "global";
35
37
  this.version = "v1";
36
38
  this.baseUrl = constants_1.DEFAULT_URL;
37
39
  this.logger = exports.noop;
38
- let key;
40
+ // run the factory for the access token if it's a function
41
+ if (typeof options.accessToken === "function") {
42
+ this.factory = options.accessToken;
43
+ this.accessToken = this.factory();
44
+ }
45
+ else {
46
+ this.accessToken = options.accessToken;
47
+ }
48
+ // run the factory for the key if it's a function
39
49
  if (typeof options.key === "function") {
40
50
  this.factory = options.key;
41
- key = this.factory();
51
+ this.key = this.factory();
42
52
  }
43
53
  else {
44
- key = options.key;
54
+ this.key = options.key;
45
55
  }
46
- if (!key) {
47
- key = process.env.DEEPGRAM_API_KEY;
56
+ // if we still have neither, try to use the DEEPGRAM_API_KEY environment variable
57
+ if (!this.key && !this.accessToken) {
58
+ this.key = process.env.DEEPGRAM_API_KEY;
48
59
  }
49
- if (!key) {
50
- throw new errors_1.DeepgramError("A deepgram API key is required.");
60
+ // if we STILL have neither, throw an error
61
+ if (!this.key && !this.accessToken) {
62
+ throw new errors_1.DeepgramError("A deepgram API key or temporary auth token is required.");
51
63
  }
52
- this.key = key;
53
64
  options = (0, helpers_1.convertLegacyOptions)(options);
54
65
  /**
55
66
  * Apply default options.