@vapi-ai/web 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { Api } from "./api";
2
+
3
+ const api = new Api({
4
+ baseUrl: "https://api.vapi.ai",
5
+ baseApiParams: {
6
+ secure: true,
7
+ },
8
+ securityWorker: async (securityData) => {
9
+ if (securityData) {
10
+ return {
11
+ headers: {
12
+ Authorization: `Bearer ${securityData}`,
13
+ },
14
+ };
15
+ }
16
+ },
17
+ });
18
+
19
+ export const client = api;
package/dist/api.d.ts ADDED
@@ -0,0 +1,414 @@
1
+ export interface PhoneCallParams {
2
+ callSid?: string;
3
+ customerPhoneNumber: string;
4
+ twilioPhoneNumber: string;
5
+ twilioAccountSid: string;
6
+ twilioAuthToken: string;
7
+ }
8
+ export interface Call {
9
+ type: "inboundPhoneCall" | "outboundPhoneCall" | "webCall";
10
+ id: string;
11
+ orgId: string;
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ agentId?: string;
15
+ customerId?: string;
16
+ phoneNumberId?: string;
17
+ startedAt: string;
18
+ endedAt?: string;
19
+ transcript?: string;
20
+ recordingUrl?: string;
21
+ cost?: number;
22
+ summary?: string;
23
+ agentParams?: object;
24
+ callParams?: PhoneCallParams;
25
+ }
26
+ export interface OpenAIFunctionParamaters {
27
+ type: string;
28
+ properties: object;
29
+ required?: string[];
30
+ }
31
+ export interface OpenAIFunction {
32
+ /** This is the the name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. */
33
+ name: string;
34
+ /** This is a description of what the function does, used by the AI to choose when and how to call the function. */
35
+ description?: string;
36
+ /**
37
+ * These are the parameters the functions accepts, described as a JSON Schema object. See the [OpenAI guide](https://platform.openai.com/docs/guides/gpt/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema) for documentation about the format.
38
+ *
39
+ * To describe a function that accepts no parameters, provide the value {"type": "object", "properties": {}}.
40
+ */
41
+ parameters: OpenAIFunctionParamaters;
42
+ }
43
+ export interface CreateAgentDTO {
44
+ /** This is the OpenAI model that will be used. */
45
+ model?: "gpt-4-32k" | "gpt-4" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo";
46
+ /**
47
+ * This is the voice that will be used.
48
+ *
49
+ * Pro Voices: steve, joseph, myra, paula, drew, phillip, paul, and mrb.
50
+ *
51
+ * Basic Voices: davis, jenny, aria, steffan, sara, and jason.
52
+ */
53
+ voice?: "burt" | "phillip" | "steve" | "joseph" | "myra" | "paula" | "ryan" | "drew" | "paul" | "mrb" | "matilda" | "davis" | "jenny" | "aria" | "steffan" | "sara" | "jason";
54
+ /** This is the agent’s name, just for your own reference. */
55
+ name?: string;
56
+ /** This is the system prompt, which sets the objective and background before the call. */
57
+ context?: string;
58
+ /** These are the functions that the agent can execute during the call. */
59
+ functions?: OpenAIFunction[];
60
+ /**
61
+ * This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber, botPhoneNumber, and all the agent parameters.
62
+ *
63
+ * Function Calling POST Request:
64
+ * When the agent wants to call a function, we'll POST your callbackURL with `name` and `arguments`.
65
+ * Respond with a JSON object of the result. For example: `{ result: "Hello world!" }` or `{ result: { temperature: "38 degrees" } }`. If empty, return `{}.
66
+ *
67
+ * End-of-Call Report POST Request:
68
+ * You'll get `transcript`, `recordingUrl` and `summary` of the call.
69
+ *
70
+ * Context Retrieval GET Request:
71
+ * If the agent's context isn't set, it'll ask for context before starting the call. Respond with `{ context: "You are an assistant..." }`
72
+ */
73
+ callbackUrl?: string;
74
+ /** This is the number the agent will transfer to if it runs into any issues. */
75
+ forwardingPhoneNumber?: string;
76
+ /** Whether the AI should talk first when the call is connected. */
77
+ startTalking?: boolean;
78
+ }
79
+ export interface CreateOutboundCallDto {
80
+ /** This is the agent that will be used for the call. To create a transient agent, use `agent` instead. */
81
+ agentId?: string;
82
+ /** This is the agent that will be used for the call. To use an existing agent, use `agentId` instead. */
83
+ agent?: CreateAgentDTO;
84
+ /** This is the phone number that will be used for the call. */
85
+ phoneNumberId: string;
86
+ /** This is the number that will be called. */
87
+ customerPhoneNumber: string;
88
+ }
89
+ export interface CreateWebCallDto {
90
+ /** This is the agent that will be used for the call. To create a transient agent, use `agent` instead. */
91
+ agentId?: string;
92
+ /** This is the agent that will be used for the call. To use an existing agent, use `agentId` instead. */
93
+ agent?: CreateAgentDTO;
94
+ }
95
+ export interface WebCallResponseDto {
96
+ url: string;
97
+ callId: string;
98
+ }
99
+ export interface Agent {
100
+ /** This is the OpenAI model that will be used. */
101
+ model?: "gpt-4-32k" | "gpt-4" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo";
102
+ /**
103
+ * This is the voice that will be used.
104
+ *
105
+ * Pro Voices: steve, joseph, myra, paula, drew, phillip, paul, and mrb.
106
+ *
107
+ * Basic Voices: davis, jenny, aria, steffan, sara, and jason.
108
+ */
109
+ voice?: "burt" | "phillip" | "steve" | "joseph" | "myra" | "paula" | "ryan" | "drew" | "paul" | "mrb" | "matilda" | "davis" | "jenny" | "aria" | "steffan" | "sara" | "jason";
110
+ /** Unique identifier for the agent. */
111
+ id: string;
112
+ /** Unique identifier for the organization that this agent belongs to. */
113
+ orgId: string;
114
+ /** ISO 8601 date-time string of when the agent was created. */
115
+ createdAt: string;
116
+ /** ISO 8601 date-time string of when the agent was last updated. */
117
+ updatedAt: string;
118
+ /** This is the agent’s name, just for your own reference. */
119
+ name?: string;
120
+ /** This is the system prompt, which sets the objective and background before the call. */
121
+ context?: string;
122
+ /** These are the functions that the agent can execute during the call. */
123
+ functions?: OpenAIFunction[];
124
+ /**
125
+ * This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber, botPhoneNumber, and all the agent parameters.
126
+ *
127
+ * Function Calling POST Request:
128
+ * When the agent wants to call a function, we'll POST your callbackURL with `name` and `arguments`.
129
+ * Respond with a JSON object of the result. For example: `{ result: "Hello world!" }` or `{ result: { temperature: "38 degrees" } }`. If empty, return `{}.
130
+ *
131
+ * End-of-Call Report POST Request:
132
+ * You'll get `transcript`, `recordingUrl` and `summary` of the call.
133
+ *
134
+ * Context Retrieval GET Request:
135
+ * If the agent's context isn't set, it'll ask for context before starting the call. Respond with `{ context: "You are an assistant..." }`
136
+ */
137
+ callbackUrl?: string;
138
+ /** This is the number the agent will transfer to if it runs into any issues. */
139
+ forwardingPhoneNumber?: string;
140
+ /** Whether the AI should talk first when the call is connected. */
141
+ startTalking?: boolean;
142
+ }
143
+ export interface UpdateAgentDTO {
144
+ /** This is the OpenAI model that will be used. */
145
+ model?: "gpt-4-32k" | "gpt-4" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo";
146
+ /**
147
+ * This is the voice that will be used.
148
+ *
149
+ * Pro Voices: steve, joseph, myra, paula, drew, phillip, paul, and mrb.
150
+ *
151
+ * Basic Voices: davis, jenny, aria, steffan, sara, and jason.
152
+ */
153
+ voice?: "burt" | "phillip" | "steve" | "joseph" | "myra" | "paula" | "ryan" | "drew" | "paul" | "mrb" | "matilda" | "davis" | "jenny" | "aria" | "steffan" | "sara" | "jason";
154
+ /** This is the agent’s name, just for your own reference. */
155
+ name?: string;
156
+ /** This is the system prompt, which sets the objective and background before the call. */
157
+ context?: string;
158
+ /** These are the functions that the agent can execute during the call. */
159
+ functions?: OpenAIFunction[];
160
+ /**
161
+ * This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber, botPhoneNumber, and all the agent parameters.
162
+ *
163
+ * Function Calling POST Request:
164
+ * When the agent wants to call a function, we'll POST your callbackURL with `name` and `arguments`.
165
+ * Respond with a JSON object of the result. For example: `{ result: "Hello world!" }` or `{ result: { temperature: "38 degrees" } }`. If empty, return `{}.
166
+ *
167
+ * End-of-Call Report POST Request:
168
+ * You'll get `transcript`, `recordingUrl` and `summary` of the call.
169
+ *
170
+ * Context Retrieval GET Request:
171
+ * If the agent's context isn't set, it'll ask for context before starting the call. Respond with `{ context: "You are an assistant..." }`
172
+ */
173
+ callbackUrl?: string;
174
+ /** This is the number the agent will transfer to if it runs into any issues. */
175
+ forwardingPhoneNumber?: string;
176
+ /** Whether the AI should talk first when the call is connected. */
177
+ startTalking?: boolean;
178
+ }
179
+ export interface BuyPhoneNumberDto {
180
+ /** This is the area code of the phone number to purchase. */
181
+ areaCode: string;
182
+ agentId?: string;
183
+ }
184
+ export interface PhoneNumber {
185
+ id: string;
186
+ createdAt: string;
187
+ updatedAt: string;
188
+ orgId: string;
189
+ stripeSubscriptionId?: string;
190
+ number: string;
191
+ agentId?: string;
192
+ twilioAccountSid: string;
193
+ twilioAuthToken: string;
194
+ }
195
+ export interface ImportTwilioPhoneNumberDto {
196
+ /** This is the area code of the phone number to purchase. */
197
+ twilioAccountSid: string;
198
+ twilioAuthToken: string;
199
+ twilioPhoneNumber: string;
200
+ agentId?: string;
201
+ }
202
+ export interface UpdatePhoneNumberDto {
203
+ /** This is the agent that will be used to handle inbound calls to this phone number. */
204
+ agentId?: string;
205
+ }
206
+ export type QueryParamsType = Record<string | number, any>;
207
+ export type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;
208
+ export interface FullRequestParams extends Omit<RequestInit, "body"> {
209
+ /** set parameter to `true` for call `securityWorker` for this request */
210
+ secure?: boolean;
211
+ /** request path */
212
+ path: string;
213
+ /** content type of request body */
214
+ type?: ContentType;
215
+ /** query params */
216
+ query?: QueryParamsType;
217
+ /** format of response (i.e. response.json() -> format: "json") */
218
+ format?: ResponseFormat;
219
+ /** request body */
220
+ body?: unknown;
221
+ /** base url */
222
+ baseUrl?: string;
223
+ /** request cancellation token */
224
+ cancelToken?: CancelToken;
225
+ }
226
+ export type RequestParams = Omit<FullRequestParams, "body" | "method" | "query" | "path">;
227
+ export interface ApiConfig<SecurityDataType = unknown> {
228
+ baseUrl?: string;
229
+ baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
230
+ securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
231
+ customFetch?: typeof fetch;
232
+ }
233
+ export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
234
+ data: D;
235
+ error: E;
236
+ }
237
+ type CancelToken = Symbol | string | number;
238
+ export declare enum ContentType {
239
+ Json = "application/json",
240
+ FormData = "multipart/form-data",
241
+ UrlEncoded = "application/x-www-form-urlencoded",
242
+ Text = "text/plain"
243
+ }
244
+ export declare class HttpClient<SecurityDataType = unknown> {
245
+ baseUrl: string;
246
+ private securityData;
247
+ private securityWorker?;
248
+ private abortControllers;
249
+ private customFetch;
250
+ private baseApiParams;
251
+ constructor(apiConfig?: ApiConfig<SecurityDataType>);
252
+ setSecurityData: (data: SecurityDataType | null) => void;
253
+ protected encodeQueryParam(key: string, value: any): string;
254
+ protected addQueryParam(query: QueryParamsType, key: string): string;
255
+ protected addArrayQueryParam(query: QueryParamsType, key: string): any;
256
+ protected toQueryString(rawQuery?: QueryParamsType): string;
257
+ protected addQueryParams(rawQuery?: QueryParamsType): string;
258
+ private contentFormatters;
259
+ protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams;
260
+ protected createAbortSignal: (cancelToken: CancelToken) => AbortSignal | undefined;
261
+ abortRequest: (cancelToken: CancelToken) => void;
262
+ request: <T = any, E = any>({ body, secure, path, type, query, format, baseUrl, cancelToken, ...params }: FullRequestParams) => Promise<HttpResponse<T, E>>;
263
+ }
264
+ /**
265
+ * @title Vapi API
266
+ * @version 1.0
267
+ * @contact
268
+ *
269
+ * API for talking AIs
270
+ */
271
+ export declare class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
272
+ call: {
273
+ /**
274
+ * No description
275
+ *
276
+ * @tags Calls
277
+ * @name CallControllerFindAll
278
+ * @summary List Calls
279
+ * @request GET:/call
280
+ */
281
+ callControllerFindAll: (params?: RequestParams) => Promise<HttpResponse<Call[], any>>;
282
+ /**
283
+ * No description
284
+ *
285
+ * @tags Calls
286
+ * @name CallControllerFindOne
287
+ * @summary Get Call
288
+ * @request GET:/call/{id}
289
+ */
290
+ callControllerFindOne: (id: string, params?: RequestParams) => Promise<HttpResponse<Call, any>>;
291
+ /**
292
+ * No description
293
+ *
294
+ * @tags Calls
295
+ * @name CallControllerCreatePhoneCall
296
+ * @summary Create Phone Call
297
+ * @request POST:/call/phone
298
+ */
299
+ callControllerCreatePhoneCall: (data: CreateOutboundCallDto, params?: RequestParams) => Promise<HttpResponse<Call, any>>;
300
+ /**
301
+ * No description
302
+ *
303
+ * @tags Calls
304
+ * @name CallControllerCreateWebCall
305
+ * @summary Create Web Call
306
+ * @request POST:/call/web
307
+ */
308
+ callControllerCreateWebCall: (data: CreateWebCallDto, params?: RequestParams) => Promise<HttpResponse<WebCallResponseDto, any>>;
309
+ };
310
+ agent: {
311
+ /**
312
+ * No description
313
+ *
314
+ * @tags Agents
315
+ * @name AgentControllerCreate
316
+ * @summary Create Agent
317
+ * @request POST:/agent
318
+ */
319
+ agentControllerCreate: (data: CreateAgentDTO, params?: RequestParams) => Promise<HttpResponse<Agent, any>>;
320
+ /**
321
+ * No description
322
+ *
323
+ * @tags Agents
324
+ * @name AgentControllerFindAll
325
+ * @summary List Agents
326
+ * @request GET:/agent
327
+ */
328
+ agentControllerFindAll: (params?: RequestParams) => Promise<HttpResponse<Agent[], any>>;
329
+ /**
330
+ * No description
331
+ *
332
+ * @tags Agents
333
+ * @name AgentControllerFindOne
334
+ * @summary Get Agent
335
+ * @request GET:/agent/{id}
336
+ */
337
+ agentControllerFindOne: (id: string, params?: RequestParams) => Promise<HttpResponse<Agent, any>>;
338
+ /**
339
+ * No description
340
+ *
341
+ * @tags Agents
342
+ * @name AgentControllerUpdate
343
+ * @summary Update Agent
344
+ * @request PATCH:/agent/{id}
345
+ */
346
+ agentControllerUpdate: (id: string, data: UpdateAgentDTO, params?: RequestParams) => Promise<HttpResponse<Agent, any>>;
347
+ /**
348
+ * No description
349
+ *
350
+ * @tags Agents
351
+ * @name AgentControllerRemove
352
+ * @summary Delete Agent
353
+ * @request DELETE:/agent/{id}
354
+ */
355
+ agentControllerRemove: (id: string, params?: RequestParams) => Promise<HttpResponse<void, any>>;
356
+ };
357
+ phoneNumber: {
358
+ /**
359
+ * No description
360
+ *
361
+ * @tags Phone Numbers
362
+ * @name PhoneNumberControllerBuy
363
+ * @summary Buy Phone Number
364
+ * @request POST:/phone-number/buy
365
+ */
366
+ phoneNumberControllerBuy: (data: BuyPhoneNumberDto, params?: RequestParams) => Promise<HttpResponse<PhoneNumber, any>>;
367
+ /**
368
+ * No description
369
+ *
370
+ * @tags Phone Numbers
371
+ * @name PhoneNumberControllerImport
372
+ * @summary Import Twilio Number
373
+ * @request POST:/phone-number/import
374
+ */
375
+ phoneNumberControllerImport: (data: ImportTwilioPhoneNumberDto, params?: RequestParams) => Promise<HttpResponse<PhoneNumber, any>>;
376
+ /**
377
+ * No description
378
+ *
379
+ * @tags Phone Numbers
380
+ * @name PhoneNumberControllerFindAll
381
+ * @summary List Phone Numbers
382
+ * @request GET:/phone-number
383
+ */
384
+ phoneNumberControllerFindAll: (params?: RequestParams) => Promise<HttpResponse<PhoneNumber[], any>>;
385
+ /**
386
+ * No description
387
+ *
388
+ * @tags Phone Numbers
389
+ * @name PhoneNumberControllerFindOne
390
+ * @summary Get Phone Number
391
+ * @request GET:/phone-number/{id}
392
+ */
393
+ phoneNumberControllerFindOne: (id: string, params?: RequestParams) => Promise<HttpResponse<PhoneNumber, any>>;
394
+ /**
395
+ * No description
396
+ *
397
+ * @tags Phone Numbers
398
+ * @name PhoneNumberControllerUpdate
399
+ * @summary Update Phone Number
400
+ * @request PATCH:/phone-number/{id}
401
+ */
402
+ phoneNumberControllerUpdate: (id: string, data: UpdatePhoneNumberDto, params?: RequestParams) => Promise<HttpResponse<PhoneNumber, any>>;
403
+ /**
404
+ * No description
405
+ *
406
+ * @tags Phone Numbers
407
+ * @name PhoneNumberControllerRemove
408
+ * @summary Delete Phone Number
409
+ * @request DELETE:/phone-number/{id}
410
+ */
411
+ phoneNumberControllerRemove: (id: string, params?: RequestParams) => Promise<HttpResponse<void, any>>;
412
+ };
413
+ }
414
+ export {};