create_assistant
Create a new AI assistant with custom name, instructions, voice, and LLM configuration for conversational applications.
Instructions
Creates a new Vapi assistant
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the assistant | |
| instructions | No | Instructions for the assistant | You are a helpful assistant. |
| llm | No | LLM configuration | |
| toolIds | No | IDs of tools to use with this assistant | |
| transcriber | No | Transcription configuration | |
| voice | No | Voice configuration | |
| firstMessage | No | First message to say to the user | Hello, how can I help you today? |
| firstMessageMode | No | This determines who speaks first, either assistant or user | assistant-speaks-first |
Implementation Reference
- src/tools/assistant.ts:31-41 (registration)Registers the 'create_assistant' MCP tool with server.tool(), including name, description, input schema, and inline handler function that transforms input and creates the assistant via Vapi SDK.server.tool( 'create_assistant', 'Creates a new Vapi assistant', CreateAssistantInputSchema.shape, createToolHandler(async (data) => { // console.log('create_assistant', data); const createAssistantDto = transformAssistantInput(data); const assistant = await vapiClient.assistants.create(createAssistantDto); return transformAssistantOutput(assistant); }) );
- src/tools/assistant.ts:35-40 (handler)Core handler logic wrapped by createToolHandler: transforms input using transformAssistantInput, calls vapiClient.assistants.create, and transforms output.createToolHandler(async (data) => { // console.log('create_assistant', data); const createAssistantDto = transformAssistantInput(data); const assistant = await vapiClient.assistants.create(createAssistantDto); return transformAssistantOutput(assistant); })
- src/schemas/index.ts:124-177 (schema)Zod schema defining the input parameters for the create_assistant tool, including name, instructions, llm, toolIds, transcriber, voice, firstMessage, and firstMessageMode.export const CreateAssistantInputSchema = z.object({ name: z.string().describe('Name of the assistant'), instructions: z .string() .optional() .default('You are a helpful assistant.') .describe('Instructions for the assistant'), llm: z .union([ LLMSchema, z.string().transform((str) => { try { return JSON.parse(str); } catch (e) { throw new Error(`Invalid LLM JSON string: ${str}`); } }), ]) .default(DEFAULT_LLM) .describe('LLM configuration'), toolIds: z .array(z.string()) .optional() .describe('IDs of tools to use with this assistant'), transcriber: z .object({ provider: z.string().describe('Provider to use for transcription'), model: z.string().describe('Transcription model to use'), }) .default(DEFAULT_TRANSCRIBER) .describe('Transcription configuration'), voice: z .object({ provider: VoiceProviderSchema.describe('Provider to use for voice'), voiceId: z.string().describe('Voice ID to use'), model: z.string().optional().describe('Voice model to use'), }) .default(DEFAULT_VOICE) .describe('Voice configuration'), firstMessage: z .string() .optional() .default('Hello, how can I help you today?') .describe('First message to say to the user'), firstMessageMode: z .enum([ 'assistant-speaks-first', 'assistant-waits-for-user', 'assistant-speaks-first-with-model-generated-message', ]) .default('assistant-speaks-first') .optional() .describe('This determines who speaks first, either assistant or user'), });
- src/transformers/index.ts:17-62 (helper)Helper function that transforms the Zod-validated input into the Vapi.CreateAssistantDto format required by the Vapi SDK.export function transformAssistantInput( input: z.infer<typeof CreateAssistantInputSchema> ): Vapi.CreateAssistantDto { const assistantDto: any = { name: input.name, }; assistantDto.model = { provider: input.llm.provider as any, model: input.llm.model, }; if (input.toolIds && input.toolIds.length > 0) { assistantDto.model.toolIds = input.toolIds; } if (input.instructions) { assistantDto.model.messages = [ { role: 'system', content: input.instructions, }, ]; } assistantDto.transcriber = { provider: input.transcriber.provider, ...(input.transcriber.model ? { model: input.transcriber.model } : {}), }; assistantDto.voice = { provider: input.voice.provider as any, voiceId: input.voice.voiceId, ...(input.voice.model ? { model: input.voice.model } : {}), }; if (input.firstMessage) { assistantDto.firstMessage = input.firstMessage; } if (input.firstMessageMode) { assistantDto.firstMessageMode = input.firstMessageMode; } return assistantDto as Vapi.CreateAssistantDto; }