---
title: "AI SDK | Micdrop"
description: "Plug any Vercel AI SDK model provider into a TypeScript voice agent, so your Node server can answer with an OpenAI, Anthropic, Google or Mistral model."
url: "https://micdrop.dev/docs/ai-integration/provided-integrations/ai-sdk"
---

*   [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)
    *   [Turn Detection](/docs/client/turn-detection)
    *   [Reducing Latency](/docs/client/latency)
    *   [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)
        
    
*   [Client (React Native)](/docs/react-native)
    
    *   [Installation](/docs/react-native/installation)
    *   [Hooks and Call State](/docs/react-native/hooks)
    *   [Audio Output and Devices](/docs/react-native/audio-output)
    *   [Voice Activity Detection (VAD)](/docs/react-native/vad)
    *   [Turn Detection](/docs/react-native/turn-detection)
    *   [Using Another Audio Library](/docs/react-native/custom-audio)
    
*   [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)
    *   [Dictation and Text-Only Calls](/docs/server/dictation)
    *   [Partial Messages](/docs/server/partial-messages)
    *   [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)
        *   [Kokoro](/docs/ai-integration/provided-integrations/kokoro)
        *   [Mistral](/docs/ai-integration/provided-integrations/mistral)
        *   [OpenAI](/docs/ai-integration/provided-integrations/openai)
        *   [Piper](/docs/ai-integration/provided-integrations/piper)
        *   [Pocket TTS](/docs/ai-integration/provided-integrations/pocket-tts)
        *   [Qwen3-TTS](/docs/ai-integration/provided-integrations/qwen-tts)
        *   [Whisper](/docs/ai-integration/provided-integrations/whisper)
        
    *   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)
        
    *   [Local Models](/docs/ai-integration/local-models)
        
        *   [Local LLM](/docs/ai-integration/local-models/agent)
        *   [Local STT](/docs/ai-integration/local-models/speech-to-text)
        *   [Local TTS](/docs/ai-integration/local-models/text-to-speech)
        *   [Latency and Memory](/docs/ai-integration/local-models/performance)
        *   [Explorations](/docs/ai-integration/local-models/explorations)
            
            *   [MiniCPM5-2B](/docs/ai-integration/local-models/explorations/minicpm)
            *   [Mistral 7B](/docs/ai-integration/local-models/explorations/mistral-7b)
            *   [Voxtral Mini 3B](/docs/ai-integration/local-models/explorations/voxtral-stt)
            *   [Voxtral TTS 4B](/docs/ai-integration/local-models/explorations/voxtral-tts)
            *   [AuK and AuK-Flash](/docs/ai-integration/local-models/explorations/auk)
            
        
    *   [IA Vocale Souveraine 🇫🇷🇪🇺](/docs/ai-integration/sovereign-voice-ai)
    
*   [Migration](/docs/migration)
    
    *   [Upgrade to v3](/docs/migration/v3)
    

[Micdrop](/) › [Documentation](/docs/getting-started) › [AI Integrations](/docs/ai-integration) › Provided Integrations

# AI SDK

AI SDK implementation for [@micdrop/server](/docs/server).

This package provides an AI agent implementation using the [Vercel AI SDK](https://sdk.vercel.ai/), allowing you to use any compatible language model provider.

## Installation

Install AI SDK:

Terminal window

```
npm install @micdrop/ai-sdk
```

And install the provider you want to use, for example OpenAI:

Terminal window

```
npm install @ai-sdk/openai
```

## AI SDK Agent

### Usage with MicdropServer

```
import { AiSdkAgent } from '@micdrop/ai-sdk'import { MicdropServer } from '@micdrop/server'import { openai } from '@ai-sdk/openai' // or any other provider
const agent = new AiSdkAgent({  model: openai('gpt-4o'), // Use any AI SDK compatible model  systemPrompt: 'You are a helpful assistant',
  // Custom AI SDK settings (optional)  settings: {    temperature: 0.7,    maxOutputTokens: 150,  },
  // Provider specific parameters (optional)  providerOptions: {    openai: { reasoningEffort: 'none' },  },})
// Use with MicdropServernew MicdropServer(socket, {  agent,  // ... other options})
```

### Usage without MicdropServer

```
import { AiSdkAgent } from '@micdrop/ai-sdk'import { openai } from '@ai-sdk/openai'
const agent = new AiSdkAgent({  model: openai('gpt-4o'),  systemPrompt: 'You are a helpful assistant',})
agent.on('Message', (message) => console.log('Message:', message))
agent.addUserMessage('Hello, what can you do?')
// The answer is a text stream, written as the model generates itagent.answer().on('data', (chunk) => process.stdout.write(chunk))
```

### Events

Event

Payload

Description

`Message`

`MicdropConversationItem`

A message, a tool call or a tool result was added to the conversation.

`ToolCall`

`MicdropToolCall`

A tool declared with `emitOutput` ran, with its parameters and output.

`CancelLastUserMessage`

none

The last user message was dropped because it carried no intent.

`SkipAnswer`

none

The agent stays silent and waits for the user to finish their sentence.

`EndCall`

none

The agent decided that the call is over.

`Failed`

none

The agent gave up generating an answer after its retries.

See the [Agent interface](/docs/ai-integration/custom-integrations/custom-agent) for the full contract.

### Supported Providers

The AI SDK Agent supports any provider compatible with the Vercel AI SDK:

*   **OpenAI**: `openai('gpt-4o')`, `openai('gpt-3.5-turbo')`
*   **Anthropic**: `anthropic('claude-3-5-sonnet-20241022')`
*   **Google**: `google('gemini-1.5-pro')`, `google('gemini-1.5-flash')`
*   **Mistral**: `mistral('mistral-large-latest')`
*   **And many more**: See [AI SDK Providers](https://sdk.vercel.ai/providers/ai-sdk-providers)

### Provider specific options

`settings` carries the parameters every provider understands, such as the temperature. Parameters read by a single provider go in `providerOptions`, under the name of that provider. Turning reasoning off is the common case in a call, since reasoning delays the first token:

```
const agent = new AiSdkAgent({  model: openai.chat('gpt-5.2'),  systemPrompt: 'You are a helpful assistant',  providerOptions: {    openai: { reasoningEffort: 'none' },  },})
```

The same option reaches a [local server](/docs/ai-integration/local-models) behind `createOpenAI`. Ollama maps it to its own `think` flag, and a model without a reasoning mode ignores it.

### Options

Option

Type

Default

Description

`model`

`LanguageModel`

Required

Any AI SDK compatible language model

`systemPrompt`

`string`

Required

System prompt for the agent

`maxRetry`

`number`

`3`

Maximum number of retries on API failures

`autoEndCall`

`boolean | string`

`false`

[Auto-detect when user wants to end call](/docs/server/auto-end-call)

`autoSemanticTurn`

`boolean | string`

`false`

[Handle incomplete user sentences](/docs/server/semantic-turn-detection)

`autoIgnoreUserNoise`

`boolean | string`

`false`

[Filter meaningless user sounds](/docs/server/noise-filtering)

`extract`

[`ExtractJsonOptions`](/docs/server/extract#json-extraction) | [`ExtractTagOptions`](/docs/server/extract#custom-tag-extraction)

`undefined`

Extract structured data from responses

`onBeforeAnswer`

`function`

`undefined`

Hook called before answer generation - return `true` to skip generation

`settings`

`CallSettings`

`{}`

Additional AI SDK parameters

`providerOptions`

`ProviderOptions`

`{}`

Provider specific parameters, keyed by provider name

The AI SDK Agent supports adding and removing custom tools to extend its capabilities. For detailed information about tool management, see the [Tools documentation](/docs/server/tools).

### Advanced Features

The AI SDK Agent supports advanced features for improved conversation handling:

*   **[Auto End Call](/docs/server/auto-end-call)**: Automatically detect when users want to end the conversation
*   **[Semantic Turn Detection](/docs/server/semantic-turn-detection)**: Handle incomplete sentences for natural flow
*   **[User Noise Filtering](/docs/server/noise-filtering)**: Filter out meaningless sounds and filler words
*   **[Extract Value from Answer](/docs/server/extract)**: Extract structured data from responses
*   **[Tools](/docs/server/tools)**: Add custom tools to the agent

[Previous← AI Integrations](/docs/ai-integration)[NextCartesia →](/docs/ai-integration/provided-integrations/cartesia)

On this page

*   [Installation](#installation)
*   [AI SDK Agent](#ai-sdk-agent)
*   [Usage with MicdropServer](#usage-with-micdropserver)
*   [Usage without MicdropServer](#usage-without-micdropserver)
*   [Events](#events)
*   [Supported Providers](#supported-providers)
*   [Provider specific options](#provider-specific-options)
*   [Options](#options)
*   [Advanced Features](#advanced-features)
