### Install Dependencies and Start Server Source: https://developers.deepgram.com/docs/build-voice-agent-with-twilio-deepgram-openai Install the project's Node.js dependencies and start the server. Requires Node.js v12.1.0 or later. ```shell npm install npm run start ``` -------------------------------- ### Start the Client Development Server Source: https://developers.deepgram.com/docs/pipecat-integration In a separate terminal, navigate to the client directory, install dependencies, and start the development server. ```bash cd my-bot/client npm install npm run dev ``` -------------------------------- ### Install Modal CLI Source: https://developers.deepgram.com/docs/deploy-deepgram-on-modal Installs the Modal CLI and performs initial setup. Ensure you have Python and pip installed. ```bash pip install modal modal setup ``` -------------------------------- ### Install and Start Node Media Server Source: https://developers.deepgram.com/docs/integrate-deepgram-with-zoom Installs and starts the Node Media Server globally, which is used to receive and view RTMP stream data from Zoom. ```bash npm i node-media-server -g && node-media-server ``` -------------------------------- ### Python SDK Migration Example Setup Source: https://developers.deepgram.com/docs/pre-recorded-audio This Python snippet shows the basic import structure for using the Deepgram client. Refer to the provided GitHub link for comprehensive migration guides. ```python # For more Python SDK migration guides, visit: # https://github.com/deepgram/deepgram-python-sdk/tree/main/docs # main.py (python example) import os from deepgram import ( DeepgramClient, ) ``` -------------------------------- ### Start MCP Server (Default) Source: https://developers.deepgram.com/developer-tools/cli/mcp-server Starts the MCP server using the default stdio transport. This is the simplest way to get the server running. ```shell dg mcp ``` -------------------------------- ### Install Deepgram Go SDK Source: https://developers.deepgram.com/docs/pre-recorded-audio Install the Deepgram Go SDK using the go get command. ```shell # Install the Deepgram Go SDK # https://github.com/deepgram/deepgram-go-sdk go get github.com/deepgram/deepgram-go-sdk ``` -------------------------------- ### Python SDK Migration Guide Placeholder Source: https://developers.deepgram.com/docs/text-to-speech This is a placeholder for Python SDK migration guides. Specific code examples for Python text-to-speech generation would be provided here. ```python # For more Python SDK migration guides, visit: ``` -------------------------------- ### Get Project Balances (Java) Source: https://developers.deepgram.com/reference/manage/billing/get This Java example uses the Unirest library to make a GET request for project balance data. Remember to replace `` with your actual API key. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/balances/123456-7890-1234-5678-901234") .header("Authorization", "Token ") .header("Content-Type", "application/json") .body("{}") .asString(); ``` -------------------------------- ### Python SDK Example Source: https://developers.deepgram.com/reference/voice-agent/agent-configurations/update-agent-metadata Use the Python requests library to update agent metadata. Ensure you have the library installed. ```python import requests url = "https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/agents/a1b2c3d4-e5f6-7890-abcd-ef1234567890" payload = {} headers = { "Authorization": "Token ", "Content-Type": "application/json" } response = requests.put(url, json=payload, headers=headers) print(response.json()) ``` -------------------------------- ### Get API Key Details (Ruby) Source: https://developers.deepgram.com/reference/manage/keys/get This Ruby example shows how to retrieve API key information using the `Net::HTTP` library. It sets up the URI, creates a GET request, adds the authorization header, and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/keys/123456789012345678901234") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Token ' response = http.request(request) puts response.read_body ``` -------------------------------- ### Set up Project Environment Source: https://developers.deepgram.com/docs/build-a-voice-agent-go Create a new project directory, initialize a Go module, and create the main Go file. ```shell mkdir deepgram-agent-demo cd deepgram-agent-demo go mod init deepgram-agent-demo touch main.go ``` -------------------------------- ### Get Distribution Credentials (PHP) Source: https://developers.deepgram.com/reference/self-hosted/distribution-credentials/get A PHP example using Guzzle HTTP client to fetch distribution credentials. This requires the Guzzle library to be installed via Composer. ```php request('GET', 'https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/self-hosted/distribution/credentials/8b36cfd0-472f-4a21-833f-2d6343c3a2f3', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Run Setup Wizard for Deployment Source: https://developers.deepgram.com/docs/inbound-telephony-agent Execute the setup script to configure Twilio, deploy to Fly.io, and automatically set up webhooks. ```bash python setup.py ``` -------------------------------- ### Get API Key Details (PHP) Source: https://developers.deepgram.com/reference/manage/keys/get This PHP example uses the Guzzle HTTP client to fetch API key details. Make sure you have installed Guzzle via Composer and included the autoloader. ```php request('GET', 'https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/keys/123456789012345678901234', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Analyze Text with PHP SDK Source: https://developers.deepgram.com/reference/text-intelligence/analyze-text This PHP example shows the initial setup for using the Guzzle HTTP client to interact with the Deepgram API for text analysis. Ensure Guzzle is installed via Composer. ```php ' with your Deepgram API key. ```php request('GET', 'https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/models/af6e9977-99f6-4d8f-b6f5-dfdf6fb6e291', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### start() Source: https://developers.deepgram.com/docs/browser-agent-javascript Requests microphone permission and begins capturing audio frames. ```APIDOC ## start() ### Description Requests microphone permission via `getUserMedia` and begins capturing audio frames. ### Method `start(): Promise` ### Example ```javascript await mic.start(); ``` ``` -------------------------------- ### Run the Mock Server Source: https://developers.deepgram.com/docs/getting-started-with-the-streaming-test-suite Start the mock server to test custom audio streams in a simplified environment. This server echoes received audio data and saves it to a file. ```bash python server.py ``` -------------------------------- ### Full Widget Configuration Reference Source: https://developers.deepgram.com/docs/browser-agent-widget This snippet provides a comprehensive reference for all available initialization options, including authentication, agent settings, layout, features, theming, callbacks, and network configuration. ```javascript init({ // -- Auth (one required) -- apiKey: "...", // Development only tokenFactory: () => Promise, // Production // -- Agent -- agent: "AGENT_ID" | AgentSettingsObject, // Required overrides: { systemPrompt, greeting }, // -- Layout -- layout: "sidebar", // sidebar | inline | floating // button | embedded | orb placement: "bottom-right", // FAB position containerId: "my-element", // Required for inline / embedded buttonId: "my-button", // External trigger element defaultOpen: false, // Start panel open (sidebar/floating) dismissible: true, // Allow close/dismiss // -- Features -- vad: false | { speechThreshold, silenceThreshold }, showTranscript: true, showMicToggle: true, showSpeakerToggle: true, showTextInput: true, // -- Text -- text: { name, startLabel, stopLabel, connectingLabel, inputPlaceholder, emptyStateHint, }, // -- Theming -- colorScheme: "auto" | "light" | "dark" | { mode: "class", darkSelector, lightSelector }, theme: { /* design tokens listed above */ }, // -- Callbacks -- on: { onConnect, onDisconnect, onError, onMessage, onAgentStartedSpeaking, onFunctionCallRequest, onAgentError, onReconnecting, }, // -- Audio -- playerSampleRate: 24_000, // Agent audio sample rate // -- Network -- url: "wss://...", // Custom WebSocket URL (proxy) }); ``` -------------------------------- ### Configure Environment Variables Source: https://developers.deepgram.com/docs/multi-agent-architecture Copies the example environment file and instructs users to fill in their API keys and credentials. ```bash cp .env.example .env ``` -------------------------------- ### Generate Speech with Deepgram SDK (Go) Source: https://developers.deepgram.com/docs/the-deepgram-model-improvement-partnership-program This Go example shows how to generate speech audio using the Deepgram SDK and opt out of the Model Improvement Program. Install the SDK with `go get github.com/deepgram/deepgram-go-sdk`. The `mip_opt_out` parameter is passed via custom context parameters. ```go // Install the SDK: go get github.com/deepgram/deepgram-go-sdk package main import ( "context" "encoding/json" "fmt" "os" prettyjson "github.com/hokaccha/go-prettyjson" api "github.com/deepgram/deepgram-go-sdk/pkg/api/speak/v1/rest" interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" client "github.com/deepgram/deepgram-go-sdk/pkg/client/speak" ) const ( textToSpeech string = "Hello, World!" filePath string = "./test.wav" ) func main() { // init library client.Init(client.InitLib{ LogLevel: client.LogLevelTrace, // LogLevelDefault, LogLevelFull, LogLevelDebug, LogLevelTrace }) // Go context ctx := context.Background() // set the Transcription options options := &interfaces.SpeakOptions{ Model: "aura-2-thalia-en", Encoding: "linear16", SampleRate: 48000, } // Custom option to opt out of Model Improvement Program params := make(map[string][]string, 0) params["mip_opt_out"] = []string{"true"} ctx = interfaces.WithCustomParameters(ctx, params) // create a Deepgram client c := client.NewRESTWithDefaults() dg := api.New(c) // send/process file to Deepgram res, err := dg.ToSave(ctx, filePath, textToSpeech, options) if err != nil { fmt.Printf("FromStream failed. Err: %v\n", err) os.Exit(1) } data, err := json.Marshal(res) if err != nil { fmt.Printf("json.Marshal failed. Err: %v\n", err) os.Exit(1) } // make the JSON pretty prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } ``` -------------------------------- ### List Projects (Go HTTP Client) Source: https://developers.deepgram.com/reference/manage/projects/list Retrieve your projects using Go's built-in HTTP client. This example demonstrates setting headers and sending a GET request. Remember to replace '' with your actual API key. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.deepgram.com/v1/projects" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Token ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Install Deepgram Helm Chart Source: https://developers.deepgram.com/docs/self-managed-kubernetes Install the Deepgram self-hosted Helm chart using your custom `values.yaml` file. Monitor the installation progress using `kubectl get all`. ```shell helm install deepgram deepgram/deepgram-self-hosted \ -f my-values.yaml \ --namespace dg-self-hosted \ --atomic \ --timeout 1h # Monitor the installation in a separate shell watch kubectl get all ``` -------------------------------- ### Create Distribution Credentials (Ruby) Source: https://developers.deepgram.com/reference/self-hosted/distribution-credentials/create A Ruby example demonstrating how to create distribution credentials using the built-in 'net/http' and 'uri' libraries. ```ruby require 'uri' require 'net/http' url = URI("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/self-hosted/distribution/credentials") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Token ' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Go HTTP Client Example Source: https://developers.deepgram.com/reference/voice-agent/agent-configurations/update-agent-metadata This Go example demonstrates updating agent metadata using the standard net/http package. It includes reading the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/agents/a1b2c3d4-e5f6-7890-abcd-ef1234567890" payload := strings.NewReader("{}") req, _ := http.NewRequest("PUT", url, payload) req.Header.Add("Authorization", "Token ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Alternative Setup Wizard Modes Source: https://developers.deepgram.com/docs/inbound-telephony-agent Utilize different modes of the setup wizard for specific configurations, such as skipping Fly.io deployment or updating Twilio webhook URLs. ```bash python setup.py --twilio-only # Skip Fly.io, provide your own URL python setup.py --update-url URL # Quick Twilio webhook URL update python setup.py --status # Show current config python setup.py --teardown # Clean up deployment ``` -------------------------------- ### Get Distribution Credentials (Ruby) Source: https://developers.deepgram.com/reference/self-hosted/distribution-credentials/get A Ruby example using the `net/http` library to make a GET request for distribution credentials. It sets the necessary Authorization header. ```ruby require 'uri' require 'net/http' url = URI("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/self-hosted/distribution/credentials/8b36cfd0-472f-4a21-833f-2d6343c3a2f3") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Token ' response = http.request(request) puts response.read_body ``` -------------------------------- ### Get Billing Fields (JavaScript) Source: https://developers.deepgram.com/reference/manage/billing/fields/get Use the `fetch` API to make a GET request to the billing fields endpoint. This example includes basic error handling. ```javascript const url = 'https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/billing/fields'; const options = {method: 'GET', headers: {Authorization: 'Token '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Start WebSocket Server Source: https://developers.deepgram.com/docs/twilio-and-deepgram-voice-agent This snippet shows how to start a WebSocket server using `websockets.serve` and prints the server address. It then runs the server indefinitely using `asyncio`'s event loop. ```python server = websockets.serve(router, "localhost", 5000) print("Server starting on ws://localhost:5000") asyncio.get_event_loop().run_until_complete(server) asyncio.get_event_loop().run_forever() ``` -------------------------------- ### Setup Wizard Modes Source: https://developers.deepgram.com/docs/outbound-telephony-agent Provides various modes for the setup wizard, including configuring Twilio-only, checking status, tearing down deployments, and redeploying. ```bash # Other setup wizard modes: python setup.py --twilio-only # Skip Fly.io, provide your own URL python setup.py --status # Show current config python setup.py --teardown # Clean up deployment python setup.py --redeploy # Redeploy to pick up code changes or .env changes ``` -------------------------------- ### PHP Guzzle Example Source: https://developers.deepgram.com/reference/voice-agent/agent-configurations/update-agent-metadata Update agent metadata with PHP using the Guzzle HTTP client. This example requires the Guzzle HTTP client to be installed via Composer. ```php request('PUT', 'https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/agents/a1b2c3d4-e5f6-7890-abcd-ef1234567890', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Token ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` -------------------------------- ### Ready Status Example Source: https://developers.deepgram.com/docs/self-hosted-status-endpoint The 'Ready' status indicates that a backend Engine is available after initialization. No inference requests have been processed yet. ```json { "system_health": "Ready", "active_batch_requests": 2, "active_stream_requests": 1, "active_listen_v2_stream_requests": 0 } ``` -------------------------------- ### Get Agent Variable (JavaScript) Source: https://developers.deepgram.com/reference/voice-agent/agent-variables/get-agent-variable Utilize the fetch API in JavaScript to get an agent variable. This example demonstrates setting up the request URL, options, and handling the response. ```javascript const url = 'https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/agent-variables/v1a2b3c4-d5e6-7890-abcd-ef1234567890'; const options = { method: 'GET', headers: {Authorization: 'Token ', 'Content-Type': 'application/json'}, body: '{}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Create Agent Configuration using Go HTTP Client Source: https://developers.deepgram.com/reference/voice-agent/agent-configurations/create-agent-configuration Use Go's standard HTTP client to create an agent configuration. This example demonstrates setting headers and the request body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/agents" payload := strings.NewReader("{\n \"config\": \"{\\\"language\\\":\\\"en-US\\\",\\\"model\\\":\\\"general\\\",\\\"punctuate\\\":true,\\\"profanity_filter\\\":false}\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Token ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Apply Multiple Settings Source: https://developers.deepgram.com/docs/configure-sagemaker-deployments Demonstrates how to apply multiple configuration settings to both the engine and API server using incrementing suffixes. ```bash DEEPGRAM_ENGINE_01=chunking.streaming.step=0.5 DEEPGRAM_ENGINE_02=health.gpu_required=true DEEPGRAM_API_01=features.listen_v2=true DEEPGRAM_API_02=features.topic_detection=false ``` -------------------------------- ### Get Distribution Credentials (Swift) Source: https://developers.deepgram.com/reference/self-hosted/distribution-credentials/get A Swift example using `URLSession` to perform a GET request for distribution credentials. It sets up the request with the correct URL and authorization header. ```swift import Foundation let headers = ["Authorization": "Token "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/self-hosted/distribution/credentials/8b36cfd0-472f-4a21-833f-2d6343c3a2f3")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Create Project Directory and File Source: https://developers.deepgram.com/docs/build-a-voice-agent-python Create a new directory for your project and a Python file to store your agent code. ```shell mkdir deepgram-agent-demo cd deepgram-agent-demo touch main.py ``` -------------------------------- ### Get Billing Breakdown with C# RestSharp Source: https://developers.deepgram.com/reference/manage/billing/breakdown/get Use the RestSharp library in C# to make a GET request for billing breakdown data. This example demonstrates basic usage. ```csharp using RestSharp; var client = new RestClient("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/billing/breakdown?accessor=12345678-1234-1234-1234-123456789012&deployment=hosted&tag=tag1&line_item=streaming%3A%3Anova-3&grouping=%5B%22deployment%22%2C%22line_item%22%5D"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Token "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### List Agent Configurations (Swift) Source: https://developers.deepgram.com/reference/voice-agent/agent-configurations/list-agent-configurations This Swift example demonstrates fetching agent configurations using `URLSession`. Ensure your API key is correctly set in the `Authorization` header. ```swift import Foundation let headers = [ "Authorization": "Token ", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/agents")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Get Purchases using PHP GuzzleHttp Source: https://developers.deepgram.com/reference/manage/billing/purchases/get This PHP example uses the GuzzleHttp client to retrieve purchase records. It shows how to set the Authorization header for the GET request. ```php request('GET', 'https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/purchases', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ``` -------------------------------- ### Speech Started JSON Event Source: https://developers.deepgram.com/docs/speech-started This is an example of the JSON message received when the Speech Started event is detected. It includes the event type, channel information, and the timestamp of speech detection. ```JSON { "type": "SpeechStarted", "channel": [ 0, 1 ], "timestamp": 9.54 } ``` -------------------------------- ### Initialize Node.js Agent Project Source: https://developers.deepgram.com/docs/livekit-integration Use the LiveKit CLI to scaffold a new Node.js agent project. Installs dependencies using npm. ```bash lk agent init my-agent --template agent-starter-node cd my-agent npm install ``` -------------------------------- ### Get Agent Variable (Ruby) Source: https://developers.deepgram.com/reference/voice-agent/agent-variables/get-agent-variable A Ruby example demonstrating how to fetch an agent variable using Net::HTTP. It covers setting the URL, headers, and making the GET request. ```ruby require 'uri' require 'net/http' url = URI("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/agent-variables/v1a2b3c4-d5e6-7890-abcd-ef1234567890") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Token ' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Get Agent Configuration with Java (Unirest) Source: https://developers.deepgram.com/reference/voice-agent/agent-configurations/get-agent-configuration This Java example uses the Unirest library to make a GET request for agent configuration. Replace `` with your actual API key. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/agents/a1b2c3d4-e5f6-7890-abcd-ef1234567890") .header("Authorization", "Token ") .header("Content-Type", "application/json") .body("{}") .asString(); ``` -------------------------------- ### Initialize Project and Environment Variables Source: https://developers.deepgram.com/docs/build-a-voice-agent-javascript Sets up a new project directory, initializes npm, creates an index.js file, and exports the Deepgram API key as an environment variable. ```shell mkdir deepgram-agent-demo cd deepgram-agent-demo npm init -y touch index.js export DEEPGRAM_API_KEY="your_api_key" ``` -------------------------------- ### Running the Application Source: https://developers.deepgram.com/docs/text-intelligence Instructions on how to execute the Deepgram SDK examples from the terminal. ```javascript # Run your application using the file you created in the previous step # Example: node index.js node index.js ``` ```shell # Run your application using the file you created in the previous step # Example: python deepgram_test.py python YOUR_PROJECT_NAME.py ``` ```shell # Run your application using the file you created in the previous step # Example: go run main.go go run YOUR_PROJECT_NAME.go ``` ```shell mvn compile exec:java -Dexec.mainClass="Main" ``` -------------------------------- ### Get Distribution Credentials (C#) Source: https://developers.deepgram.com/reference/self-hosted/distribution-credentials/get This C# example uses the RestSharp library to make a GET request for distribution credentials. It configures the client and adds the necessary authorization header. ```csharp using RestSharp; var client = new RestClient("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/self-hosted/distribution/credentials/8b36cfd0-472f-4a21-833f-2d6343c3a2f3"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Token "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Get Billing Breakdown with Swift URLSession Source: https://developers.deepgram.com/reference/manage/billing/breakdown/get Fetch billing breakdown data using Swift's URLSession. This example shows how to set headers and make a GET request. ```swift import Foundation let headers = ["Authorization": "Token "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/billing/breakdown?accessor=12345678-1234-1234-1234-123456789012&deployment=hosted&tag=tag1&line_item=streaming%3A%3Anova-3&grouping=%5B%22deployment%22%2C%22line_item%22%5D")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Run Python Example Script Source: https://developers.deepgram.com/docs/using-interim-results Execute the provided Python script to process an audio file and display interim and final transcripts with their 'is_final' status. ```shell python3 show-final.py -k 'YOUR_DEEPGRAM_API_KEY' /PATH/TO/AUDIO.wav ``` -------------------------------- ### Get Project Balances (C#) Source: https://developers.deepgram.com/reference/manage/billing/get This C# example uses RestSharp to make a GET request for project balance data. Replace `` with your actual Deepgram API key. ```csharp using RestSharp; var client = new RestClient("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/balances/123456-7890-1234-5678-901234"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Token "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` -------------------------------- ### List Agent Variables (Go) Source: https://developers.deepgram.com/reference/voice-agent/agent-variables/list-agent-variables This Go example demonstrates making an HTTP GET request to list agent variables. It includes setting headers and reading the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/agent-variables" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Token ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### List API Keys using Go Source: https://developers.deepgram.com/reference/manage/keys/list This Go program demonstrates how to fetch your project's API keys by making an HTTP GET request. It prints the response status and body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/keys" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Token ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Distribution Credentials (Java) Source: https://developers.deepgram.com/reference/self-hosted/distribution-credentials/get This Java example uses the Unirest library to send a GET request to retrieve distribution credential information. Ensure Unirest is included in your project dependencies. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/self-hosted/distribution/credentials/8b36cfd0-472f-4a21-833f-2d6343c3a2f3") .header("Authorization", "Token ") .asString(); ``` -------------------------------- ### List Project Invites using Go HTTP Client Source: https://developers.deepgram.com/reference/manage/invites/list This Go program demonstrates how to list project invites using the standard net/http package. It prints the response status and body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/invites" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Token ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get API Key Details (Swift) Source: https://developers.deepgram.com/reference/manage/keys/get This Swift example demonstrates fetching API key details using `URLSession`. It sets up an `NSMutableURLRequest` with the GET method and the required authorization header. ```swift import Foundation let headers = ["Authorization": "Token "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/keys/123456789012345678901234")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Get Purchases using Swift URLSession Source: https://developers.deepgram.com/reference/manage/billing/purchases/get This Swift example uses URLSession to make a GET request for purchase history. It includes setting up the request headers and handling the response asynchronously. ```swift import Foundation let headers = ["Authorization": "Token "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/purchases")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Start the Flask Development Server Source: https://developers.deepgram.com/docs/transcribe-recorded-calls-with-twilio Run the Flask application to start the server for the recorded call transcription project. ```bash FLASK_APP=server.py FLASK_ENV=development flask run ``` -------------------------------- ### List Requests with Query Parameters (Go) Source: https://developers.deepgram.com/reference/manage/requests/list This Go program demonstrates how to list requests using query parameters to filter by accessor, request ID, deployment, endpoint, method, and status. It utilizes the standard Go HTTP client. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/requests?accessor=12345678-1234-1234-1234-123456789012&request_id=12345678-1234-1234-1234-123456789012&deployment=hosted&endpoint=listen&method=async&status=succeeded" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Token ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### C# - Get Usage Breakdown Source: https://developers.deepgram.com/reference/manage/usage/breakdown/get This C# example uses the RestSharp library to make a GET request for usage breakdown data. It shows how to configure the client and add the necessary Authorization header. ```csharp using RestSharp; var client = new RestClient("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/usage/breakdown?accessor=12345678-1234-1234-1234-123456789012&alternatives=true&callback_method=true&callback=true&channels=true&custom_intent_mode=true&custom_intent=true&custom_topic_mode=true&custom_topic=true&deployment=hosted&detect_entities=true&detect_language=true&diarize=true&dictation=true&encoding=true&endpoint=listen&extra=true&filler_words=true&intents=true&keyterm=true&keywords=true&language=true&measurements=true&method=async&model=6f548761-c9c0-429a-9315-11a1d28499c8&multichannel=true&numerals=true¶graphs=true&profanity_filter=true&punctuate=true&redact=true&replace=true&search=true&sentiment=true&smart_format=true&summarize=true&tag=tag1&topics=true&utt_split=true&utterances=true&version=true"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Token "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Get Usage Breakdown with Ruby Net::HTTP Source: https://developers.deepgram.com/reference/manage/usage/breakdown/get This Ruby example demonstrates how to construct a URI and make an HTTP GET request to the usage breakdown API using the Net::HTTP library. ```ruby require 'uri' require 'net/http' url = URI("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/usage/breakdown?accessor=12345678-1234-1234-1234-123456789012&alternatives=true&callback_method=true&callback=true&channels=true&custom_intent_mode=true&custom_intent=true&custom_topic_mode=true&custom_topic=true&deployment=hosted&detect_entities=true&detect_language=true&diarize=true&dictation=true&encoding=true&endpoint=listen&extra=true&filler_words=true&intents=true&keyterm=true&keywords=true&language=true&measurements=true&method=async&model=6f548761-c9c0-429a-9315-11a1d28499c8&multichannel=true&numerals=true¶graphs=true&profanity_filter=true&punctuate=true&redact=true&replace=true&search=true&sentiment=true&smart_format=true&summarize=true&tag=tag1&topics=true&utt_split=true&utterances=true&version=true") ``` -------------------------------- ### Get Billing Breakdown with Ruby Net::HTTP Source: https://developers.deepgram.com/reference/manage/billing/breakdown/get Fetch billing breakdown data using Ruby's built-in Net::HTTP library. This example shows a basic GET request. ```ruby require 'uri' require 'net/http' url = URI("https://api.deepgram.com/v1/projects/123456-7890-1234-5678-901234/billing/breakdown?accessor=12345678-1234-1234-1234-123456789012&deployment=hosted&tag=tag1&line_item=streaming%3A%3Anova-3&grouping=%5B%22deployment%22%2C%22line_item%22%5D") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Token ' response = http.request(request) puts response.read_body ```