This SDK provides convenient, fully-typed access to Vapi's API.
You can install the package via composer:
composer require spiralink/vapi-php-sdkYou can always refer to the documentation to examine the various resources that are available.
use Vapi\Vapi;
$vapi = new Vapi(token: 'your-api-token');
$assistants = $vapi->assistants->list();If something goes wrong during any kind of interaction, an exception of type VapiApiException will be thrown:
use Vapi\Exceptions\VapiApiException;
try {
$call = $vapi->calls->create($request);
} catch (VapiApiException $ex) {
$logger->log($ex->getMessage());
}The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retriable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).
A request is deemed retriable when any of the following HTTP status codes is returned:
Use the maxRetries request option to configure this behavior.
$call = $vapi->calls->create($request, [
'maxRetries' => 0, // Override maxRetries at the request level
]);The SDK defaults to a 30 second timeout. Use the timeout option to configure this behavior.
$call = $vapi->calls->create($request, [
'timeout' => 15, // Override timeout at the request level
]);composer testPlease see CHANGELOG for more information on what has changed recently.
If you discover any security related issues, please email support@spiralink.ai instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.