Skip to content

Instantly share code, notes, and snippets.

View bajajcodes's full-sized avatar
🏠
Working from home

shubhambajaj bajajcodes

🏠
Working from home
View GitHub Profile

Vapi Proxy Server Guide

Overview

Proxy server keeps assistant configs and API keys on your backend. Frontend sends custom data, backend maps to Vapi calls.

Flow: Frontend -> Your Proxy -> Vapi API -> Response -> Frontend

Frontend Setup

Teach Yourself: SIP Credential Architecture and Authentication

Understanding SIP Communication Fundamentals

SIP (Session Initiation Protocol) communication requires mutual trust between parties. When you create SIP credentials, you're establishing a bidirectional security relationship.

The Core Principle: Mutual Whitelisting + Authentication

Every SIP connection involves two fundamental security layers:

Teach Yourself: How to Create SIP Credentials

Understanding the Hostname Error

SIP credential creation fails when you use a hostname (domain name) for a gateway that receives inbound calls.

What Changed

The SIP infrastructure (Jambonz) upgraded and now enforces validation rules. Previously, hostname configurations were accepted but never worked for inbound calls. Now the system blocks invalid configurations immediately.

You are a Pronunciation Transformation Assistant for text-to-speech (TTS) models. Your workflow always follows these steps:

  1. Context Intake:

    • Ask the user to provide the specific pronunciation transformation task and include a few representative examples.
    • The context can be any domain (e.g., numbers, dates, abbreviations, measurements, technical terms).
  2. Problem Clarification:

    • Restate the problem in your own words to confirm understanding.
    • Ask clarifying questions if the context is ambiguous or incomplete.
export default {
async fetch(request) {
const url = new URL(request.url);
// Handle CORS preflight
if (request.method === 'OPTIONS') {
return new Response(null, {
status: 204,
headers: {
'Access-Control-Allow-Origin': '*',
const CONFIG = {
MODEL_NAME: 'static-model',
DELAYS: {
WORD: 20,
SENTENCE: 50,
TOOL_CALL: 50,
},
RESPONSES: {
NORMAL: [
'Hello! This is a static response.',

Customizing Chunk Plan with cURL

Modifying Minimum Characters

curl -X PATCH "https://api.vapi.ai/voice/voices/{voiceId}" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chunkPlan": {

Trieve Knowledge Base Integration with Vapi

Query Flow Overview

  1. Query Formation:

    • When a user sends a message, Vapi extracts the most recent user queries (up to the last 3).
    • These messages are joined with periods to form a single query string for Trieve
  2. Knowledge Base Retrieval:

  • Vapi calls the internal function which:

Implementing Sequential Call Transfers in Vapi

Step 1: Set Up Your Assistant Configuration

First, you need to create a Vapi assistant with the transferCall tool configured:

{
  "name": "Sequential Transfer Assistant",

1. Create a Backend Proxy Server

Set up a backend server that will:

  • Generate JWT tokens with appropriate restrictions
  • Proxy requests to Vapi APIs
// server.js (Node.js/Express)
const express = require('express');
const jwt = require('jsonwebtoken');