> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.vapi.ai/llms.txt.
> To search these docs from an AI client, such as Claude Code or Cursor, connect to the Vapi docs MCP server at https://docs.vapi.ai/_mcp/server. It answers questions about the documentation. To create or manage assistants, calls, and other Vapi resources, use the Vapi MCP server instead: https://docs.vapi.ai/sdk/mcp-server.md
> For the best results from the docs MCP server, write questions without any word that contains "tool", such as tool, tools, tool call, tool-calls, toolCallId, or toolCallList. Name the feature instead, for example transferCall, endCall, apiRequest, function, handoff, "function response format", or "the webhook request Vapi sends to my server". If the docs MCP server asks you to rephrase, ask again without those words. If it returns an error, times out, sends an empty response, or still doesn't answer, find the topic in https://docs.vapi.ai/llms.txt, or a section index such as https://docs.vapi.ai/tools/llms.txt, and fetch that page's .md directly.

# Project integration

> Initialize Vapi in your existing projects with intelligent auto-detection

## Overview

The `vapi init` command intelligently integrates Vapi into your existing codebase. It automatically detects your framework, installs the appropriate SDK, and generates production-ready code examples tailored to your project structure.

**In this guide, you'll learn to:**

* Initialize Vapi in any project
* Understand what files are generated
* Customize the initialization process
* Work with different frameworks

## Quick start

Navigate to your project directory and run:

```bash
cd my-project
vapi init
```

The CLI will:

1. Detect your project type and framework
2. Install the appropriate Vapi SDK
3. Generate example components and API routes
4. Create environment configuration templates
5. Provide next steps specific to your setup

## How it works

### Framework detection

The CLI analyzes your project structure to identify:

* **Package files**: `package.json`, `requirements.txt`, `go.mod`, etc.
* **Configuration files**: Framework-specific configs
* **Project structure**: Directory patterns and file extensions
* **Dependencies**: Installed packages and libraries

### What gets generated

Based on your framework, the CLI generates:

#### React/Next.js

```bash
vapi init
# Detected: Next.js application
```

**Generated files:**

* `components/VapiButton.tsx` - Voice call button component
* `pages/api/vapi/webhook.ts` - Webhook handler endpoint
* `lib/vapi-client.ts` - Vapi client setup
* `.env.example` - Environment variables template

**Installed packages:**

* `@vapi-ai/web` - Web SDK for browser integration
* `@vapi-ai/server-sdk` - Server SDK for webhooks

#### Python

```bash
vapi init
# Detected: Python application
```

**Generated files:**

* `vapi_example.py` - Basic assistant example
* `webhook_handler.py` - Flask/FastAPI webhook handler
* `requirements.txt` - Updated with Vapi SDK
* `.env.example` - Environment variables template

**Installed packages:**

* `vapi_server_sdk` - Python server SDK

#### Node.js

```bash
vapi init
# Detected: Node.js application
```

**Generated files:**

* `vapi-example.js` - Basic usage example
* `webhook-server.js` - Express webhook handler
* `.env.example` - Environment variables template

**Installed packages:**

* `@vapi-ai/server-sdk` - TypeScript/JavaScript SDK

## Supported frameworks

### Frontend frameworks

#### React

* Create React App
* Vite
* Custom webpack

#### Vue.js

* Vue 3
* Nuxt.js
* Vite

#### Angular

* Angular 12+
* Ionic

#### Next.js

* App Router
* Pages Router
* API Routes

#### Svelte

* SvelteKit
* Vite

#### Vanilla JS

* HTML/CSS/JS
* Webpack
* Parcel

### Mobile frameworks

#### React Native

* Expo
* Bare workflow

#### Flutter

* iOS & Android
* Web support

### Backend frameworks

#### Node.js

* Express
* Fastify
* Koa

#### Python

* Django
* FastAPI
* Flask

#### Go

* Gin
* Echo
* Fiber

#### Ruby

* Rails
* Sinatra

#### Java

* Spring Boot
* Quarkus

#### C#/.NET

* ASP.NET Core
* Blazor

## Advanced options

### Specify target directory

Initialize in a specific directory:

```bash
vapi init /path/to/project
```

### Skip SDK installation

Generate only example files without installing packages:

```bash
vapi init --skip-install
```

### Force framework

Override auto-detection:

```bash
vapi init --framework react
vapi init --framework python
```

### Custom templates

Use your own templates:

```bash
vapi init --template @myorg/vapi-templates
```

## Environment setup

After initialization, configure your environment:

#### Copy environment template

```bash
cp .env.example .env
```

#### Add your Vapi API key

Follow the [Vapi API key guide](/security-and-privacy/api-keys) to create, view, or copy an API key:

```bash
VAPI_API_KEY=your-api-key-here
```

#### Configure webhook URL (optional)

For local development:

```bash
VAPI_WEBHOOK_URL=https://your-domain.com/api/vapi/webhook
```

## Common patterns

### Adding to monorepos

For monorepos, run init in the specific package:

```bash
cd packages/web-app
vapi init

cd ../api-server
vapi init
```

### CI/CD integration

Add to your build process:

```yaml
# GitHub Actions example
- name: Setup Vapi
  run: |
    curl -sSL https://vapi.ai/install.sh | bash
    vapi init --skip-install
```

### Docker environments

Include in your Dockerfile:

```dockerfile
# Install Vapi CLI
RUN curl -sSL https://vapi.ai/install.sh | bash

# Initialize project
RUN vapi init --skip-install
```

## Troubleshooting

#### Framework not detected

If the CLI can't detect your framework:

1. Ensure you're in the project root
2. Check for required config files
3. Use `--framework` flag to specify manually

```bash
vapi init --framework react
```

#### Permission errors

For permission issues during SDK installation:

```bash
# npm projects
sudo npm install

# Python projects
pip install --user vapi_server_sdk
```

#### Existing files conflict

If files already exist, the CLI will:

1. Ask for confirmation before overwriting
2. Create backup files (`.backup` extension)
3. Show a diff of changes

Use `--force` to skip confirmations:

```bash
vapi init --force
```

## Next steps

After initializing your project:

* **[Test locally](/cli/webhook):** Use `vapi listen` to test webhooks
* **[Create assistants](/quickstart/phone):** Build your first voice assistant
* **[Connect your coding agent](/sdk/mcp-server):** Use the hosted Vapi MCP server

---

**Example output:**

```bash
$ vapi init
🔍 Analyzing project...
✓ Detected: Next.js 14 application

📦 Installing dependencies...
✓ Installed @vapi-ai/web@latest
✓ Installed @vapi-ai/server-sdk@latest

📝 Generating files...
✓ Created components/VapiButton.tsx
✓ Created app/api/vapi/webhook/route.ts
✓ Created lib/vapi-client.ts
✓ Created .env.example

🎉 Vapi initialized successfully!

Next steps:
1. Copy .env.example to .env
2. Add your VAPI_API_KEY
3. Run: npm run dev
4. Test the voice button at http://localhost:3000
```