Skip to content

Commit 225102d

Browse files
style: use string interpolation in JsonException messages
Replace string concatenation with double-quoted string interpolation in error messages thrown by JsonDecoder, JsonDeserializer, and JsonSerializer. The resulting messages are identical at runtime. Key changes: - Replace `"..." . $json` with `"...$json"` in JsonDecoder error messages - Replace `"..." . $type` with `"...$type"` in JsonDeserializer error message - Replace `"..." . $unionType` with `"...$unionType"` in JsonSerializer error message 🌿 Generated with Fern
1 parent 4d6e89b commit 225102d

9 files changed

Lines changed: 547 additions & 95 deletions

File tree

.fern/metadata.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"cliVersion": "4.62.4",
2+
"cliVersion": "4.65.1",
33
"generatorName": "fernapi/fern-php-sdk",
4-
"generatorVersion": "2.2.6",
4+
"generatorVersion": "2.4.0",
55
"generatorConfig": {
66
"namespace": "Vapi",
77
"client-class-name": "VapiClient"
88
},
9-
"originGitCommit": "7353542e713a4907a187bb55b184fb955cb6c5e9",
10-
"sdkVersion": "1.0.0"
9+
"originGitCommit": "46b109d88752307f8952db91eaa642f61c3875b4",
10+
"sdkVersion": "1.0.1"
1111
}

README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Vapi PHP Library
2+
3+
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FVapiAI%2Fserver-sdk-php)
4+
[![php shield](https://img.shields.io/badge/php-packagist-pink)](https://packagist.org/packages/vapi/vapi)
5+
6+
The Vapi PHP library provides convenient access to the Vapi APIs from PHP.
7+
8+
## Table of Contents
9+
10+
- [Requirements](#requirements)
11+
- [Installation](#installation)
12+
- [Usage](#usage)
13+
- [Environments](#environments)
14+
- [Exception Handling](#exception-handling)
15+
- [Advanced](#advanced)
16+
- [Custom Client](#custom-client)
17+
- [Retries](#retries)
18+
- [Timeouts](#timeouts)
19+
- [Contributing](#contributing)
20+
21+
## Requirements
22+
23+
This SDK requires PHP ^8.1.
24+
25+
## Installation
26+
27+
```sh
28+
composer require vapi/vapi
29+
```
30+
31+
## Usage
32+
33+
Instantiate and use the client with the following:
34+
35+
```php
36+
<?php
37+
38+
namespace Example;
39+
40+
use Vapi\VapiClient;
41+
use Vapi\Types\CreateAssistantDto;
42+
43+
$client = new VapiClient(
44+
token: '<token>',
45+
);
46+
$client->assistants->create(
47+
new CreateAssistantDto([]),
48+
);
49+
50+
```
51+
52+
## Environments
53+
54+
This SDK allows you to configure different environments for API requests.
55+
56+
```php
57+
The SDK defaults to the `Default_` environment. To use a different environment, pass it to the client constructor:
58+
59+
```php
60+
use Vapi\VapiClient;
61+
use Vapi\Environments;
62+
63+
$client = new VapiClient(
64+
token: '<YOUR_TOKEN>',
65+
options: [
66+
'baseUrl' => Environments::Staging->value
67+
]
68+
);
69+
```
70+
71+
Available environments:
72+
- `Environments::Default_`
73+
```
74+
75+
## Exception Handling
76+
77+
When the API returns a non-success status code (4xx or 5xx response), an exception will be thrown.
78+
79+
```php
80+
use Vapi\Exceptions\VapiApiException;
81+
use Vapi\Exceptions\VapiException;
82+
83+
try {
84+
$response = $client->assistants->create(...);
85+
} catch (VapiApiException $e) {
86+
echo 'API Exception occurred: ' . $e->getMessage() . "\n";
87+
echo 'Status Code: ' . $e->getCode() . "\n";
88+
echo 'Response Body: ' . $e->getBody() . "\n";
89+
// Optionally, rethrow the exception or handle accordingly.
90+
}
91+
```
92+
93+
## Advanced
94+
95+
### Custom Client
96+
97+
This SDK is built to work with any HTTP client that implements the [PSR-18](https://www.php-fig.org/psr/psr-18/) `ClientInterface`.
98+
By default, if no client is provided, the SDK will use `php-http/discovery` to find an installed HTTP client.
99+
However, you can pass your own client that adheres to `ClientInterface`:
100+
101+
```php
102+
use Vapi\VapiClient;
103+
104+
// Pass any PSR-18 compatible HTTP client implementation.
105+
// For example, using Guzzle:
106+
$customClient = new \GuzzleHttp\Client([
107+
'timeout' => 5.0,
108+
]);
109+
110+
$client = new VapiClient(options: [
111+
'client' => $customClient
112+
]);
113+
114+
// Or using Symfony HttpClient:
115+
// $customClient = (new \Symfony\Component\HttpClient\Psr18Client())
116+
// ->withOptions(['timeout' => 5.0]);
117+
//
118+
// $client = new VapiClient(options: [
119+
// 'client' => $customClient
120+
// ]);
121+
```
122+
123+
### Retries
124+
125+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
126+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
127+
retry limit (default: 2).
128+
129+
A request is deemed retryable when any of the following HTTP status codes is returned:
130+
131+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
132+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
133+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
134+
135+
Use the `maxRetries` request option to configure this behavior.
136+
137+
```php
138+
$response = $client->assistants->create(
139+
...,
140+
options: [
141+
'maxRetries' => 0 // Override maxRetries at the request level
142+
]
143+
);
144+
```
145+
146+
### Timeouts
147+
148+
The SDK defaults to a 30 second timeout. Use the `timeout` option to configure this behavior.
149+
150+
```php
151+
$response = $client->assistants->create(
152+
...,
153+
options: [
154+
'timeout' => 3.0 // Override timeout at the request level
155+
]
156+
);
157+
```
158+
159+
## Contributing
160+
161+
While we value open-source contributions to this SDK, this library is generated programmatically.
162+
Additions made directly to this library would have to be moved over to our generation code,
163+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
164+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
165+
an issue first to discuss with us!
166+
167+
On the other hand, contributions to the README are always very welcome!

changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 1.0.1 - 2026-04-10
2+
* style: use string interpolation in JsonException messages
3+
* Replace string concatenation with double-quoted string interpolation
4+
* in error messages thrown by JsonDecoder, JsonDeserializer, and
5+
* JsonSerializer. The resulting messages are identical at runtime.
6+
* Key changes:
7+
* Replace `"..." . $json` with `"...$json"` in JsonDecoder error messages
8+
* Replace `"..." . $type` with `"...$type"` in JsonDeserializer error message
9+
* Replace `"..." . $unionType` with `"...$unionType"` in JsonSerializer error message
10+
* 🌿 Generated with Fern
11+
112
## 1.0.0 - 2026-04-07
213
* Several public classes have been removed in this release. The following types no longer exist and must be migrated:
314
* `UpdateAssistantDtoVoicemailDetection` and `AssistantOverridesVoicemailDetection` — removed voicemail detection union type classes; consult the updated API types for replacements.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vapi/vapi",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Vapi PHP Library",
55
"keywords": [
66
"vapi",

0 commit comments

Comments
 (0)