# VAPI

> Plug Munsit's Arabic text-to-speech into VAPI voice assistants as a custom voice provider — natural Arabic on phone calls, with VAPI's real-time performance intact. You need a Munsit account and a VAPI account with access to custom voice configuration.

## How it works

VAPI's custom TTS system operates through a webhook pattern. There's no SDK to install — VAPI calls a Munsit endpoint directly, four steps per utterance:

| Step | What happens |
| --- | --- |
| **1 · Text conversion trigger** | During a conversation, VAPI needs to convert text to speech. |
| **2 · Request to Munsit** | VAPI sends a POST request to Munsit's TTS endpoint with text and audio specifications. |
| **3 · Audio generation** | Munsit generates Arabic audio and returns it as raw PCM data. |
| **4 · Real-time playback** | VAPI streams the audio to the caller in real time. |

## Set up authentication

VAPI stores your Munsit key as a **Custom Credential** and attaches it to every TTS request. First, create a key in the [Munsit dashboard](https://app.munsit.com/en/api-keys): click **"Generate New API Key"**, name it descriptively (e.g. "VAPI Integration"), and copy it immediately.

> Your API key will only be displayed once. Copy it securely before closing the dialog. Store keys in VAPI Custom Credentials — never hardcoded in assistant configuration — use separate credentials for dev and production, and rotate periodically.

Then create a Server Configuration at [VAPI Custom Credentials](https://dashboard.vapi.ai/settings/integrations/custom-credential) → **"Create New Server Configuration"**, with these exact settings:

| Field | Value |
| --- | --- |
| **Name** | A descriptive name, e.g. "Munsit TTS" |
| **Authentication Type** | Bearer Token |
| **Token** | Your Munsit API key |
| **Include Bearer** | **Disable** this toggle (turn it OFF) |
| **Header Name** | `x-api-key` |

Save, then copy the configuration's **Credential ID** — a UUID like `d4a3a362-fe82-4255-b475-f30eefe8e75c`, shown next to the configuration name (or in the URL when viewing its details). You'll reference it from your assistant configuration.

## The endpoint URL

The Munsit TTS endpoint URL encodes the model, voice, and tuning in its path and query string:

```
https://api.munsit.com/api/v1/integrations/vapi/{model_id}/{voice_id}?similarity={similarity}&speed={speed}
```

| Parameter | Type | Description | Example |
| --- | --- | --- | --- |
| `model_id` | string | The Munsit model to use — `faseeh-v1-preview` (Faseeh), high-quality Arabic voice synthesis. | `faseeh-v1-preview` |
| `voice_id` | string | The Arabic voice identifier. Browse and verify IDs in the [Voice Library](/text-to-speech/voices) — they're case-sensitive. | `ar-najdi-male-2` |
| `similarity` | number | Voice similarity/stability, 0.0–1.0 (typically 0.5–0.9). **0.0–0.4** more expressive · **0.5–0.7** balanced (recommended) · **0.8–1.0** very consistent. Rules of thumb: customer service 0.7–0.8, professional 0.8–0.9, creative 0.5–0.6. | `0.7` |
| `speed` | number | Speech speed multiplier, 0.7–1.2 (default 1.0). Below 1.0 slows down, above 1.0 speeds up. | `1.0` |

```
// Full model with Najdi male voice
"url": "https://api.munsit.com/api/v1/integrations/vapi/faseeh-v1-preview/ar-najdi-male-2?similarity=0.7&speed=1.0"

// Faseeh with UAE female voice
"url": "https://api.munsit.com/api/v1/integrations/vapi/faseeh-v1-preview/ar-uae-female-1?similarity=0.8&speed=1.0"

// Full model with Hijazi male voice (slower speech)
"url": "https://api.munsit.com/api/v1/integrations/vapi/faseeh-v1-preview/ar-hijazi-male-1?similarity=0.75&speed=0.9"
```

## Configure your assistant

Point the assistant's voice at your Munsit URL, reference the Credential ID from step 2, and always configure a fallback voice provider so calls continue if the endpoint has issues. Replace the example Credential ID with your own.

```
{
  "name": "Munsit Assistant 2",
  "voice": {
    "provider": "custom-voice",
    "server": {
      "url": "https://api.munsit.com/api/v1/integrations/vapi/faseeh-v1-preview/ar-najdi-male-2?similarity=0.7&speed=1.0",
      "credentialId": "d4a3a362-fe82-4255-b475-f30eefe8e75c",
      "timeoutSeconds": 30
    },
    "fallbackPlan": {
      "voices": [
        {
          "provider": "eleven-labs",
          "voiceId": "21m00Tcm4TlvDq8ikWAM"
        }
      ]
    }
  }
}
```

## On the wire

Every TTS request from VAPI arrives as a `voice-request` message; Munsit answers with raw streamed PCM. You don't have to build either side — this is what flows between them.

```
{
  "message": {
    "type": "voice-request",
    "text": "مرحباً، كيف يمكنني مساعدتك اليوم؟",
    "sampleRate": 24000,
    "timestamp": 1677123456789,
    "call": {
      "id": "call-123",
      "orgId": "org-456"
    },
    "assistant": {
      "id": "assistant-789",
      "name": "Munsit Assistant"
    },
    "customer": {
      "number": "+1234567890"
    }
  }
}
```

```
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Transfer-Encoding: chunked

[Raw PCM audio bytes]
```

Required request fields: `type` (always `"voice-request"`), `text` (supports Arabic and mixed content), `sampleRate` (8000, 16000, 22050, or 24000 Hz), and `timestamp` (Unix milliseconds). The audio Munsit returns is raw PCM — no headers or containers — mono, 16-bit signed integer, little-endian, at the requested sample rate.

> Munsit handles all audio format requirements automatically. No additional configuration needed.

## Test the integration

Use VAPI's API to create a test call that exercises your Munsit TTS assistant end to end.

```
async function testFaseehWithVAPICall() {
  const vapiApiKey = 'your-vapi-api-key';
  const assistantId = 'your-assistant-id'; // Assistant with Munsit TTS

  const callData = {
    assistant: { id: assistantId },
    phoneNumberId: 'your-phone-number-id',
    customer: { number: '+1234567890' }, // Your test number
  };

  try {
    const response = await fetch('https://api.vapi.ai/call', {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${vapiApiKey}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(callData),
    });

    const call = await response.json();
    console.log('Test call created:', call.id);
    return call;
  } catch (error) {
    console.error('Failed to create test call:', error);
  }
}
```

## Troubleshooting

Symptoms, likely causes, and what to change.

| Symptom | Common causes | Solutions |
| --- | --- | --- |
| **Request timeouts** — VAPI doesn't receive audio, calls may drop | Network issues between VAPI and the Munsit API; TTS takes longer than the timeout; server overload | Increase `timeoutSeconds` (default 30); check network and Munsit API status |
| **Audio playback problems** — no audio, or distorted/garbled sound | Incorrect URL format or parameters; invalid voice ID; authentication issues | Verify the URL matches `/vapi/{model_id}/{voice_id}?similarity={similarity}`; confirm the voice ID exists; check the credential ID holds a valid Munsit key |
| **Authentication failures** — 401 Unauthorized | Invalid Munsit key in custom credentials; missing/incorrect credential ID; key expired or revoked | Verify the key at [app.munsit.com](https://app.munsit.com/); check the credential ID against the VAPI dashboard; regenerate if needed |
| **High latency** — noticeable delays in conversation | Network latency; high similarity values requiring more processing | Reduce similarity (e.g. 0.9 → 0.7); consider geographic proximity of services |
| **Invalid voice ID** — 404 Not Found | Typo; voice doesn't exist; wrong model/voice combination | Verify IDs in the [Voice Library](/text-to-speech/voices) — exact and case-sensitive — and check the voice is available for your model |

## Where next

Now that Munsit TTS is answering calls: try different voices, combine Munsit for Arabic with other providers for English, and watch usage in the [dashboard](https://app.munsit.com/).

- [Explore voices](/text-to-speech/voices) — Try different Arabic voices from the library. — `GET /voices`

- [TTS API](/text-to-speech/synthesize) — The synthesis engine behind the VAPI endpoint. — `POST /text-to-speech`

- [Ultravox](/integrations/ultravox) — The custom-voice pattern on Ultravox. — `guide`

- [Support](/support) — Schedule a meeting with the Munsit team — VAPI questions go to docs.vapi.ai. — `guide`
