@deepgram/sdk 5.0.0-alpha.2 → 5.0.0-alpha.3
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.
- package/dist/browser/index.global.js +207 -60
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/CustomClient.d.ts +9 -1
- package/dist/cjs/CustomClient.js +131 -21
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1Settings.d.ts +3 -43
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.d.ts +26 -0
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.js +3 -0
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakEndpointProvider.d.ts +28 -13
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakEndpointProvider.js +19 -17
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakOneItemProvider.d.ts +28 -13
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakOneItemProvider.js +19 -17
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentThinkProvider.d.ts +115 -0
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentThinkProvider.js +57 -0
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1UpdateSpeakSpeakProvider.d.ts +18 -3
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1UpdateSpeakSpeakProvider.js +2 -0
- package/dist/cjs/api/resources/agent/resources/v1/types/index.d.ts +2 -0
- package/dist/cjs/api/resources/agent/resources/v1/types/index.js +2 -0
- package/dist/cjs/api/resources/listen/resources/v1/types/ListenV1Results.d.ts +3 -3
- package/dist/cjs/api/types/SpeakV1SampleRate.d.ts +1 -1
- package/dist/cjs/api/types/SpeakV1SampleRate.js +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/CustomClient.d.mts +9 -1
- package/dist/esm/CustomClient.mjs +131 -21
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1Settings.d.mts +3 -43
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.d.mts +26 -0
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.mjs +2 -0
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakEndpointProvider.d.mts +28 -13
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakEndpointProvider.mjs +19 -17
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakOneItemProvider.d.mts +28 -13
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentSpeakOneItemProvider.mjs +19 -17
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentThinkProvider.d.mts +115 -0
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentThinkProvider.mjs +54 -0
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1UpdateSpeakSpeakProvider.d.mts +18 -3
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1UpdateSpeakSpeakProvider.mjs +2 -0
- package/dist/esm/api/resources/agent/resources/v1/types/index.d.mts +2 -0
- package/dist/esm/api/resources/agent/resources/v1/types/index.mjs +2 -0
- package/dist/esm/api/resources/listen/resources/v1/types/ListenV1Results.d.mts +3 -3
- package/dist/esm/api/types/SpeakV1SampleRate.d.mts +1 -1
- package/dist/esm/api/types/SpeakV1SampleRate.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -4
|
@@ -37,13 +37,79 @@ catch (_a) {
|
|
|
37
37
|
// ws not available (e.g., in browser)
|
|
38
38
|
NodeWebSocket = undefined;
|
|
39
39
|
}
|
|
40
|
+
// Helper function to generate UUID that works in both Node.js and browser
|
|
41
|
+
function generateUUID() {
|
|
42
|
+
// In Node.js, use the crypto module
|
|
43
|
+
if (RUNTIME.type === "node") {
|
|
44
|
+
try {
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
46
|
+
const crypto = require("crypto");
|
|
47
|
+
return crypto.randomUUID();
|
|
48
|
+
}
|
|
49
|
+
catch (_a) {
|
|
50
|
+
// Fallback if crypto module is not available
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// In browser or as fallback, use global crypto if available
|
|
54
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
55
|
+
return crypto.randomUUID();
|
|
56
|
+
}
|
|
57
|
+
// Fallback UUID generation (RFC4122 version 4)
|
|
58
|
+
// This is a simple fallback that should work everywhere
|
|
59
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
60
|
+
const r = (Math.random() * 16) | 0;
|
|
61
|
+
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
62
|
+
return v.toString(16);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Wrapper auth provider that checks for accessToken first (Bearer scheme)
|
|
67
|
+
* before falling back to the original auth provider (Token scheme for API keys).
|
|
68
|
+
*/
|
|
69
|
+
class AccessTokenAuthProviderWrapper {
|
|
70
|
+
constructor(originalProvider, accessToken) {
|
|
71
|
+
this.originalProvider = originalProvider;
|
|
72
|
+
this.accessToken = accessToken;
|
|
73
|
+
}
|
|
74
|
+
getAuthRequest(arg) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
// Check for access token first (highest priority)
|
|
78
|
+
// Access tokens use Bearer scheme, API keys use Token scheme
|
|
79
|
+
const accessToken = (_a = (yield core.Supplier.get(this.accessToken))) !== null && _a !== void 0 ? _a : (_b = process.env) === null || _b === void 0 ? void 0 : _b.DEEPGRAM_ACCESS_TOKEN;
|
|
80
|
+
if (accessToken != null) {
|
|
81
|
+
return {
|
|
82
|
+
headers: { Authorization: `Bearer ${accessToken}` },
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// Fall back to original provider (which handles API keys)
|
|
86
|
+
return this.originalProvider.getAuthRequest(arg);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
40
90
|
/**
|
|
41
91
|
* Custom wrapper around DeepgramClient that ensures the custom websocket implementation
|
|
42
92
|
* from ws.ts is always used, even if the auto-generated code changes.
|
|
43
93
|
*/
|
|
44
94
|
export class CustomDeepgramClient extends DeepgramClient {
|
|
45
95
|
constructor(options = {}) {
|
|
46
|
-
|
|
96
|
+
// Generate a UUID for the session ID
|
|
97
|
+
const sessionId = generateUUID();
|
|
98
|
+
// Add the session ID to headers so it's included in all REST requests
|
|
99
|
+
const optionsWithSessionId = Object.assign(Object.assign({}, options), { headers: Object.assign(Object.assign({}, options.headers), { "x-deepgram-session-id": sessionId }) });
|
|
100
|
+
super(optionsWithSessionId);
|
|
101
|
+
this._sessionId = sessionId;
|
|
102
|
+
// Wrap the auth provider to handle accessToken if provided
|
|
103
|
+
// This ensures accessToken takes priority over apiKey/env var
|
|
104
|
+
if (options.accessToken != null) {
|
|
105
|
+
this._options.authProvider = new AccessTokenAuthProviderWrapper(this._options.authProvider, options.accessToken);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get the session ID that was generated for this client instance.
|
|
110
|
+
*/
|
|
111
|
+
get sessionId() {
|
|
112
|
+
return this._sessionId;
|
|
47
113
|
}
|
|
48
114
|
/**
|
|
49
115
|
* Override the agent getter to return a wrapped client that ensures
|
|
@@ -106,6 +172,25 @@ class WrappedSpeakClient extends SpeakClientImpl {
|
|
|
106
172
|
return new WrappedSpeakV1Client(this._options);
|
|
107
173
|
}
|
|
108
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Helper function to resolve Suppliers in headers to their actual values.
|
|
177
|
+
*/
|
|
178
|
+
function resolveHeaders(headers) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
const resolved = {};
|
|
181
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
182
|
+
if (value == null) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
// Resolve Supplier if it's a Supplier, otherwise use the value directly
|
|
186
|
+
const resolvedValue = yield core.Supplier.get(value);
|
|
187
|
+
if (resolvedValue != null) {
|
|
188
|
+
resolved[key] = resolvedValue;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return resolved;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
109
194
|
/**
|
|
110
195
|
* Helper function to get WebSocket class and handle headers/protocols based on runtime.
|
|
111
196
|
* In Node.js, use the 'ws' library which supports headers.
|
|
@@ -115,6 +200,8 @@ function getWebSocketOptions(headers) {
|
|
|
115
200
|
const options = {};
|
|
116
201
|
// Check if we're in a browser environment (browser or web-worker)
|
|
117
202
|
const isBrowser = RUNTIME.type === "browser" || RUNTIME.type === "web-worker";
|
|
203
|
+
// Extract session ID header
|
|
204
|
+
const sessionIdHeader = headers["x-deepgram-session-id"] || headers["X-Deepgram-Session-Id"];
|
|
118
205
|
// In Node.js, ensure we use the 'ws' library which supports headers
|
|
119
206
|
if (RUNTIME.type === "node" && NodeWebSocket) {
|
|
120
207
|
options.WebSocket = NodeWebSocket;
|
|
@@ -125,10 +212,14 @@ function getWebSocketOptions(headers) {
|
|
|
125
212
|
// Extract Authorization header and use Sec-WebSocket-Protocol instead
|
|
126
213
|
const authHeader = headers.Authorization || headers.authorization;
|
|
127
214
|
const browserHeaders = Object.assign({}, headers);
|
|
128
|
-
// Remove Authorization from headers since
|
|
215
|
+
// Remove Authorization and session ID from headers since they won't work in browser
|
|
129
216
|
delete browserHeaders.Authorization;
|
|
130
217
|
delete browserHeaders.authorization;
|
|
218
|
+
delete browserHeaders["x-deepgram-session-id"];
|
|
219
|
+
delete browserHeaders["X-Deepgram-Session-Id"];
|
|
131
220
|
options.headers = browserHeaders;
|
|
221
|
+
// Build protocols array for browser WebSocket
|
|
222
|
+
const protocols = [];
|
|
132
223
|
// If we have an Authorization header, extract the token and format as protocols
|
|
133
224
|
// Deepgram expects:
|
|
134
225
|
// - For API keys: Sec-WebSocket-Protocol: token,API_KEY_GOES_HERE
|
|
@@ -138,18 +229,25 @@ function getWebSocketOptions(headers) {
|
|
|
138
229
|
if (authHeader.startsWith("Token ")) {
|
|
139
230
|
// API key: "Token API_KEY" -> ["token", "API_KEY"]
|
|
140
231
|
const apiKey = authHeader.substring(6); // Remove "Token " prefix
|
|
141
|
-
|
|
232
|
+
protocols.push("token", apiKey);
|
|
142
233
|
}
|
|
143
234
|
else if (authHeader.startsWith("Bearer ")) {
|
|
144
235
|
// Access token: "Bearer TOKEN" -> ["bearer", "TOKEN"]
|
|
145
236
|
const token = authHeader.substring(7); // Remove "Bearer " prefix
|
|
146
|
-
|
|
237
|
+
protocols.push("bearer", token);
|
|
147
238
|
}
|
|
148
239
|
else {
|
|
149
240
|
// Fallback: use the entire header value if it doesn't match expected format
|
|
150
|
-
|
|
241
|
+
protocols.push(authHeader);
|
|
151
242
|
}
|
|
152
243
|
}
|
|
244
|
+
// Add session ID as a protocol for browser WebSocket
|
|
245
|
+
if (sessionIdHeader && typeof sessionIdHeader === "string") {
|
|
246
|
+
protocols.push("x-deepgram-session-id", sessionIdHeader);
|
|
247
|
+
}
|
|
248
|
+
if (protocols.length > 0) {
|
|
249
|
+
options.protocols = protocols;
|
|
250
|
+
}
|
|
153
251
|
}
|
|
154
252
|
else {
|
|
155
253
|
// Fallback for other environments
|
|
@@ -163,17 +261,20 @@ function getWebSocketOptions(headers) {
|
|
|
163
261
|
class WrappedAgentV1Client extends AgentV1Client {
|
|
164
262
|
connect() {
|
|
165
263
|
return __awaiter(this, arguments, void 0, function* (args = {}) {
|
|
166
|
-
var _a, _b, _c, _d, _e;
|
|
264
|
+
var _a, _b, _c, _d, _e, _f;
|
|
167
265
|
const { headers, debug, reconnectAttempts } = args;
|
|
168
266
|
// Get Authorization from authProvider (matching the working version)
|
|
169
267
|
const authRequest = yield ((_a = this._options.authProvider) === null || _a === void 0 ? void 0 : _a.getAuthRequest());
|
|
170
|
-
|
|
268
|
+
// Merge headers from options (which includes session ID), auth headers, and request headers
|
|
269
|
+
const mergedHeaders = mergeHeaders((_b = this._options.headers) !== null && _b !== void 0 ? _b : {}, (_c = authRequest === null || authRequest === void 0 ? void 0 : authRequest.headers) !== null && _c !== void 0 ? _c : {}, headers);
|
|
270
|
+
// Resolve any Suppliers in headers to actual values
|
|
271
|
+
const _headers = yield resolveHeaders(mergedHeaders);
|
|
171
272
|
// Get WebSocket options with proper header handling
|
|
172
273
|
const wsOptions = getWebSocketOptions(_headers);
|
|
173
274
|
// Explicitly use the custom ReconnectingWebSocket from ws.ts
|
|
174
275
|
const socket = new ReconnectingWebSocket({
|
|
175
|
-
url: core.url.join((
|
|
176
|
-
protocols: (
|
|
276
|
+
url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.DeepgramEnvironment.Production).agent, "/v1/agent/converse"),
|
|
277
|
+
protocols: (_f = wsOptions.protocols) !== null && _f !== void 0 ? _f : [],
|
|
177
278
|
queryParameters: {},
|
|
178
279
|
headers: wsOptions.headers,
|
|
179
280
|
options: {
|
|
@@ -253,7 +354,7 @@ class WrappedAgentV1Socket extends AgentV1Socket {
|
|
|
253
354
|
class WrappedListenV1Client extends ListenV1Client {
|
|
254
355
|
connect(args) {
|
|
255
356
|
return __awaiter(this, void 0, void 0, function* () {
|
|
256
|
-
var _a, _b, _c;
|
|
357
|
+
var _a, _b, _c, _d;
|
|
257
358
|
// Extract all the args (same as the original implementation)
|
|
258
359
|
const { callback, callback_method: callbackMethod, channels, diarize, dictation, encoding, endpointing, extra, interim_results: interimResults, keyterm, keywords, language, mip_opt_out: mipOptOut, model, multichannel, numerals, profanity_filter: profanityFilter, punctuate, redact, replace, sample_rate: sampleRate, search, smart_format: smartFormat, tag, utterance_end_ms: utteranceEndMs, vad_events: vadEvents, version, headers, debug, reconnectAttempts, } = args;
|
|
259
360
|
// Build query params (same as original)
|
|
@@ -313,13 +414,16 @@ class WrappedListenV1Client extends ListenV1Client {
|
|
|
313
414
|
_queryParams.version = version;
|
|
314
415
|
// Get Authorization from authProvider (matching the working version)
|
|
315
416
|
const authRequest = yield this._options.authProvider.getAuthRequest();
|
|
316
|
-
|
|
417
|
+
// Merge headers from options (which includes session ID), auth headers, and request headers
|
|
418
|
+
const mergedHeaders = mergeHeaders((_a = this._options.headers) !== null && _a !== void 0 ? _a : {}, authRequest.headers, headers);
|
|
419
|
+
// Resolve any Suppliers in headers to actual values
|
|
420
|
+
const _headers = yield resolveHeaders(mergedHeaders);
|
|
317
421
|
// Get WebSocket options with proper header handling
|
|
318
422
|
const wsOptions = getWebSocketOptions(_headers);
|
|
319
423
|
// Explicitly use the custom ReconnectingWebSocket from ws.ts
|
|
320
424
|
const socket = new ReconnectingWebSocket({
|
|
321
|
-
url: core.url.join((
|
|
322
|
-
protocols: (
|
|
425
|
+
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.DeepgramEnvironment.Production).production, "/v1/listen"),
|
|
426
|
+
protocols: (_d = wsOptions.protocols) !== null && _d !== void 0 ? _d : [],
|
|
323
427
|
queryParameters: _queryParams,
|
|
324
428
|
headers: wsOptions.headers,
|
|
325
429
|
options: {
|
|
@@ -392,7 +496,7 @@ class WrappedListenV1Socket extends ListenV1Socket {
|
|
|
392
496
|
class WrappedListenV2Client extends ListenV2Client {
|
|
393
497
|
connect(args) {
|
|
394
498
|
return __awaiter(this, void 0, void 0, function* () {
|
|
395
|
-
var _a, _b, _c, _d, _e;
|
|
499
|
+
var _a, _b, _c, _d, _e, _f;
|
|
396
500
|
const { model, encoding, sample_rate: sampleRate, eager_eot_threshold: eagerEotThreshold, eot_threshold: eotThreshold, eot_timeout_ms: eotTimeoutMs, keyterm, mip_opt_out: mipOptOut, tag, headers, debug, reconnectAttempts, } = args;
|
|
397
501
|
const _queryParams = {};
|
|
398
502
|
_queryParams.model = model;
|
|
@@ -414,13 +518,16 @@ class WrappedListenV2Client extends ListenV2Client {
|
|
|
414
518
|
_queryParams.tag = tag;
|
|
415
519
|
// Get Authorization from authProvider (matching the working version)
|
|
416
520
|
const authRequest = yield ((_a = this._options.authProvider) === null || _a === void 0 ? void 0 : _a.getAuthRequest());
|
|
417
|
-
|
|
521
|
+
// Merge headers from options (which includes session ID), auth headers, and request headers
|
|
522
|
+
const mergedHeaders = mergeHeaders((_b = this._options.headers) !== null && _b !== void 0 ? _b : {}, (_c = authRequest === null || authRequest === void 0 ? void 0 : authRequest.headers) !== null && _c !== void 0 ? _c : {}, headers);
|
|
523
|
+
// Resolve any Suppliers in headers to actual values
|
|
524
|
+
const _headers = yield resolveHeaders(mergedHeaders);
|
|
418
525
|
// Get WebSocket options with proper header handling
|
|
419
526
|
const wsOptions = getWebSocketOptions(_headers);
|
|
420
527
|
// Explicitly use the custom ReconnectingWebSocket from ws.ts
|
|
421
528
|
const socket = new ReconnectingWebSocket({
|
|
422
|
-
url: core.url.join((
|
|
423
|
-
protocols: (
|
|
529
|
+
url: core.url.join((_d = (yield core.Supplier.get(this._options.baseUrl))) !== null && _d !== void 0 ? _d : ((_e = (yield core.Supplier.get(this._options.environment))) !== null && _e !== void 0 ? _e : environments.DeepgramEnvironment.Production).production, "/v2/listen"),
|
|
530
|
+
protocols: (_f = wsOptions.protocols) !== null && _f !== void 0 ? _f : [],
|
|
424
531
|
queryParameters: _queryParams,
|
|
425
532
|
headers: wsOptions.headers,
|
|
426
533
|
options: {
|
|
@@ -493,7 +600,7 @@ class WrappedListenV2Socket extends ListenV2Socket {
|
|
|
493
600
|
class WrappedSpeakV1Client extends SpeakV1Client {
|
|
494
601
|
connect(args) {
|
|
495
602
|
return __awaiter(this, void 0, void 0, function* () {
|
|
496
|
-
var _a, _b, _c;
|
|
603
|
+
var _a, _b, _c, _d;
|
|
497
604
|
const { encoding, mip_opt_out: mipOptOut, model, sample_rate: sampleRate, headers, debug, reconnectAttempts, } = args;
|
|
498
605
|
const _queryParams = {};
|
|
499
606
|
if (encoding != null)
|
|
@@ -506,13 +613,16 @@ class WrappedSpeakV1Client extends SpeakV1Client {
|
|
|
506
613
|
_queryParams.sample_rate = sampleRate;
|
|
507
614
|
// Get Authorization from authProvider (matching the working version)
|
|
508
615
|
const authRequest = yield this._options.authProvider.getAuthRequest();
|
|
509
|
-
|
|
616
|
+
// Merge headers from options (which includes session ID), auth headers, and request headers
|
|
617
|
+
const mergedHeaders = mergeHeaders((_a = this._options.headers) !== null && _a !== void 0 ? _a : {}, authRequest.headers, headers);
|
|
618
|
+
// Resolve any Suppliers in headers to actual values
|
|
619
|
+
const _headers = yield resolveHeaders(mergedHeaders);
|
|
510
620
|
// Get WebSocket options with proper header handling
|
|
511
621
|
const wsOptions = getWebSocketOptions(_headers);
|
|
512
622
|
// Explicitly use the custom ReconnectingWebSocket from ws.ts
|
|
513
623
|
const socket = new ReconnectingWebSocket({
|
|
514
|
-
url: core.url.join((
|
|
515
|
-
protocols: (
|
|
624
|
+
url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.DeepgramEnvironment.Production).production, "/v1/speak"),
|
|
625
|
+
protocols: (_d = wsOptions.protocols) !== null && _d !== void 0 ? _d : [],
|
|
516
626
|
queryParameters: _queryParams,
|
|
517
627
|
headers: wsOptions.headers,
|
|
518
628
|
options: {
|
|
@@ -73,7 +73,7 @@ export declare namespace AgentV1Settings {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
interface Agent {
|
|
76
|
-
/**
|
|
76
|
+
/** Deprecated. Use `listen.provider.language` and `speak.provider.language` fields instead. */
|
|
77
77
|
language?: string;
|
|
78
78
|
/** Conversation context including the history of messages and function calls */
|
|
79
79
|
context?: Agent.Context;
|
|
@@ -120,22 +120,10 @@ export declare namespace AgentV1Settings {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
interface Listen {
|
|
123
|
-
provider?:
|
|
124
|
-
}
|
|
125
|
-
namespace Listen {
|
|
126
|
-
interface Provider {
|
|
127
|
-
/** Provider type for speech-to-text */
|
|
128
|
-
type: "deepgram";
|
|
129
|
-
/** Model to use for speech to text */
|
|
130
|
-
model?: string;
|
|
131
|
-
/** Prompt key-term recognition (nova-3 'en' only) */
|
|
132
|
-
keyterms?: string[];
|
|
133
|
-
/** Applies smart formatting to improve transcript readability (Deepgram providers only) */
|
|
134
|
-
smart_format?: boolean;
|
|
135
|
-
}
|
|
123
|
+
provider?: Deepgram.agent.AgentV1SettingsAgentListenProvider;
|
|
136
124
|
}
|
|
137
125
|
interface Think {
|
|
138
|
-
provider:
|
|
126
|
+
provider: Deepgram.agent.AgentV1SettingsAgentThinkProvider;
|
|
139
127
|
/** Optional for non-Deepgram LLM providers. When present, must include url field and headers object */
|
|
140
128
|
endpoint?: Think.Endpoint;
|
|
141
129
|
functions?: Think.Functions.Item[];
|
|
@@ -144,34 +132,6 @@ export declare namespace AgentV1Settings {
|
|
|
144
132
|
context_length?: Think.ContextLength;
|
|
145
133
|
}
|
|
146
134
|
namespace Think {
|
|
147
|
-
type Provider = {
|
|
148
|
-
type?: "open_ai" | undefined;
|
|
149
|
-
model?: ("gpt-5" | "gpt-5-mini" | "gpt-5-nano" | "gpt-4.1" | "gpt-4.1-mini" | "gpt-4.1-nano" | "gpt-4o" | "gpt-4o-mini") | undefined;
|
|
150
|
-
temperature?: number | undefined;
|
|
151
|
-
} | {
|
|
152
|
-
type?: "aws_bedrock" | undefined;
|
|
153
|
-
model?: ("anthropic/claude-3-5-sonnet-20240620-v1:0" | "anthropic/claude-3-5-haiku-20240307-v1:0") | undefined;
|
|
154
|
-
temperature?: number | undefined;
|
|
155
|
-
credentials?: {
|
|
156
|
-
type?: ("sts" | "iam") | undefined;
|
|
157
|
-
region?: string | undefined;
|
|
158
|
-
access_key_id?: string | undefined;
|
|
159
|
-
secret_access_key?: string | undefined;
|
|
160
|
-
session_token?: string | undefined;
|
|
161
|
-
} | undefined;
|
|
162
|
-
} | {
|
|
163
|
-
type?: "anthropic" | undefined;
|
|
164
|
-
model?: ("claude-3-5-haiku-latest" | "claude-sonnet-4-20250514") | undefined;
|
|
165
|
-
temperature?: number | undefined;
|
|
166
|
-
} | {
|
|
167
|
-
type?: "google" | undefined;
|
|
168
|
-
model?: ("gemini-2.0-flash" | "gemini-2.0-flash-lite" | "gemini-2.5-flash") | undefined;
|
|
169
|
-
temperature?: number | undefined;
|
|
170
|
-
} | {
|
|
171
|
-
type?: "groq" | undefined;
|
|
172
|
-
model?: "openai/gpt-oss-20b" | undefined;
|
|
173
|
-
temperature?: number | undefined;
|
|
174
|
-
};
|
|
175
135
|
/**
|
|
176
136
|
* Optional for non-Deepgram LLM providers. When present, must include url field and headers object
|
|
177
137
|
*/
|
package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.d.mts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as Deepgram from "../../../../../index.mjs";
|
|
2
|
+
export type AgentV1SettingsAgentListenProvider = Deepgram.agent.AgentV1SettingsAgentListenProvider.V1 | Deepgram.agent.AgentV1SettingsAgentListenProvider.V2;
|
|
3
|
+
export declare namespace AgentV1SettingsAgentListenProvider {
|
|
4
|
+
interface V1 {
|
|
5
|
+
version: "v1";
|
|
6
|
+
/** Provider type for speech-to-text */
|
|
7
|
+
type: "deepgram";
|
|
8
|
+
/** Model to use for speech to text using the V1 API (e.g. Nova-3, Nova-2) */
|
|
9
|
+
model?: string;
|
|
10
|
+
/** Language code to use for speech-to-text. Can be a BCP-47 language tag (e.g. `en`), or `multi` for code-switching transcription */
|
|
11
|
+
language?: string;
|
|
12
|
+
/** Prompt keyterm recognition to improve Keyword Recall Rate */
|
|
13
|
+
keyterms?: string[];
|
|
14
|
+
/** Applies smart formatting to improve transcript readability */
|
|
15
|
+
smart_format?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface V2 {
|
|
18
|
+
version: "v2";
|
|
19
|
+
/** Provider type for speech-to-text */
|
|
20
|
+
type: "deepgram";
|
|
21
|
+
/** Model to use for speech to text using the V2 API (e.g. flux-general-en) */
|
|
22
|
+
model: string;
|
|
23
|
+
/** Prompt keyterm recognition to improve Keyword Recall Rate */
|
|
24
|
+
keyterms?: string[];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -3,10 +3,12 @@ export type AgentV1SettingsAgentSpeakEndpointProvider = Deepgram.agent.AgentV1Se
|
|
|
3
3
|
export declare namespace AgentV1SettingsAgentSpeakEndpointProvider {
|
|
4
4
|
interface Deepgram {
|
|
5
5
|
type: "deepgram";
|
|
6
|
+
/** The REST API version for the Deepgram text-to-speech API */
|
|
7
|
+
version?: "v1";
|
|
6
8
|
/** Deepgram TTS model */
|
|
7
|
-
model:
|
|
9
|
+
model: Deepgram.Model;
|
|
8
10
|
}
|
|
9
|
-
namespace
|
|
11
|
+
namespace Deepgram {
|
|
10
12
|
/** Deepgram TTS model */
|
|
11
13
|
const Model: {
|
|
12
14
|
readonly AuraAsteriaEn: "aura-asteria-en";
|
|
@@ -77,12 +79,16 @@ export declare namespace AgentV1SettingsAgentSpeakEndpointProvider {
|
|
|
77
79
|
}
|
|
78
80
|
interface ElevenLabs {
|
|
79
81
|
type: "eleven_labs";
|
|
82
|
+
/** The REST API version for the Deepgram text-to-speech API */
|
|
83
|
+
version?: "v1";
|
|
80
84
|
/** Eleven Labs model ID */
|
|
81
|
-
model_id:
|
|
82
|
-
/**
|
|
85
|
+
model_id: ElevenLabs.ModelId;
|
|
86
|
+
/** Optional language to use, e.g. 'en-US'. Corresponds to the `language_code` parameter in the ElevenLabs API */
|
|
87
|
+
language?: string;
|
|
88
|
+
/** Use the `language` field instead. */
|
|
83
89
|
language_code?: string;
|
|
84
90
|
}
|
|
85
|
-
namespace
|
|
91
|
+
namespace ElevenLabs {
|
|
86
92
|
/** Eleven Labs model ID */
|
|
87
93
|
const ModelId: {
|
|
88
94
|
readonly ElevenTurboV25: "eleven_turbo_v2_5";
|
|
@@ -93,13 +99,18 @@ export declare namespace AgentV1SettingsAgentSpeakEndpointProvider {
|
|
|
93
99
|
}
|
|
94
100
|
interface Cartesia {
|
|
95
101
|
type: "cartesia";
|
|
102
|
+
/** The API version header for the Cartesia text-to-speech API */
|
|
103
|
+
version?: Cartesia.Version;
|
|
96
104
|
/** Cartesia model ID */
|
|
97
|
-
model_id:
|
|
98
|
-
voice:
|
|
105
|
+
model_id: Cartesia.ModelId;
|
|
106
|
+
voice: Cartesia.Voice;
|
|
99
107
|
/** Cartesia language code */
|
|
100
108
|
language?: string;
|
|
101
109
|
}
|
|
102
|
-
namespace
|
|
110
|
+
namespace Cartesia {
|
|
111
|
+
/** The API version header for the Cartesia text-to-speech API */
|
|
112
|
+
const Version: {};
|
|
113
|
+
type Version = (typeof Version)[keyof typeof Version];
|
|
103
114
|
/** Cartesia model ID */
|
|
104
115
|
const ModelId: {
|
|
105
116
|
readonly Sonic2: "sonic-2";
|
|
@@ -115,12 +126,14 @@ export declare namespace AgentV1SettingsAgentSpeakEndpointProvider {
|
|
|
115
126
|
}
|
|
116
127
|
interface OpenAi {
|
|
117
128
|
type: "open_ai";
|
|
129
|
+
/** The REST API version for the OpenAI text-to-speech API */
|
|
130
|
+
version?: "v1";
|
|
118
131
|
/** OpenAI TTS model */
|
|
119
|
-
model:
|
|
132
|
+
model: OpenAi.Model;
|
|
120
133
|
/** OpenAI voice */
|
|
121
|
-
voice:
|
|
134
|
+
voice: OpenAi.Voice;
|
|
122
135
|
}
|
|
123
|
-
namespace
|
|
136
|
+
namespace OpenAi {
|
|
124
137
|
/** OpenAI TTS model */
|
|
125
138
|
const Model: {
|
|
126
139
|
readonly Tts1: "tts-1";
|
|
@@ -142,8 +155,10 @@ export declare namespace AgentV1SettingsAgentSpeakEndpointProvider {
|
|
|
142
155
|
type: "aws_polly";
|
|
143
156
|
/** AWS Polly voice name */
|
|
144
157
|
voice: AgentV1SettingsAgentSpeakEndpointProviderAwsPolly.Voice;
|
|
145
|
-
/** Language
|
|
146
|
-
|
|
158
|
+
/** Language to use, e.g. 'en-US'. Corresponds to the `language_code` parameter in the AWS Polly API */
|
|
159
|
+
language: string;
|
|
160
|
+
/** Use the `language` field instead. */
|
|
161
|
+
language_code?: string;
|
|
147
162
|
engine: AgentV1SettingsAgentSpeakEndpointProviderAwsPolly.Engine;
|
|
148
163
|
credentials: AgentV1SettingsAgentSpeakEndpointProviderAwsPolly.Credentials;
|
|
149
164
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
export var AgentV1SettingsAgentSpeakEndpointProvider;
|
|
3
3
|
(function (AgentV1SettingsAgentSpeakEndpointProvider) {
|
|
4
|
-
let
|
|
5
|
-
(function (
|
|
4
|
+
let Deepgram;
|
|
5
|
+
(function (Deepgram) {
|
|
6
6
|
/** Deepgram TTS model */
|
|
7
|
-
|
|
7
|
+
Deepgram.Model = {
|
|
8
8
|
AuraAsteriaEn: "aura-asteria-en",
|
|
9
9
|
AuraLunaEn: "aura-luna-en",
|
|
10
10
|
AuraStellaEn: "aura-stella-en",
|
|
@@ -69,33 +69,35 @@ export var AgentV1SettingsAgentSpeakEndpointProvider;
|
|
|
69
69
|
Aura2EstrellaEs: "aura-2-estrella-es",
|
|
70
70
|
Aura2JavierEs: "aura-2-javier-es",
|
|
71
71
|
};
|
|
72
|
-
})(
|
|
73
|
-
let
|
|
74
|
-
(function (
|
|
72
|
+
})(Deepgram = AgentV1SettingsAgentSpeakEndpointProvider.Deepgram || (AgentV1SettingsAgentSpeakEndpointProvider.Deepgram = {}));
|
|
73
|
+
let ElevenLabs;
|
|
74
|
+
(function (ElevenLabs) {
|
|
75
75
|
/** Eleven Labs model ID */
|
|
76
|
-
|
|
76
|
+
ElevenLabs.ModelId = {
|
|
77
77
|
ElevenTurboV25: "eleven_turbo_v2_5",
|
|
78
78
|
ElevenMonolingualV1: "eleven_monolingual_v1",
|
|
79
79
|
ElevenMultilingualV2: "eleven_multilingual_v2",
|
|
80
80
|
};
|
|
81
|
-
})(
|
|
82
|
-
let
|
|
83
|
-
(function (
|
|
81
|
+
})(ElevenLabs = AgentV1SettingsAgentSpeakEndpointProvider.ElevenLabs || (AgentV1SettingsAgentSpeakEndpointProvider.ElevenLabs = {}));
|
|
82
|
+
let Cartesia;
|
|
83
|
+
(function (Cartesia) {
|
|
84
|
+
/** The API version header for the Cartesia text-to-speech API */
|
|
85
|
+
Cartesia.Version = {};
|
|
84
86
|
/** Cartesia model ID */
|
|
85
|
-
|
|
87
|
+
Cartesia.ModelId = {
|
|
86
88
|
Sonic2: "sonic-2",
|
|
87
89
|
SonicMultilingual: "sonic-multilingual",
|
|
88
90
|
};
|
|
89
|
-
})(
|
|
90
|
-
let
|
|
91
|
-
(function (
|
|
91
|
+
})(Cartesia = AgentV1SettingsAgentSpeakEndpointProvider.Cartesia || (AgentV1SettingsAgentSpeakEndpointProvider.Cartesia = {}));
|
|
92
|
+
let OpenAi;
|
|
93
|
+
(function (OpenAi) {
|
|
92
94
|
/** OpenAI TTS model */
|
|
93
|
-
|
|
95
|
+
OpenAi.Model = {
|
|
94
96
|
Tts1: "tts-1",
|
|
95
97
|
Tts1Hd: "tts-1-hd",
|
|
96
98
|
};
|
|
97
99
|
/** OpenAI voice */
|
|
98
|
-
|
|
100
|
+
OpenAi.Voice = {
|
|
99
101
|
Alloy: "alloy",
|
|
100
102
|
Echo: "echo",
|
|
101
103
|
Fable: "fable",
|
|
@@ -103,7 +105,7 @@ export var AgentV1SettingsAgentSpeakEndpointProvider;
|
|
|
103
105
|
Nova: "nova",
|
|
104
106
|
Shimmer: "shimmer",
|
|
105
107
|
};
|
|
106
|
-
})(
|
|
108
|
+
})(OpenAi = AgentV1SettingsAgentSpeakEndpointProvider.OpenAi || (AgentV1SettingsAgentSpeakEndpointProvider.OpenAi = {}));
|
|
107
109
|
let AgentV1SettingsAgentSpeakEndpointProviderAwsPolly;
|
|
108
110
|
(function (AgentV1SettingsAgentSpeakEndpointProviderAwsPolly) {
|
|
109
111
|
/** AWS Polly voice name */
|
|
@@ -3,10 +3,12 @@ export type AgentV1SettingsAgentSpeakOneItemProvider = Deepgram.agent.AgentV1Set
|
|
|
3
3
|
export declare namespace AgentV1SettingsAgentSpeakOneItemProvider {
|
|
4
4
|
interface Deepgram {
|
|
5
5
|
type: "deepgram";
|
|
6
|
+
/** The REST API version for the Deepgram text-to-speech API */
|
|
7
|
+
version?: "v1";
|
|
6
8
|
/** Deepgram TTS model */
|
|
7
|
-
model:
|
|
9
|
+
model: Deepgram.Model;
|
|
8
10
|
}
|
|
9
|
-
namespace
|
|
11
|
+
namespace Deepgram {
|
|
10
12
|
/** Deepgram TTS model */
|
|
11
13
|
const Model: {
|
|
12
14
|
readonly AuraAsteriaEn: "aura-asteria-en";
|
|
@@ -77,12 +79,16 @@ export declare namespace AgentV1SettingsAgentSpeakOneItemProvider {
|
|
|
77
79
|
}
|
|
78
80
|
interface ElevenLabs {
|
|
79
81
|
type: "eleven_labs";
|
|
82
|
+
/** The REST API version for the Deepgram text-to-speech API */
|
|
83
|
+
version?: "v1";
|
|
80
84
|
/** Eleven Labs model ID */
|
|
81
|
-
model_id:
|
|
82
|
-
/**
|
|
85
|
+
model_id: ElevenLabs.ModelId;
|
|
86
|
+
/** Optional language to use, e.g. 'en-US'. Corresponds to the `language_code` parameter in the ElevenLabs API */
|
|
87
|
+
language?: string;
|
|
88
|
+
/** Use the `language` field instead. */
|
|
83
89
|
language_code?: string;
|
|
84
90
|
}
|
|
85
|
-
namespace
|
|
91
|
+
namespace ElevenLabs {
|
|
86
92
|
/** Eleven Labs model ID */
|
|
87
93
|
const ModelId: {
|
|
88
94
|
readonly ElevenTurboV25: "eleven_turbo_v2_5";
|
|
@@ -93,13 +99,18 @@ export declare namespace AgentV1SettingsAgentSpeakOneItemProvider {
|
|
|
93
99
|
}
|
|
94
100
|
interface Cartesia {
|
|
95
101
|
type: "cartesia";
|
|
102
|
+
/** The API version header for the Cartesia text-to-speech API */
|
|
103
|
+
version?: Cartesia.Version;
|
|
96
104
|
/** Cartesia model ID */
|
|
97
|
-
model_id:
|
|
98
|
-
voice:
|
|
105
|
+
model_id: Cartesia.ModelId;
|
|
106
|
+
voice: Cartesia.Voice;
|
|
99
107
|
/** Cartesia language code */
|
|
100
108
|
language?: string;
|
|
101
109
|
}
|
|
102
|
-
namespace
|
|
110
|
+
namespace Cartesia {
|
|
111
|
+
/** The API version header for the Cartesia text-to-speech API */
|
|
112
|
+
const Version: {};
|
|
113
|
+
type Version = (typeof Version)[keyof typeof Version];
|
|
103
114
|
/** Cartesia model ID */
|
|
104
115
|
const ModelId: {
|
|
105
116
|
readonly Sonic2: "sonic-2";
|
|
@@ -115,12 +126,14 @@ export declare namespace AgentV1SettingsAgentSpeakOneItemProvider {
|
|
|
115
126
|
}
|
|
116
127
|
interface OpenAi {
|
|
117
128
|
type: "open_ai";
|
|
129
|
+
/** The REST API version for the OpenAI text-to-speech API */
|
|
130
|
+
version?: "v1";
|
|
118
131
|
/** OpenAI TTS model */
|
|
119
|
-
model:
|
|
132
|
+
model: OpenAi.Model;
|
|
120
133
|
/** OpenAI voice */
|
|
121
|
-
voice:
|
|
134
|
+
voice: OpenAi.Voice;
|
|
122
135
|
}
|
|
123
|
-
namespace
|
|
136
|
+
namespace OpenAi {
|
|
124
137
|
/** OpenAI TTS model */
|
|
125
138
|
const Model: {
|
|
126
139
|
readonly Tts1: "tts-1";
|
|
@@ -142,8 +155,10 @@ export declare namespace AgentV1SettingsAgentSpeakOneItemProvider {
|
|
|
142
155
|
type: "aws_polly";
|
|
143
156
|
/** AWS Polly voice name */
|
|
144
157
|
voice: AgentV1SettingsAgentSpeakOneItemProviderAwsPolly.Voice;
|
|
145
|
-
/** Language code
|
|
146
|
-
|
|
158
|
+
/** Language code to use, e.g. 'en-US'. Corresponds to the `language_code` parameter in the AWS Polly API */
|
|
159
|
+
language: string;
|
|
160
|
+
/** Use the `language` field instead. */
|
|
161
|
+
language_code?: string;
|
|
147
162
|
engine: AgentV1SettingsAgentSpeakOneItemProviderAwsPolly.Engine;
|
|
148
163
|
credentials: AgentV1SettingsAgentSpeakOneItemProviderAwsPolly.Credentials;
|
|
149
164
|
}
|