Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"shouldGenerateWebsocketClients": true,
"enableForwardCompatibleEnums": true
},
"originGitCommit": "05bd7add608b322a6278fa20da22f2ed501d50ef",
"originGitCommit": "d1854cf6d560a0e27c9f46c1d83a6d7d9924f045",
"originGitCommitIsDirty": true,
"invokedBy": "manual",
"sdkVersion": "5.1.1"
Expand Down
24 changes: 24 additions & 0 deletions .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,27 @@ src/api/resources/manage/resources/v1/resources/projects/resources/keys/client/C
# CreateKeyV1RequestOne alias alongside CreateKeyV1Request. Swap to .bak before
# regen.
src/api/types/CreateKeyV1Request.ts

# src/api/resources/agent/resources/v1/types/AgentV1Settings.ts: backward-compat
# patch for the AgentV1Settings.Agent namespace. The 2026-05-06 regen restructured
# Agent from an interface with named sub-types (Agent.Context, Agent.Listen,
# Agent.Think, Agent.Speak, Agent.Context.Messages.Item) into a union with
# anonymous shapes plus a string variant ({...} | string) for the new
# agent-by-ID-string flow. We restore the original interface form so existing
# imports of the sub-types AND direct field reads (settings.agent.context, etc.)
# keep compiling without typeof narrowing. The new agent-by-ID-string variant is
# surfaced as the opt-in `AgentReference = Agent | string` alias for callers who
# want it in types. Mirrors the Python SDK's compat shims for the same regen.
# Regression coverage in tests/unit/compat-aliases.test.ts.
# Swap to .bak before regen.
src/api/resources/agent/resources/v1/types/AgentV1Settings.ts

# src/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.ts:
# the 2026-05-06 regen renamed this type to AgentV1SettingsAgentContextListenProvider
# (the new V2 adds an optional language_hint field). We replace the regenerated
# duplicate with a one-line type alias to the new canonical name so pinned-name
# callers (`const p: AgentV1SettingsAgentListenProvider = ...`) keep compiling
# without a cast. Purely additive at the type level — the old V2 is a subset of
# the new V2. Regression coverage in tests/unit/compat-aliases.test.ts.
# Swap to .bak before regen.
src/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.ts
52 changes: 8 additions & 44 deletions .github/.commitlintrc.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,16 @@
{
"extends": [
"@commitlint/config-conventional"
],
"extends": ["@commitlint/config-conventional"],
"rules": {
"type-enum": [
2,
"always",
[
"feat",
"fix",
"docs",
"style",
"refactor",
"perf",
"test",
"build",
"ci",
"chore",
"revert"
]
["feat", "fix", "docs", "style", "refactor", "perf", "test", "build", "ci", "chore", "revert"]
],
"type-case": [
2,
"always",
"lower-case"
],
"type-empty": [
2,
"never"
],
"scope-case": [
2,
"always",
"lower-case"
],
"subject-empty": [
2,
"never"
],
"subject-full-stop": [
2,
"never",
"."
],
"header-max-length": [
2,
"always",
100
]
"type-case": [2, "always", "lower-case"],
"type-empty": [2, "never"],
"scope-case": [2, "always", "lower-case"],
"subject-empty": [2, "never"],
"subject-full-stop": [2, "never", "."],
"header-max-length": [2, "always", 100]
}
}
2 changes: 1 addition & 1 deletion .github/.release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "5.1.0"
".": "5.1.0"
}
56 changes: 28 additions & 28 deletions .github/release-please-config.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"packages": {
".": {
"release-type": "node",
"package-name": "@deepgram/sdk",
"tag-separator": "",
"include-component-in-tag": false,
"include-v-in-tag": true,
"changelog-path": "CHANGELOG.md",
"bump-minor-pre-major": false,
"bump-patch-for-minor-pre-major": false,
"draft": false,
"extra-files": [
{
"type": "json",
"path": ".fern/metadata.json",
"jsonpath": "$.sdkVersion"
},
{
"type": "generic",
"path": "src/BaseClient.ts"
},
{
"type": "generic",
"path": "src/version.ts"
"packages": {
".": {
"release-type": "node",
"package-name": "@deepgram/sdk",
"tag-separator": "",
"include-component-in-tag": false,
"include-v-in-tag": true,
"changelog-path": "CHANGELOG.md",
"bump-minor-pre-major": false,
"bump-patch-for-minor-pre-major": false,
"draft": false,
"extra-files": [
{
"type": "json",
"path": ".fern/metadata.json",
"jsonpath": "$.sdkVersion"
},
{
"type": "generic",
"path": "src/BaseClient.ts"
},
{
"type": "generic",
"path": "src/version.ts"
}
]
}
]
}
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
},
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
}
19 changes: 7 additions & 12 deletions .mcp.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
{
"mcpServers": {
"deepgram-styles": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"-p",
"@deepgram/styles",
"mcp"
],
"env": {}
"mcpServers": {
"deepgram-styles": {
"type": "stdio",
"command": "npx",
"args": ["-y", "-p", "@deepgram/styles", "mcp"],
"env": {}
}
}
}
}
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Current temporarily frozen files:
`pnpm-lock.yaml` is **not** frozen — let Fern regenerate it, then run `pnpm install` after re-applying the `package.json` patch and the lockfile rebuilds correctly.
- `src/api/resources/manage/resources/v1/resources/projects/resources/keys/client/Client.ts` — keep `manage.v1.projects.keys.create(projectId, request?)` source-compatible with older callers that omit the request body, while still allowing the regenerated request form.
- `src/api/types/CreateKeyV1Request.ts` — preserve the old exported `CreateKeyV1RequestOne` alias alongside `CreateKeyV1Request` so existing type imports keep compiling.
- `src/api/resources/agent/resources/v1/types/AgentV1Settings.ts` — backward-compat patch for the `AgentV1Settings.Agent` namespace. The 2026-05-06 regen restructured `Agent` from an interface with named sub-types into a union with anonymous shapes plus a string variant (`{...} | string`) for the new agent-by-ID-string flow. We restore the original interface form so existing imports of the sub-types (`Agent.Context`, `Agent.Listen`, `Agent.Think`, `Agent.Speak`, `Agent.Context.Messages.Item`) AND direct field reads (`settings.agent.context`, `.greeting`, etc.) keep compiling in TS strict mode without a `typeof` narrowing guard. The new agent-by-ID-string variant is surfaced as the opt-in `AgentReference = Agent | string` alias for callers who want to pass a string ID at the type level. Mirrors the Python SDK's compat shims for the same regen. Regression coverage in `tests/unit/compat-aliases.test.ts`.
- `src/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.ts` — backward-compat alias for the type renamed by the 2026-05-06 regen to `AgentV1SettingsAgentContextListenProvider`. The new V2 only adds an optional `language_hint` field, so the regenerated duplicate is replaced with a one-line `type AgentV1SettingsAgentListenProvider = AgentV1SettingsAgentContextListenProvider` (plus namespace merge for `.V1`/`.V2` access). Purely additive at the type level — pinned-name callers (`const p: AgentV1SettingsAgentListenProvider = ...`) keep compiling without a cast. Regression coverage in `tests/unit/compat-aliases.test.ts`.

**Note:** If you need to patch a Fern-generated file, add it to `.fernignore` with a comment describing the patch, and add it to the "temporarily frozen" list above.

Expand Down
4 changes: 2 additions & 2 deletions context7.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"url": "https://context7.com/deepgram/deepgram-js-sdk",
"public_key": "pk_hu7APZeIXQ14hNyaCBm0A"
"url": "https://context7.com/deepgram/deepgram-js-sdk",
"public_key": "pk_hu7APZeIXQ14hNyaCBm0A"
}
38 changes: 19 additions & 19 deletions examples/01-authentication-api-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@ const { DeepgramClient } = require("../dist/cjs/index.js");

// Method 1: Pass API key in options object
const deepgramClient1 = new DeepgramClient({
apiKey: process.env.DEEPGRAM_API_KEY,
apiKey: process.env.DEEPGRAM_API_KEY,
});

// Method 2: Use environment variable (DEEPGRAM_API_KEY)
const deepgramClient2 = new DeepgramClient();

// Example usage: Verify authentication by listing projects
async function example() {
try {
const data = await deepgramClient1.manage.v1.projects.list();
if (data) {
console.log("Authentication successful! Projects:", JSON.stringify(data, null, 2));
} else {
console.error("No data returned from the API");
try {
const data = await deepgramClient1.manage.v1.projects.list();
if (data) {
console.log("Authentication successful! Projects:", JSON.stringify(data, null, 2));
} else {
console.error("No data returned from the API");
}
} catch (error) {
console.error("Error:", error);
}
} catch (error) {
console.error("Error:", error);
}

try {
const data = await deepgramClient2.manage.v1.projects.list();
if (data) {
console.log("Authentication successful! Projects:", JSON.stringify(data, null, 2));
} else {
console.error("No data returned from the API");
try {
const data = await deepgramClient2.manage.v1.projects.list();
if (data) {
console.log("Authentication successful! Projects:", JSON.stringify(data, null, 2));
} else {
console.error("No data returned from the API");
}
} catch (error) {
console.error("Error:", error);
}
} catch (error) {
console.error("Error:", error);
}
}

example();
108 changes: 54 additions & 54 deletions examples/02-authentication-access-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,68 @@ const { DeepgramClient } = require("../dist/cjs/index.js");

// Example: Generate an access token first, then use it
async function example() {
// First, create a client with API key to generate access token
const apiKeyClient = new DeepgramClient({
apiKey: process.env.DEEPGRAM_API_KEY,
});
// First, create a client with API key to generate access token
const apiKeyClient = new DeepgramClient({
apiKey: process.env.DEEPGRAM_API_KEY,
});

if (!process.env.DEEPGRAM_API_KEY) {
console.error("Error: DEEPGRAM_API_KEY environment variable is required");
process.exit(1);
}
if (!process.env.DEEPGRAM_API_KEY) {
console.error("Error: DEEPGRAM_API_KEY environment variable is required");
process.exit(1);
}

// Generate temporary access token
try {
const data = await apiKeyClient.auth.v1.tokens.grant({ });
console.log("Access token:", data.access_token);
console.log("Expires in:", data.expires_in, "seconds\n");
// Generate temporary access token
try {
const data = await apiKeyClient.auth.v1.tokens.grant({});
console.log("Access token:", data.access_token);
console.log("Expires in:", data.expires_in, "seconds\n");

// Use the access token in a new client instance
const tempClient = new DeepgramClient({ accessToken: data.access_token });
// Use the access token in a new client instance
const tempClient = new DeepgramClient({ accessToken: data.access_token });

// Verify the access token is actually being used (Bearer scheme, not Token)
const authRequest = await tempClient._options.authProvider.getAuthRequest();
const authHeader = authRequest.headers.Authorization;

console.log("Verifying access token is being used...");
console.log(`Authorization header: ${authHeader.substring(0, 30)}...`);

if (authHeader.startsWith("Bearer ")) {
const tokenInHeader = authHeader.substring(7);
if (tokenInHeader === data.access_token) {
console.log("✓ PASS: Access token is being used (Bearer scheme)\n");
} else {
console.error("✗ FAIL: Access token in header doesn't match provided token");
process.exit(1);
}
} else {
console.error(`✗ FAIL: Expected Bearer scheme, got: ${authHeader.substring(0, 30)}...`);
process.exit(1);
}
// Verify the access token is actually being used (Bearer scheme, not Token)
const authRequest = await tempClient._options.authProvider.getAuthRequest();
const authHeader = authRequest.headers.Authorization;

console.log("Verifying access token is being used...");
console.log(`Authorization header: ${authHeader.substring(0, 30)}...`);

// Now use the temporary client to verify it works
// Note: Access tokens from grant() have usage:write permission for voice APIs,
// but NOT for Manage APIs. So we verify with auth.v1.tokens.get() instead.
const text = `The history of the phrase 'The quick brown fox jumps over the lazy dog'.
if (authHeader.startsWith("Bearer ")) {
const tokenInHeader = authHeader.substring(7);
if (tokenInHeader === data.access_token) {
console.log("✓ PASS: Access token is being used (Bearer scheme)\n");
} else {
console.error("✗ FAIL: Access token in header doesn't match provided token");
process.exit(1);
}
} else {
console.error(`✗ FAIL: Expected Bearer scheme, got: ${authHeader.substring(0, 30)}...`);
process.exit(1);
}

// Now use the temporary client to verify it works
// Note: Access tokens from grant() have usage:write permission for voice APIs,
// but NOT for Manage APIs. So we verify with auth.v1.tokens.get() instead.
const text = `The history of the phrase 'The quick brown fox jumps over the lazy dog'.
The earliest known apperance of the phrase was in The Boston Journal.
This phrase is commonly used for typing practice and testing keyboards.`;

try {
const data = await tempClient.read.v1.text.analyze({
body: { text },
language: "en",
summarize: true, // Enable at least one feature
// Add more text intelligence options as needed
});

console.log("Analysis result:", JSON.stringify(data, null, 2));
} catch (error) {

try {
const data = await tempClient.read.v1.text.analyze({
body: { text },
language: "en",
summarize: true, // Enable at least one feature
// Add more text intelligence options as needed
});

console.log("Analysis result:", JSON.stringify(data, null, 2));
} catch (error) {
console.error("Error:", error);
}
} catch (error) {
console.error("Error:", error);
}
} catch (error) {
console.error("Error:", error);
process.exit(1);
}
process.exit(1);
}
}

// WORKS!
Expand Down
Loading
Loading