Skip to main content

AI SDK

AI SDK implementation for @micdrop/server.

This package provides an AI agent implementation using the Vercel AI SDK, allowing you to use any compatible language model provider.

Installation​

Install AI SDK:

npm install @micdrop/ai-sdk

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

npm install @ai-sdk/openai

AI SDK Agent​

Usage​

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,
maxTokens: 150,
},
})

// Use with MicdropServer
new MicdropServer(socket, {
agent,
// ... other options
})

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

Options​

OptionTypeDefaultDescription
modelLanguageModelRequiredAny AI SDK compatible language model
systemPromptstringRequiredSystem prompt for the agent
maxRetrynumber3Maximum number of retries on API failures
autoEndCallboolean | stringfalseAuto-detect when user wants to end call
autoSemanticTurnboolean | stringfalseHandle incomplete user sentences
autoIgnoreUserNoiseboolean | stringfalseFilter meaningless user sounds
extractExtractJsonOptions | ExtractTagOptionsundefinedExtract structured data from responses
onBeforeAnswerfunctionundefinedHook called before answer generation - return true to skip generation
settingsCallSettings{}Additional AI SDK parameters

The AI SDK Agent supports adding and removing custom tools to extend its capabilities. For detailed information about tool management, see the Tools documentation.

Advanced Features​

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