Skip to content

SpiraLink-AI/vapi-php-sdk

Repository files navigation

Vapi PHP SDK PHP

Build Status Total Downloads Latest Stable Version License

Vapi PHP SDK

This SDK provides convenient, fully-typed access to Vapi's API.

Installation

You can install the package via composer:

composer require spiralink/vapi-php-sdk

Usage

You 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();

Handling exceptions

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());
}

Retries

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:

  • 408 (Timeout)
  • 429 (Too Many Requests)
  • 5XX (Internal Server Errors)

Use the maxRetries request option to configure this behavior.

$call = $vapi->calls->create($request, [
    'maxRetries' => 0, // Override maxRetries at the request level
]);

Timeouts

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
]);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security

If you discover any security related issues, please email support@spiralink.ai instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

An unofficial PHP SDK for accessing Vapi's API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages