> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.vapi.ai/llms.txt.
> For full documentation content, see https://docs.vapi.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.vapi.ai/_mcp/server.

# 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:

```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

```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

```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

* Create React App
* Vite
* Custom webpack

- Vue 3
- Nuxt.js
- Vite

* Angular 12+
* Ionic

- App Router
- Pages Router
- API Routes

* SvelteKit
* Vite

- HTML/CSS/JS
- Webpack
- Parcel

### Mobile frameworks

* Expo
* Bare workflow

- iOS & Android
- Web support

### Backend frameworks

* Express
* Fastify
* Koa

- Django
- FastAPI
- Flask

* Gin
* Echo
* Fiber

- Rails
- Sinatra

* Spring Boot
* Quarkus

- 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:

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

Get your API key from the [Vapi Dashboard](https://dashboard.vapi.ai/):

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

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

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
```

For permission issues during SDK installation:

```bash
# npm projects
sudo npm install

# Python projects
pip install --user vapi-server-sdk
```

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
* **[Set up MCP](/cli/mcp):** Enhance your IDE with Vapi intelligence

***

**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
```