chub-dev 0.1.0 → 0.1.2-beta.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 (139) hide show
  1. package/README.md +55 -0
  2. package/bin/chub-mcp +2 -0
  3. package/dist/airtable/docs/database/javascript/DOC.md +1437 -0
  4. package/dist/airtable/docs/database/python/DOC.md +1735 -0
  5. package/dist/amplitude/docs/analytics/javascript/DOC.md +1282 -0
  6. package/dist/amplitude/docs/analytics/python/DOC.md +1199 -0
  7. package/dist/anthropic/docs/claude-api/javascript/DOC.md +503 -0
  8. package/dist/anthropic/docs/claude-api/python/DOC.md +389 -0
  9. package/dist/asana/docs/tasks/DOC.md +1396 -0
  10. package/dist/assemblyai/docs/transcription/DOC.md +1043 -0
  11. package/dist/atlassian/docs/confluence/javascript/DOC.md +1347 -0
  12. package/dist/atlassian/docs/confluence/python/DOC.md +1604 -0
  13. package/dist/auth0/docs/identity/javascript/DOC.md +968 -0
  14. package/dist/auth0/docs/identity/python/DOC.md +1199 -0
  15. package/dist/aws/docs/s3/javascript/DOC.md +1773 -0
  16. package/dist/aws/docs/s3/python/DOC.md +1807 -0
  17. package/dist/binance/docs/trading/javascript/DOC.md +1315 -0
  18. package/dist/binance/docs/trading/python/DOC.md +1454 -0
  19. package/dist/braintree/docs/gateway/javascript/DOC.md +1278 -0
  20. package/dist/braintree/docs/gateway/python/DOC.md +1179 -0
  21. package/dist/chromadb/docs/embeddings-db/javascript/DOC.md +1263 -0
  22. package/dist/chromadb/docs/embeddings-db/python/DOC.md +1707 -0
  23. package/dist/clerk/docs/auth/javascript/DOC.md +1220 -0
  24. package/dist/clerk/docs/auth/python/DOC.md +274 -0
  25. package/dist/cloudflare/docs/workers/javascript/DOC.md +918 -0
  26. package/dist/cloudflare/docs/workers/python/DOC.md +994 -0
  27. package/dist/cockroachdb/docs/distributed-db/DOC.md +1500 -0
  28. package/dist/cohere/docs/llm/DOC.md +1335 -0
  29. package/dist/datadog/docs/monitoring/javascript/DOC.md +1740 -0
  30. package/dist/datadog/docs/monitoring/python/DOC.md +1815 -0
  31. package/dist/deepgram/docs/speech/javascript/DOC.md +885 -0
  32. package/dist/deepgram/docs/speech/python/DOC.md +685 -0
  33. package/dist/deepl/docs/translation/javascript/DOC.md +887 -0
  34. package/dist/deepl/docs/translation/python/DOC.md +944 -0
  35. package/dist/deepseek/docs/llm/DOC.md +1220 -0
  36. package/dist/directus/docs/headless-cms/javascript/DOC.md +1128 -0
  37. package/dist/directus/docs/headless-cms/python/DOC.md +1276 -0
  38. package/dist/discord/docs/bot/javascript/DOC.md +1090 -0
  39. package/dist/discord/docs/bot/python/DOC.md +1130 -0
  40. package/dist/elasticsearch/docs/search/DOC.md +1634 -0
  41. package/dist/elevenlabs/docs/text-to-speech/javascript/DOC.md +336 -0
  42. package/dist/elevenlabs/docs/text-to-speech/python/DOC.md +552 -0
  43. package/dist/firebase/docs/auth/DOC.md +1015 -0
  44. package/dist/gemini/docs/genai/javascript/DOC.md +691 -0
  45. package/dist/gemini/docs/genai/python/DOC.md +555 -0
  46. package/dist/github/docs/octokit/DOC.md +1560 -0
  47. package/dist/google/docs/bigquery/javascript/DOC.md +1688 -0
  48. package/dist/google/docs/bigquery/python/DOC.md +1503 -0
  49. package/dist/hubspot/docs/crm/javascript/DOC.md +1805 -0
  50. package/dist/hubspot/docs/crm/python/DOC.md +2033 -0
  51. package/dist/huggingface/docs/transformers/DOC.md +948 -0
  52. package/dist/intercom/docs/messaging/javascript/DOC.md +1844 -0
  53. package/dist/intercom/docs/messaging/python/DOC.md +1797 -0
  54. package/dist/jira/docs/issues/javascript/DOC.md +1420 -0
  55. package/dist/jira/docs/issues/python/DOC.md +1492 -0
  56. package/dist/kafka/docs/streaming/javascript/DOC.md +1671 -0
  57. package/dist/kafka/docs/streaming/python/DOC.md +1464 -0
  58. package/dist/landingai-ade/docs/api/DOC.md +620 -0
  59. package/dist/landingai-ade/docs/sdk/python/DOC.md +489 -0
  60. package/dist/landingai-ade/docs/sdk/typescript/DOC.md +542 -0
  61. package/dist/landingai-ade/skills/SKILL.md +489 -0
  62. package/dist/launchdarkly/docs/feature-flags/javascript/DOC.md +1191 -0
  63. package/dist/launchdarkly/docs/feature-flags/python/DOC.md +1671 -0
  64. package/dist/linear/docs/tracker/DOC.md +1554 -0
  65. package/dist/livekit/docs/realtime/javascript/DOC.md +303 -0
  66. package/dist/livekit/docs/realtime/python/DOC.md +163 -0
  67. package/dist/mailchimp/docs/marketing/DOC.md +1420 -0
  68. package/dist/meilisearch/docs/search/DOC.md +1241 -0
  69. package/dist/microsoft/docs/onedrive/javascript/DOC.md +1421 -0
  70. package/dist/microsoft/docs/onedrive/python/DOC.md +1549 -0
  71. package/dist/mongodb/docs/atlas/DOC.md +2041 -0
  72. package/dist/notion/docs/workspace-api/javascript/DOC.md +1435 -0
  73. package/dist/notion/docs/workspace-api/python/DOC.md +1400 -0
  74. package/dist/okta/docs/identity/javascript/DOC.md +1171 -0
  75. package/dist/okta/docs/identity/python/DOC.md +1401 -0
  76. package/dist/openai/docs/chat/javascript/DOC.md +407 -0
  77. package/dist/openai/docs/chat/python/DOC.md +568 -0
  78. package/dist/paypal/docs/checkout/DOC.md +278 -0
  79. package/dist/pinecone/docs/sdk/javascript/DOC.md +984 -0
  80. package/dist/pinecone/docs/sdk/python/DOC.md +1395 -0
  81. package/dist/plaid/docs/banking/javascript/DOC.md +1163 -0
  82. package/dist/plaid/docs/banking/python/DOC.md +1203 -0
  83. package/dist/playwright-community/skills/login-flows/SKILL.md +108 -0
  84. package/dist/postmark/docs/transactional-email/DOC.md +1168 -0
  85. package/dist/prisma/docs/orm/javascript/DOC.md +1419 -0
  86. package/dist/prisma/docs/orm/python/DOC.md +1317 -0
  87. package/dist/qdrant/docs/vector-search/javascript/DOC.md +1221 -0
  88. package/dist/qdrant/docs/vector-search/python/DOC.md +1653 -0
  89. package/dist/rabbitmq/docs/message-queue/javascript/DOC.md +1193 -0
  90. package/dist/rabbitmq/docs/message-queue/python/DOC.md +1243 -0
  91. package/dist/razorpay/docs/payments/javascript/DOC.md +1219 -0
  92. package/dist/razorpay/docs/payments/python/DOC.md +1330 -0
  93. package/dist/redis/docs/key-value/javascript/DOC.md +1851 -0
  94. package/dist/redis/docs/key-value/python/DOC.md +2054 -0
  95. package/dist/registry.json +2817 -0
  96. package/dist/replicate/docs/model-hosting/DOC.md +1318 -0
  97. package/dist/resend/docs/email/DOC.md +1271 -0
  98. package/dist/salesforce/docs/crm/javascript/DOC.md +1241 -0
  99. package/dist/salesforce/docs/crm/python/DOC.md +1183 -0
  100. package/dist/search-index.json +1 -0
  101. package/dist/sendgrid/docs/email-api/javascript/DOC.md +371 -0
  102. package/dist/sendgrid/docs/email-api/python/DOC.md +656 -0
  103. package/dist/sentry/docs/error-tracking/javascript/DOC.md +1073 -0
  104. package/dist/sentry/docs/error-tracking/python/DOC.md +1309 -0
  105. package/dist/shopify/docs/storefront/DOC.md +457 -0
  106. package/dist/slack/docs/workspace/javascript/DOC.md +933 -0
  107. package/dist/slack/docs/workspace/python/DOC.md +271 -0
  108. package/dist/square/docs/payments/javascript/DOC.md +1855 -0
  109. package/dist/square/docs/payments/python/DOC.md +1728 -0
  110. package/dist/stripe/docs/api/DOC.md +1727 -0
  111. package/dist/stripe/docs/payments/DOC.md +1726 -0
  112. package/dist/stytch/docs/auth/javascript/DOC.md +1813 -0
  113. package/dist/stytch/docs/auth/python/DOC.md +1962 -0
  114. package/dist/supabase/docs/client/DOC.md +1606 -0
  115. package/dist/twilio/docs/messaging/python/DOC.md +469 -0
  116. package/dist/twilio/docs/messaging/typescript/DOC.md +946 -0
  117. package/dist/vercel/docs/platform/DOC.md +1940 -0
  118. package/dist/weaviate/docs/vector-db/javascript/DOC.md +1268 -0
  119. package/dist/weaviate/docs/vector-db/python/DOC.md +1388 -0
  120. package/dist/zendesk/docs/support/javascript/DOC.md +2150 -0
  121. package/dist/zendesk/docs/support/python/DOC.md +2297 -0
  122. package/package.json +22 -6
  123. package/skills/get-api-docs/SKILL.md +84 -0
  124. package/src/commands/annotate.js +83 -0
  125. package/src/commands/build.js +12 -1
  126. package/src/commands/feedback.js +150 -0
  127. package/src/commands/get.js +83 -42
  128. package/src/commands/search.js +7 -0
  129. package/src/index.js +43 -17
  130. package/src/lib/analytics.js +90 -0
  131. package/src/lib/annotations.js +57 -0
  132. package/src/lib/bm25.js +170 -0
  133. package/src/lib/cache.js +69 -6
  134. package/src/lib/config.js +8 -3
  135. package/src/lib/identity.js +99 -0
  136. package/src/lib/registry.js +103 -20
  137. package/src/lib/telemetry.js +86 -0
  138. package/src/mcp/server.js +177 -0
  139. package/src/mcp/tools.js +251 -0
@@ -0,0 +1,885 @@
1
+ ---
2
+ name: speech
3
+ description: "Deepgram JavaScript SDK coding guidelines for speech recognition, text-to-speech, and audio intelligence"
4
+ metadata:
5
+ languages: "javascript"
6
+ versions: "4.11.2"
7
+ updated-on: "2026-03-02"
8
+ source: maintainer
9
+ tags: "deepgram,speech,transcription,tts,audio"
10
+ ---
11
+
12
+ # Deepgram JavaScript SDK Coding Guidelines
13
+
14
+ You are a Deepgram API coding expert. Help me with writing code using the Deepgram JavaScript SDK for speech recognition, text-to-speech, voice agents, and text intelligence.
15
+
16
+ Please follow the following guidelines when generating code.
17
+
18
+ You can find the official SDK documentation and code samples here:
19
+ https://developers.deepgram.com/
20
+
21
+ ## Golden Rule: Use the Current Official SDK
22
+
23
+ Always use the official Deepgram JavaScript SDK, which is the standard library for all Deepgram API interactions.
24
+
25
+ - **Library Name:** Deepgram JavaScript SDK
26
+ - **NPM Package:** `@deepgram/sdk`
27
+ - **Minimum Node.js Version:** 18.0.0
28
+
29
+ **Installation:**
30
+
31
+ - **Correct:** `npm install @deepgram/sdk`
32
+
33
+ **APIs and Usage:**
34
+
35
+ - **Correct:** `import { createClient } from "@deepgram/sdk"`
36
+ - **Correct:** `const deepgram = createClient(DEEPGRAM_API_KEY)`
37
+ - **Incorrect:** Using any other import patterns or client creation methods
38
+
39
+ ## Initialization and API Key
40
+
41
+ The `@deepgram/sdk` library requires creating a client instance for all API calls.
42
+
43
+ - Always use `createClient()` to create an instance
44
+ - Set your Deepgram API key as the first parameter
45
+ - Get your free API key from: https://console.deepgram.com/signup?jump=keys
46
+
47
+ ```javascript
48
+ import { createClient } from "@deepgram/sdk";
49
+
50
+ const deepgram = createClient("your-deepgram-api-key");
51
+ ```
52
+
53
+ ## Models
54
+
55
+ ### Speech Recognition Models
56
+
57
+ By default, use the following models for speech recognition:
58
+
59
+ - **General Purpose (Recommended):** `nova-3` or `nova-3-general`
60
+ - **Medical Applications:** `nova-3-medical` or `nova-2-medical`
61
+ - **Meeting Transcription:** `nova-2-meeting` or `enhanced-meeting`
62
+ - **Phone Call Audio:** `nova-2-phonecall` or `enhanced-phonecall`
63
+ - **Cost-Effective Option:** `nova` or `enhanced`
64
+ - **Highest Accuracy:** `nova-3` (latest generation)
65
+
66
+ ### Text-to-Speech Models
67
+
68
+ For text-to-speech, use the Aura model series:
69
+
70
+ - **Recommended Default:** `aura-2-thalia-en`
71
+ - **Available Voices:** All `aura-2-*` models for various voice characteristics
72
+ - **Legacy Support:** `aura-*` models (first generation)
73
+
74
+ ## Basic Speech Recognition (Transcription)
75
+
76
+ ### Synchronous Transcription - Remote Files
77
+
78
+ ```javascript
79
+ import { createClient } from "@deepgram/sdk";
80
+
81
+ const deepgram = createClient("your-api-key");
82
+
83
+ const { result, error } = await deepgram.listen.prerecorded.transcribeUrl(
84
+ { url: "https://example.com/audio.wav" },
85
+ { model: "nova-3" }
86
+ );
87
+
88
+ if (error) {
89
+ console.error("Transcription error:", error);
90
+ } else {
91
+ console.log("Transcript:", result);
92
+ }
93
+ ```
94
+
95
+ ### Synchronous Transcription - Local Files
96
+
97
+ ```javascript
98
+ import fs from "fs";
99
+
100
+ // Using file stream
101
+ const { result, error } = await deepgram.listen.prerecorded.transcribeFile(
102
+ fs.createReadStream("./audio.wav"),
103
+ { model: "nova-3" }
104
+ );
105
+
106
+ // Using file buffer
107
+ const { result, error } = await deepgram.listen.prerecorded.transcribeFile(
108
+ fs.readFileSync("./audio.wav"),
109
+ { model: "nova-3" }
110
+ );
111
+ ```
112
+
113
+ ### Live Streaming Transcription
114
+
115
+ ```javascript
116
+ const dgConnection = deepgram.listen.live({ model: "nova-3" });
117
+
118
+ dgConnection.on(LiveTranscriptionEvents.Open, () => {
119
+ dgConnection.on(LiveTranscriptionEvents.Transcript, (data) => {
120
+ console.log(data);
121
+ });
122
+
123
+ // Send audio data
124
+ dgConnection.send(audioData);
125
+ });
126
+ ```
127
+
128
+ ## Text-to-Speech
129
+
130
+ ### REST API (One-off requests)
131
+
132
+ ```javascript
133
+ const { result, error } = await deepgram.speak.request(
134
+ { text: "Hello, how are you today?" },
135
+ { model: "aura-2-thalia-en" }
136
+ );
137
+ ```
138
+
139
+ ### WebSocket (Streaming)
140
+
141
+ ```javascript
142
+ const dgConnection = deepgram.speak.live({ model: "aura-2-thalia-en" });
143
+
144
+ dgConnection.on(LiveTTSEvents.Open, () => {
145
+ dgConnection.sendText("Hello world");
146
+ dgConnection.flush(); // Important: flush after sending text
147
+ });
148
+ ```
149
+
150
+ ## Voice Agent
151
+
152
+ ```javascript
153
+ const agent = deepgram.agent();
154
+
155
+ agent.on(AgentEvents.Open, () => {
156
+ agent.configure({
157
+ audio: {
158
+ input: { encoding: "linear16", sample_rate: 16000 },
159
+ output: { encoding: "linear16", container: "wav", sample_rate: 24000 }
160
+ },
161
+ agent: {
162
+ listen: { model: "nova-3" },
163
+ speak: { model: "aura-2-thalia-en" },
164
+ think: {
165
+ provider: { type: "anthropic" },
166
+ model: "claude-3-haiku-20240307",
167
+ instructions: "You are a helpful AI assistant."
168
+ }
169
+ }
170
+ });
171
+ });
172
+
173
+ agent.on(AgentEvents.Audio, (audio) => {
174
+ // Handle audio response
175
+ });
176
+ ```
177
+
178
+ ## Error Handling
179
+
180
+ The SDK uses a consistent error handling pattern with `DeepgramResponse`:
181
+
182
+ **Error Types:**
183
+
184
+ - `DeepgramError`: Base error class
185
+ - `DeepgramApiError`: API-related errors with HTTP status codes
186
+ - `DeepgramUnknownError`: Unexpected errors
187
+ - `DeepgramVersionError`: SDK version compatibility errors
188
+
189
+ ```javascript
190
+ const { result, error } = await deepgram.listen.prerecorded.transcribeUrl(
191
+ { url: "invalid-url" },
192
+ { model: "nova-3" }
193
+ );
194
+
195
+ if (error) {
196
+ if (error instanceof DeepgramApiError) {
197
+ console.error(`API Error (${error.status}): ${error.message}`);
198
+ } else {
199
+ console.error("Unexpected error:", error.message);
200
+ }
201
+ return;
202
+ }
203
+
204
+ // Process successful result
205
+ console.log(result);
206
+ ```
207
+
208
+ ## Configuration and Advanced Features
209
+
210
+ ### Scoped Configuration
211
+
212
+ The SDK supports namespace-specific configurations:
213
+
214
+ ```javascript
215
+ // Global configuration
216
+ const deepgram = createClient("api-key", {
217
+ global: {
218
+ fetch: { options: { url: "https://api.beta.deepgram.com" } }
219
+ }
220
+ });
221
+
222
+ // Transcription-specific configuration
223
+ const deepgram = createClient("api-key", {
224
+ listen: {
225
+ fetch: { options: { url: "http://localhost:8080" } }
226
+ }
227
+ });
228
+ ```
229
+
230
+ ### Important Transcription Options
231
+
232
+ - `model`: Speech recognition model to use
233
+ - `language`: Language code (e.g., "en", "es", "fr")
234
+ - `punctuate`: Add punctuation to transcript
235
+ - `diarize`: Speaker identification
236
+ - `smart_format`: Automatic formatting improvements
237
+ - `keyterm`: Keyword detection (Nova 3 only)
238
+
239
+ ### Keyterm Detection (Nova 3 Only)
240
+
241
+ ```javascript
242
+ const { result, error } = await deepgram.listen.prerecorded.transcribeUrl(
243
+ { url: "audio.wav" },
244
+ {
245
+ model: "nova-3",
246
+ keyterm: ["urgent", "deadline", "meeting"]
247
+ }
248
+ );
249
+ ```
250
+
251
+ ## Common Mistakes to Avoid
252
+
253
+ - **Don't** use deprecated models like older versions without explicit need
254
+ - **Don't** forget to handle both `result` and `error` in responses
255
+ - **Don't** use keyterm detection with non-Nova-3 models
256
+ - **Don't** forget to call `flush()` when using live text-to-speech
257
+ - **Don't** hardcode API keys in your source code - use environment variables
258
+ - **Always** check for errors before processing results
259
+
260
+ ## Browser Support
261
+
262
+ The SDK works in browsers with UMD and ESM support:
263
+
264
+ ```html
265
+ <!-- UMD -->
266
+ <script src="https://cdn.jsdelivr.net/npm/@deepgram/sdk"></script>
267
+ <script>
268
+ const { createClient } = deepgram;
269
+ const client = createClient("api-key");
270
+ </script>
271
+
272
+ <!-- ESM -->
273
+ <script type="module">
274
+ import { createClient } from "https://cdn.jsdelivr.net/npm/@deepgram/sdk/+esm";
275
+ const client = createClient("api-key");
276
+ </script>
277
+ ```
278
+
279
+ ## Additional Features
280
+
281
+ ### Text Intelligence
282
+
283
+ ```javascript
284
+ const { result, error } = await deepgram.read.analyzeText(
285
+ { text: "Your text content here" },
286
+ { language: "en", topics: true, sentiment: true }
287
+ );
288
+ ```
289
+
290
+ ### Captions Generation
291
+
292
+ ```javascript
293
+ import { webvtt, srt } from "@deepgram/captions";
294
+
295
+ // After getting transcription result
296
+ const vttOutput = webvtt(result);
297
+ const srtOutput = srt(result);
298
+ ```
299
+
300
+ ## Useful Links
301
+
302
+ - Documentation: https://developers.deepgram.com/
303
+ - API Reference: https://developers.deepgram.com/reference/
304
+ - Models Guide: https://developers.deepgram.com/docs/model
305
+ - Getting API Keys: https://console.deepgram.com/signup?jump=keys
306
+
307
+ ## Notes
308
+
309
+ - The SDK strictly follows semantic versioning
310
+ - Always use documented interfaces to ensure compatibility
311
+ - The SDK supports both Node.js (18+) and browser environments
312
+ - For production applications, implement proper error handling and logging
313
+ - Consider using environment variables for API key management
314
+
315
+ ### Citations
316
+
317
+ ```json
318
+ "name": "@deepgram/sdk",
319
+ "engines": {
320
+ "node": ">=18.0.0"
321
+ },
322
+ npm install @deepgram/sdk
323
+ ```
324
+
325
+
326
+ ### UMD
327
+
328
+ You can now use plain `<script>`s to import deepgram from CDNs, like:
329
+
330
+ <script src="https://cdn.jsdelivr.net/npm/@deepgram/sdk"></script>
331
+
332
+
333
+ or even:
334
+
335
+ ```html
336
+ <script src="https://unpkg.com/@deepgram/sdk"></script>
337
+ ```
338
+
339
+ Then you can use it from a global deepgram variable:
340
+
341
+ ```html
342
+ <script>
343
+ const { createClient } = deepgram;
344
+ const _deepgram = createClient("deepgram-api-key");
345
+
346
+ console.log("Deepgram Instance: ", _deepgram);
347
+ // ...
348
+ </script>
349
+ ```
350
+
351
+ ### ESM
352
+
353
+ You can now use type="module" `<script>`s to import deepgram from CDNs, like:
354
+
355
+ ```html
356
+ <script type="module">
357
+ import { createClient } from "https://cdn.jsdelivr.net/npm/@deepgram/sdk/+esm";
358
+ const deepgram = createClient("deepgram-api-key");
359
+
360
+ console.log("Deepgram Instance: ", deepgram);
361
+ // ...
362
+ </script>
363
+ ```
364
+
365
+ ```typescript
366
+ import { createClient } from "@deepgram/sdk";
367
+ // - or -
368
+ const { createClient } = require("@deepgram/sdk");
369
+ ```
370
+
371
+ ```typescript
372
+ const deepgram = createClient(DEEPGRAM_API_KEY);
373
+ ```
374
+
375
+ To access the Deepgram API you will need a [free Deepgram API Key](https://console.deepgram.com/signup?jump=keys).
376
+
377
+
378
+ The SDK supports scoped configuration. You'll be able to configure various aspects of each namespace of the SDK from the initialization. Below outlines a flexible and customizable configuration system for the Deepgram SDK. Here's how the namespace configuration works:
379
+
380
+ ### 1. Global Defaults
381
+
382
+ - The `global` namespace serves as the foundational configuration applicable across all other namespaces unless overridden.
383
+ - Includes general settings like URL and headers applicable for all API calls.
384
+ - If no specific configurations are provided for other namespaces, the `global` defaults are used.
385
+
386
+ ### 2. Namespace-specific Configurations
387
+
388
+ - Each namespace (`listen`, `manage`, `onprem`, `read`, `speak`) can have its specific configurations which override the `global` settings within their respective scopes.
389
+ - Allows for detailed control over different parts of the application interacting with various Deepgram API endpoints.
390
+
391
+ ### 3. Transport Options
392
+
393
+ - Configurations for both `fetch` and `websocket` can be specified under each namespace, allowing different transport mechanisms for different operations.
394
+ - For example, the `fetch` configuration can have its own URL and proxy settings distinct from the `websocket`.
395
+ - The generic interfaces define a structure for transport options which include a client (like a `fetch` or `WebSocket` instance) and associated options (like headers, URL, proxy settings).
396
+
397
+ This configuration system enables robust customization where defaults provide a foundation, but every aspect of the client's interaction with the API can be finely controlled and tailored to specific needs through namespace-specific settings. This enhances the maintainability and scalability of the application by localizing configurations to their relevant contexts.
398
+
399
+
400
+
401
+
402
+ ```js
403
+ const { result, error } = await deepgram.listen.prerecorded.transcribeUrl(
404
+ {
405
+ url: "https://dpgr.am/spacewalk.wav",
406
+ },
407
+ {
408
+ model: "nova",
409
+ }
410
+ );
411
+
412
+ const { result, error } = await deepgram.listen.prerecorded.transcribeFile(
413
+ fs.createReadStream("./examples/spacewalk.wav"),
414
+ {
415
+ model: "nova",
416
+ }
417
+ );
418
+ ```
419
+
420
+ or
421
+
422
+ ```js
423
+ const { result, error } = await deepgram.listen.prerecorded.transcribeFile(
424
+ fs.readFileSync("./examples/spacewalk.wav"),
425
+ {
426
+ model: "nova",
427
+ }
428
+ );
429
+
430
+ const dgConnection = deepgram.listen.live({ model: "nova" });
431
+
432
+ dgConnection.on(LiveTranscriptionEvents.Open, () => {
433
+ dgConnection.on(LiveTranscriptionEvents.Transcript, (data) => {
434
+ console.log(data);
435
+ });
436
+
437
+ source.addListener("got-some-audio", async (event) => {
438
+ dgConnection.send(event.raw_audio_data);
439
+ });
440
+ });
441
+
442
+ ```
443
+ ```js
444
+ import { webvtt /* , srt */ } from "@deepgram/captions";
445
+
446
+ const { result, error } = await deepgram.listen.prerecorded.transcribeUrl(
447
+ {
448
+ url: "https://dpgr.am/spacewalk.wav",
449
+ },
450
+ {
451
+ model: "nova",
452
+ }
453
+ );
454
+
455
+ const vttOutput = webvtt(result);
456
+ // const srtOutput = srt(result);
457
+
458
+ ```
459
+ ```js
460
+ import { createClient } from "@deepgram/sdk";
461
+ import { AgentEvents } from "@deepgram/sdk";
462
+
463
+ const deepgram = createClient(DEEPGRAM_API_KEY);
464
+
465
+ // Create an agent connection
466
+ const agent = deepgram.agent();
467
+
468
+ // Set up event handlers
469
+ agent.on(AgentEvents.Open, () => {
470
+ console.log("Connection opened");
471
+
472
+ // Configure the agent once connection is established
473
+ agent.configure({
474
+ audio: {
475
+ input: {
476
+ encoding: "linear16",
477
+ sampleRate: 16000,
478
+ },
479
+ output: {
480
+ encoding: "linear16",
481
+ container: "wav",
482
+ sampleRate: 24000,
483
+ },
484
+ },
485
+ agent: {
486
+ listen: {
487
+ model: "nova-3",
488
+ },
489
+ speak: {
490
+ model: "aura-2-thalia-en",
491
+ },
492
+ think: {
493
+ provider: {
494
+ type: "anthropic",
495
+ },
496
+ model: "claude-3-haiku-20240307",
497
+ instructions: "You are a helpful AI assistant. Keep responses brief and friendly.",
498
+ },
499
+ },
500
+ });
501
+ });
502
+
503
+ // Handle agent responses
504
+ agent.on(AgentEvents.AgentStartedSpeaking, (data) => {
505
+ console.log("Agent started speaking:", data["total_latency"]);
506
+ });
507
+
508
+ agent.on(AgentEvents.ConversationText, (message) => {
509
+ console.log(`${message.role} said: ${message.content}`);
510
+ });
511
+
512
+ agent.on(AgentEvents.Audio, (audio) => {
513
+ // Handle audio data from the agent
514
+ playAudio(audio); // Your audio playback implementation
515
+ });
516
+
517
+ agent.on(AgentEvents.Error, (error) => {
518
+ console.error("Error:", error);
519
+ });
520
+
521
+ agent.on(AgentEvents.Close, () => {
522
+ console.log("Connection closed");
523
+ });
524
+
525
+ // Send audio data
526
+ function sendAudioData(audioData) {
527
+ agent.send(audioData);
528
+ }
529
+
530
+ // Keep the connection alive
531
+ setInterval(() => {
532
+ agent.keepAlive();
533
+ }, 8000);
534
+
535
+
536
+ const { result } = await deepgram.speak.request({ text }, { model: "aura-2-thalia-en" });
537
+
538
+
539
+
540
+ const dgConnection = deepgram.speak.live({ model: "aura-2-thalia-en" });
541
+
542
+ dgConnection.on(LiveTTSEvents.Open, () => {
543
+ console.log("Connection opened");
544
+
545
+ // Send text data for TTS synthesis
546
+ dgConnection.sendText(text);
547
+
548
+ // Send Flush message to the server after sending the text
549
+ dgConnection.flush();
550
+
551
+ dgConnection.on(LiveTTSEvents.Close, () => {
552
+ console.log("Connection closed");
553
+ });
554
+ });
555
+
556
+
557
+
558
+ const { result, error } = await deepgram.read.analyzeText(
559
+ { text },
560
+ { language: "en", topics: true, sentiment: true }
561
+ );
562
+ ```
563
+
564
+
565
+
566
+ 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.
567
+
568
+ 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.**
569
+
570
+
571
+
572
+ ```typescript
573
+ type ListenModel =
574
+ | "nova-3"
575
+ | "nova-3-general"
576
+ | "nova-3-medical"
577
+ | "nova-2"
578
+ | "nova-2-meeting"
579
+ | "nova-2-phonecall"
580
+ | "nova-2-voicemail"
581
+ | "nova-2-finance"
582
+ | "nova-2-conversational"
583
+ | "nova-2-video"
584
+ | "nova-2-medical"
585
+ | "nova-2-drivethru"
586
+ | "nova-2-automotive"
587
+ | "nova-2-atc"
588
+ | "nova"
589
+ | "nova-phonecall"
590
+ | "enhanced"
591
+ | "enhanced-meeting"
592
+ | "enhanced-phonecall"
593
+ | "enhanced-finance"
594
+ | "base"
595
+ | "base-meeting"
596
+ | "base-phonecall"
597
+ | "base-voicemail"
598
+ | "base-finance"
599
+ | "base-conversational"
600
+ | "base-video"
601
+ | "whisper-tiny"
602
+ | "whisper"
603
+ | "whisper-small"
604
+ | "whisper-medium"
605
+ | "whisper-large"
606
+ | string;
607
+ ```
608
+
609
+ ```typescript
610
+ type SpeakModel =
611
+ | "aura-asteria-en"
612
+ | "aura-luna-en"
613
+ | "aura-stella-en"
614
+ | "aura-athena-en"
615
+ | "aura-hera-en"
616
+ | "aura-orion-en"
617
+ | "aura-arcas-en"
618
+ | "aura-perseus-en"
619
+ | "aura-angus-en"
620
+ | "aura-orpheus-en"
621
+ | "aura-helios-en"
622
+ | "aura-zeus-en"
623
+ | "aura-2-amalthea-en"
624
+ | "aura-2-andromeda-en"
625
+ | "aura-2-apollo-en"
626
+ | "aura-2-arcas-en"
627
+ | "aura-2-aries-en"
628
+ | "aura-2-asteria-en"
629
+ | "aura-2-athena-en"
630
+ | "aura-2-atlas-en"
631
+ | "aura-2-aurora-en"
632
+ | "aura-2-callista-en"
633
+ | "aura-2-cordelia-en"
634
+ | "aura-2-cora-en"
635
+ | "aura-2-cressida-en"
636
+ | "aura-2-delia-en"
637
+ | "aura-2-draco-en"
638
+ | "aura-2-electra-en"
639
+ | "aura-2-harmonia-en"
640
+ | "aura-2-helena-en"
641
+ | "aura-2-hera-en"
642
+ | "aura-2-hermes-en"
643
+ | "aura-2-hyperion-en"
644
+ | "aura-2-iris-en"
645
+ | "aura-2-janus-en"
646
+ | "aura-2-juno-en"
647
+ | "aura-2-jupiter-en"
648
+ | "aura-2-luna-en"
649
+ | "aura-2-mars-en"
650
+ | "aura-2-minerva-en"
651
+ | "aura-2-neptune-en"
652
+ | "aura-2-odysseus-en"
653
+ | "aura-2-ophelia-en"
654
+ | "aura-2-orion-en"
655
+ | "aura-2-orpheus-en"
656
+ | "aura-2-pandora-en"
657
+ | "aura-2-phoebe-en"
658
+ | "aura-2-pluto-en"
659
+ | "aura-2-saturn-en"
660
+ | "aura-2-selene-en"
661
+ | "aura-2-thalia-en"
662
+ | "aura-2-theia-en"
663
+ | "aura-2-vesta-en"
664
+ | "aura-2-zeus-en"
665
+ | string;
666
+ /**
667
+ * Only available for Nova 3.
668
+ * @see https://developers.deepgram.com/docs/keyterm
669
+ */
670
+ keyterms?: string[];
671
+ };
672
+ ```
673
+
674
+ ```typescript
675
+ export type DeepgramResponse<T> = SuccessResponse<T> | ErrorResponse;
676
+
677
+ interface SuccessResponse<T> {
678
+ result: T;
679
+ error: null;
680
+ }
681
+
682
+ interface ErrorResponse {
683
+ result: null;
684
+ error: DeepgramError;
685
+ }
686
+ ```
687
+
688
+ ```typescript
689
+ export class DeepgramError extends Error {
690
+ protected __dgError = true;
691
+
692
+ constructor(message: string) {
693
+ super(message);
694
+ this.name = "DeepgramError";
695
+ }
696
+ }
697
+
698
+ export function isDeepgramError(error: unknown): error is DeepgramError {
699
+ return typeof error === "object" && error !== null && "__dgError" in error;
700
+ }
701
+
702
+ export class DeepgramApiError extends DeepgramError {
703
+ status: number;
704
+
705
+ constructor(message: string, status: number) {
706
+ super(message);
707
+ this.name = "DeepgramApiError";
708
+ this.status = status;
709
+ }
710
+
711
+ toJSON() {
712
+ return {
713
+ name: this.name,
714
+ message: this.message,
715
+ status: this.status,
716
+ };
717
+ }
718
+ }
719
+
720
+ export class DeepgramUnknownError extends DeepgramError {
721
+ originalError: unknown;
722
+
723
+ constructor(message: string, originalError: unknown) {
724
+ super(message);
725
+ this.name = "DeepgramUnknownError";
726
+ this.originalError = originalError;
727
+ }
728
+ }
729
+
730
+ export class DeepgramVersionError extends DeepgramError {
731
+ constructor() {
732
+ super(
733
+ `You are attempting to use an old format for a newer SDK version. Read more here: https://dpgr.am/js-v3`
734
+ );
735
+
736
+ this.name = "DeepgramVersionError";
737
+ }
738
+ }
739
+ ```
740
+
741
+ ```typescript
742
+ interface TranscriptionSchema extends Record<string, unknown> {
743
+ /**
744
+ * @see https://developers.deepgram.com/docs/model
745
+ */
746
+ model?: string;
747
+
748
+ /**
749
+ * @deprecated
750
+ * @see https://developers.deepgram.com/docs/tier
751
+ */
752
+ tier?: string;
753
+
754
+ /**
755
+ * @see https://developers.deepgram.com/docs/version
756
+ */
757
+ version?: string;
758
+
759
+ /**
760
+ * @see https://developers.deepgram.com/docs/language
761
+ */
762
+ language?: string;
763
+
764
+ /**
765
+ * @see https://developers.deepgram.com/docs/punctuation
766
+ */
767
+ punctuate?: boolean;
768
+
769
+ /**
770
+ * @see https://developers.deepgram.com/docs/profanity-filter
771
+ */
772
+ profanity_filter?: boolean;
773
+
774
+ /**
775
+ * @see https://developers.deepgram.com/docs/redaction
776
+ */
777
+ redact?: string[] | string | boolean;
778
+
779
+ /**
780
+ * @see https://developers.deepgram.com/docs/diarization
781
+ */
782
+ diarize?: boolean;
783
+
784
+ /**
785
+ * @see https://developers.deepgram.com/docs/diarization
786
+ */
787
+ diarize_version?: string;
788
+
789
+ /**
790
+ * @see https://developers.deepgram.com/docs/smart-format
791
+ */
792
+ smart_format?: boolean;
793
+
794
+ /**
795
+ * @see https://developers.deepgram.com/docs/filler-words
796
+ */
797
+ filler_words?: boolean;
798
+
799
+ /**
800
+ * @see https://developers.deepgram.com/docs/multichannel
801
+ */
802
+ multichannel?: boolean;
803
+
804
+ /**
805
+ * @see https://developers.deepgram.com/docs/numerals
806
+ * @deprecated
807
+ */
808
+ numerals?: boolean;
809
+
810
+ /**
811
+ * @see https://developers.deepgram.com/docs/search
812
+ */
813
+ search?: string[] | string;
814
+
815
+ /**
816
+ * @see https://developers.deepgram.com/docs/find-and-replace
817
+ */
818
+ replace?: string[] | string;
819
+
820
+ /**
821
+ * @see https://developers.deepgram.com/docs/callback
822
+ */
823
+ callback?: string;
824
+
825
+ /**
826
+ * @see https://developers.deepgram.com/docs/callback#results
827
+ */
828
+ callback_method?: "put" | "post";
829
+
830
+ /**
831
+ * @see https://developers.deepgram.com/docs/keywords
832
+ */
833
+ keywords?: string[] | string;
834
+
835
+ /**
836
+ * @see https://developers.deepgram.com/docs/keyterm
837
+ */
838
+ keyterm?: string[] | string;
839
+
840
+ /**
841
+ * @see https://developers.deepgram.com/docs/tagging
842
+ */
843
+ tag?: string[];
844
+
845
+ /**
846
+ * As yet unreleased.
847
+ */
848
+ sentiment?: boolean;
849
+
850
+ /**
851
+ * As yet unreleased.
852
+ */
853
+ intents?: boolean;
854
+
855
+ /**
856
+ * As yet unreleased.
857
+ */
858
+ custom_intent?: string[] | string;
859
+
860
+ /**
861
+ * As yet unreleased.
862
+ */
863
+ custom_intent_mode?: "strict" | "extended";
864
+
865
+ /**
866
+ * As yet unreleased.
867
+ */
868
+ topics?: boolean;
869
+
870
+ /**
871
+ * As yet unreleased.
872
+ */
873
+ custom_topic?: string[] | string;
874
+
875
+ /**
876
+ * As yet unreleased.
877
+ */
878
+ custom_topic_mode?: "strict" | "extended";
879
+
880
+ /**
881
+ * @see https://developers.deepgram.com/docs/extra-metadata
882
+ */
883
+ extra?: string[] | string;
884
+ }
885
+ ```