Skip to content

[Suggestion] Browser-only voice agent with secure temporary API key rotation (TypeScript) #559

@deepgram-robot

Description

@deepgram-robot

What to build

A recipe demonstrating a complete browser-only voice agent experience using Deepgram's Voice Agent API with a secure temporary API key pattern — where a minimal backend endpoint issues short-lived, scoped API keys so the browser client can connect directly to Deepgram without exposing the main API key.

Why this matters

Developers building voice-enabled web applications need a secure pattern for browser-to-Deepgram connections. Embedding API keys in client-side code is a security risk, but routing all audio through a backend adds latency and infrastructure cost. This recipe shows the recommended pattern: a lightweight token endpoint that issues temporary, scoped Deepgram API keys, allowing the browser to connect directly while maintaining security. This is the standard production pattern every browser voice app needs.

Suggested scope

  • Language: TypeScript (browser client + minimal Express/Hono token server)
  • Deepgram APIs: Voice Agent API, Manage API (for temporary key creation)
  • Architecture:
    • Minimal backend: single /token endpoint that creates a scoped, time-limited Deepgram API key
    • Browser client: vanilla TypeScript (no React/Vue required) connecting to Voice Agent API
    • Key rotation: automatic refresh before expiry
    • Audio capture: getUserMedia() with proper error handling
    • Visual feedback: audio level indicator, connection status, transcript display
  • Security features: key scoping (agent-only permissions), short TTL (60 seconds), automatic rotation
  • Complexity: Low-medium — focused on the security pattern, not complex agent logic

Acceptance criteria

  • Runnable with minimal setup (clone, add API key, run)
  • README explains the temporary key security pattern clearly
  • Uses current SDK version
  • Token endpoint creates properly scoped, time-limited keys
  • Browser client handles key rotation transparently
  • Works without any JavaScript framework (vanilla TS, loadable via script tag)
  • Includes proper error handling for microphone permissions and connection failures

Raised by the DX intelligence system.


Queued by PM — Engineer will pick this up as a priority:user recipe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    action:generateQueue action: generate code examplespriority:userUser-submitted request — prioritizetype:queueIssue is in the automation queue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions