---
title: "With NestJS | Micdrop"
description: "Integrate Micdrop server with NestJS for enterprise-grade voice applications with dependency injection and decorators."
url: "https://micdrop.dev/docs/server/with-nestjs"
---

*   [Getting Started](/docs/getting-started)
*   [Client (Browser)](/docs/client)
    
    *   [Installation](/docs/client/installation)
    *   [React Hooks](/docs/client/react-hooks)
    *   [Start/Stop Call](/docs/client/start-stop-call)
    *   [Pause/Resume Call](/docs/client/pause-resume-call)
    *   [Mute/Unmute Call](/docs/client/mute-unmute-call)
    *   [Call State](/docs/client/call-state)
    *   [Display Conversation Messages](/docs/client/display-conversation-messages)
    *   [Handling Tool Calls](/docs/client/handling-tool-calls)
    *   [Device Management](/docs/client/devices-management)
    *   [Voice Activity Detection (VAD)](/docs/client/vad)
    *   [Error Handling](/docs/client/error-handling)
    *   Utility Classes
        
        *   [Mic](/docs/client/utility-classes/mic)
        *   [MicdropClient](/docs/client/utility-classes/micdrop-client)
        *   [MicRecorder](/docs/client/utility-classes/mic-recorder)
        *   [Speaker](/docs/client/utility-classes/speaker)
        
    
*   [Server (Node.js)](/docs/server)
    
    *   [Installation](/docs/server/installation)
    *   [With Fastify](/docs/server/with-fastify)
    *   [With NestJS](/docs/server/with-nestjs)
    *   [Auth and Parameters](/docs/server/auth-and-parameters)
    *   [First Message](/docs/server/first-message)
    *   [Save Messages](/docs/server/save-messages)
    *   [Resume a Conversation](/docs/server/resume-conversation)
    *   [Recording Audio](/docs/server/recording-audio)
    *   [Error Handling](/docs/server/error-handling)
    *   [Tools](/docs/server/tools)
    *   [Extract Value from Answer](/docs/server/extract)
    *   [Auto End Call](/docs/server/auto-end-call)
    *   [Semantic Turn Detection](/docs/server/semantic-turn-detection)
    *   [Noise Filtering](/docs/server/noise-filtering)
    *   [Micdrop Protocol](/docs/server/protocol)
    
*   [AI Integrations](/docs/ai-integration)
    
    *   Provided Integrations
        
        *   [AI SDK](/docs/ai-integration/provided-integrations/ai-sdk)
        *   [Cartesia](/docs/ai-integration/provided-integrations/cartesia)
        *   [ElevenLabs](/docs/ai-integration/provided-integrations/elevenlabs)
        *   [Gladia](/docs/ai-integration/provided-integrations/gladia)
        *   [Gradium](/docs/ai-integration/provided-integrations/gradium)
        *   [Mistral](/docs/ai-integration/provided-integrations/mistral)
        *   [OpenAI](/docs/ai-integration/provided-integrations/openai)
        
    *   Custom Integrations
        
        *   [Agent (LLM)](/docs/ai-integration/custom-integrations/custom-agent)
        *   [Speech-to-Text (STT)](/docs/ai-integration/custom-integrations/custom-stt)
        *   [Text-to-Speech (TTS)](/docs/ai-integration/custom-integrations/custom-tts)
        
    *   Fallback Strategies
        
        *   [FallbackAgent](/docs/ai-integration/fallback-strategies/agent-fallback)
        *   [FallbackSTT](/docs/ai-integration/fallback-strategies/stt-fallback)
        *   [FallbackTTS](/docs/ai-integration/fallback-strategies/tts-fallback)
        
    *   [IA Vocale Souveraine 🇫🇷🇪🇺](/docs/ai-integration/sovereign-voice-ai)
    

[Micdrop](/) › [Documentation](/docs/getting-started)

# With NestJS

Integrate Micdrop server with NestJS for enterprise-grade voice applications with dependency injection and decorators.

## Installation

Terminal window

```
npm install @micdrop/server @nestjs/websockets @nestjs/platform-ws
```

## Basic Gateway

micdrop.gateway.ts

```
import {  WebSocketGateway,  WebSocketServer,  OnGatewayConnection,} from '@nestjs/websockets'import { ElevenLabsTTS } from '@micdrop/elevenlabs'import { GladiaSTT } from '@micdrop/gladia'import { OpenaiAgent } from '@micdrop/openai'import { MicdropServer } from '@micdrop/server'import { Server } from 'ws'
@WebSocketGateway({ path: '/call' })export class MicdropGateway implements OnGatewayConnection {  @WebSocketServer()  server: Server
  handleConnection(socket: Server) {    // Setup agent    const agent = new OpenaiAgent({      apiKey: process.env.OPENAI_API_KEY || '',      systemPrompt: 'You are a helpful voice assistant built with NestJS',    })
    // Setup STT    const stt = new GladiaSTT({      apiKey: process.env.GLADIA_API_KEY || '',    })
    // Setup TTS    const tts = new ElevenLabsTTS({      apiKey: process.env.ELEVENLABS_API_KEY || '',      voiceId: process.env.ELEVENLABS_VOICE_ID || '',    })
    // Handle call    new MicdropServer(socket, {      firstMessage: 'Hello, how can I help you today?',      agent,      stt,      tts,    })  }}
```

app.module.ts

```
import { Module } from '@nestjs/common'import { MicdropGateway } from './micdrop.gateway'
@Module({  providers: [MicdropGateway],})export class AppModule {}
```

[Previous← With Fastify](/docs/server/with-fastify)[NextAuth and Parameters →](/docs/server/auth-and-parameters)

On this page

*   [Installation](#installation)
*   [Basic Gateway](#basic-gateway)
