Node SDK

Official Node.js SDK for Deepgram's automated speech recognition APIs.

This guide documents all the functionality available in the Deepgram Node.js SDK, and explains in detail how the library works. All the official Deepgram SDKs are open source. To learn more about this SDK specifically, visit the Node.js SDK repository on GitHub.

📘

Node Version

Currently, the Deepgram Node SDK supports Node.js 14.14.37 and higher.

Pre-requisites

Before using the Node.js SDK, you'll need to do a few things.

Create a Deepgram Account

Before you can use Deepgram products, you'll need to create a Deepgram account. Signup is free and includes:

$200 in credit, which gives you access to:

  • all base models
  • pre-recorded and streaming functionality
  • all features

Create a Deepgram API Key

To access Deepgram’s API, you'll need to create a Deepgram API Key. Make note of your API Key; you will need it later.

Installation

You can install the Deepgram Node.js SDK as a dependency in your application using NPM or yarn. Here's how:

With NPM

npm install @deepgram/sdk

With Yarn

yarn add @deepgram/sdk

Initialization

Once the SDK is installed, import the Deepgram object. The method for importing will vary based on your use case.

Node

In Node applications, import the Deepgram object from @deepgram/sdk.

const { Deepgram } = require("@deepgram/sdk");

Browser

When using the Deepgram SDK in a front-end application, import the Deepgram object from @deepgram/sdk/browser.

import { Deepgram } from "@deepgram/sdk/browser";

Instantiating the Client

With the Deepgram object imported, create a new instance specifying your API key so that your application will be authorized to connect to Deepgram.

const deepgram = new Deepgram(DEEPGRAM_API_KEY);

With the Deepgram client initialized, you can now send requests to the Deepgram API to transcribe audio, manage projects & keys, and retrieve usage information.

Custom API Endpoint

In order to point the SDK at a different API endpoint (e.g., for on-prem deployments), you can pass in an object setting the API_URL when initializing the Deepgram client.

const REQUIRE_SSL = false; // defaults to true - set depending on server configuration
const API_URL = "localhost:8080"; // defaults to api.deepgram.com
const deepgram = new Deepgram(DEEPGRAM_API_KEY, API_URL, REQUIRE_SSL);