| name | deepgram-multi-env-setup |
| description | Configure Deepgram multi-environment setup for dev, staging, and production.
Use when setting up environment-specific configurations, managing multiple
Deepgram projects, or implementing environment isolation.
Trigger with phrases like "deepgram environments", "deepgram staging",
"deepgram dev prod", "multi-environment deepgram", "deepgram config".
|
| allowed-tools | Read, Write, Edit, Bash(kubectl:*), Bash(curl:*) |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
Deepgram Multi-Environment Setup
Overview
Configure isolated Deepgram environments for development, staging, and production with proper configuration management.
Prerequisites
- Access to Deepgram Console
- Multiple Deepgram projects (recommended)
- Environment management system
- Secret management solution
Environment Strategy
| Environment | Purpose | API Key Scope | Model | Rate Limits |
|---|
| Development | Local testing | Dev project | base | Low |
| Staging | Pre-prod testing | Staging project | nova-2 | Medium |
| Production | Live traffic | Prod project | nova-2 | High |
Instructions
Step 1: Create Deepgram Projects
Create separate projects in Deepgram Console for each environment.
Step 2: Configure API Keys
Generate environment-specific API keys with appropriate scopes.
Step 3: Implement Config Management
Create configuration system for environment switching.
Step 4: Set Up Secret Management
Securely store and access API keys per environment.
Examples
Environment Configuration
interface DeepgramConfig {
apiKey: string;
projectId: string;
model: string;
features: {
diarization: boolean;
smartFormat: boolean;
punctuate: boolean;
};
limits: {
maxConcurrent: number;
maxDurationMinutes: number;
};
callbacks: {
baseUrl: string;
};
}
const configs: Record<string, DeepgramConfig> = {
development: {
apiKey: process.env.DEEPGRAM_API_KEY_DEV!,
projectId: process.env.DEEPGRAM_PROJECT_ID_DEV!,
model: 'base',
features: {
diarization: false,
smartFormat: true,
punctuate: true,
},
limits: {
maxConcurrent: 5,
maxDurationMinutes: 10,
},
callbacks: {
baseUrl: ,
},
},
: {
: process..!,
: process..!,
: ,
: {
: ,
: ,
: ,
},
: {
: ,
: ,
},
: {
: ,
},
},
: {
: process..!,
: process..!,
: ,
: {
: ,
: ,
: ,
},
: {
: ,
: ,
},
: {
: ,
},
},
};
(): {
env = process.. || ;
config = configs[env];
(!config) {
();
}
(!config.) {
();
}
config;
}
Environment-Aware Client Factory
import { createClient, DeepgramClient } from '@deepgram/sdk';
import { getConfig } from '../config/deepgram';
let clients: Map<string, DeepgramClient> = new Map();
export function getDeepgramClient(): DeepgramClient {
const config = getConfig();
const env = process.env.NODE_ENV || 'development';
if (!clients.has(env)) {
clients.set(env, createClient(config.apiKey));
}
return clients.get(env)!;
}
export function resetClients(): void {
clients.clear();
}
export async function transcribe(audioUrl: string) {
const client = getDeepgramClient();
const config = getConfig();
{ result, error } = client...(
{ : audioUrl },
{
: config.,
: config..,
: config..,
: config..,
}
);
(error) error;
result;
}
Docker Compose Multi-Environment
version: '3.8'
x-common: &common
build: .
restart: unless-stopped
services:
app-dev:
<<: *common
container_name: deepgram-dev
environment:
- NODE_ENV=development
- DEEPGRAM_API_KEY=${DEEPGRAM_API_KEY_DEV}
- DEEPGRAM_PROJECT_ID=${DEEPGRAM_PROJECT_ID_DEV}
ports:
- "3000:3000"
profiles:
- development
app-staging:
<<: *common
container_name: deepgram-staging
environment:
- NODE_ENV=staging
- DEEPGRAM_API_KEY=${DEEPGRAM_API_KEY_STAGING}
- DEEPGRAM_PROJECT_ID=${DEEPGRAM_PROJECT_ID_STAGING}
ports:
- "3001:3000"
profiles:
- staging
app-production:
<<: *common
container_name: deepgram-prod
environment:
Kubernetes ConfigMaps and Secrets
apiVersion: v1
kind: ConfigMap
metadata:
name: deepgram-config
data:
MODEL: "nova-2"
SMART_FORMAT: "true"
PUNCTUATE: "true"
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
configMapGenerator:
- name: deepgram-config
behavior: merge
literals:
- NODE_ENV=development
- MODEL=base
- MAX_CONCURRENT=5
secretGenerator:
- name: deepgram-secrets
literals:
- API_KEY=${DEEPGRAM_API_KEY_DEV}
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
configMapGenerator:
Environment Validation Script
import { createClient } from '@deepgram/sdk';
interface EnvValidation {
environment: string;
valid: boolean;
apiKeyValid: boolean;
projectAccess: boolean;
features: string[];
errors: string[];
}
async function validateEnvironment(
name: string,
apiKey: string,
projectId: string
): Promise<EnvValidation> {
const result: EnvValidation = {
environment: name,
valid: false,
apiKeyValid: false,
projectAccess: false,
features: [],
errors: [],
};
if (!apiKey) {
result.errors.push('API key not set');
return result;
}
try {
const client = createClient(apiKey);
const { : projectsResult, : projectsError } =
client..();
(projectsError) {
result..();
result;
}
result. = ;
project = projectsResult..( p. === projectId);
(!project) {
result..();
} {
result. = ;
}
{ : transcribeError } = client...(
{ : },
{ : }
);
(!transcribeError) {
result..();
}
result. = result. && result.;
} (error) {
result..(error ? error. : );
}
result;
}
() {
environments = [
{
: ,
: process..!,
: process..!,
},
{
: ,
: process..!,
: process..!,
},
{
: ,
: process..!,
: process..!,
},
];
.();
( env environments) {
result = (env., env., env.);
.();
.();
.();
.();
(result.. > ) {
.();
}
(result.. > ) {
.();
result..( .());
}
.();
}
}
().(.);
Terraform Multi-Environment
# terraform/modules/deepgram/main.tf
variable "environment" {
type = string
}
variable "deepgram_api_key" {
type = string
sensitive = true
}
variable "config" {
type = object({
model = string
max_concurrent = number
})
}
# Store API key in secret manager
resource "aws_secretsmanager_secret" "deepgram_api_key" {
name = "deepgram/${var.environment}/api-key"
}
resource "aws_secretsmanager_secret_version" "deepgram_api_key" {
secret_id = aws_secretsmanager_secret.deepgram_api_key.id
secret_string = var.deepgram_api_key
}
# terraform/environments/production/main.tf
module "deepgram" {
source = "../../modules/deepgram"
environment = "production"
deepgram_api_key = var.deepgram_api_key_production
config = {
model = "nova-2"
max_concurrent = 100
}
}
Resources
Next Steps
Proceed to deepgram-observability for monitoring setup.