Skip to content

Commit 54a286a

Browse files
committed
fix: code examples
1 parent a41fb3a commit 54a286a

File tree

12 files changed

+250
-333
lines changed

12 files changed

+250
-333
lines changed

fern/customization/jwt-authentication.mdx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ For example, it can be used to restrict which API endpoints the token can access
3131

3232
<Note>
3333
As of writing, the only publicly scoped API endpoint is
34-
https://api.vapi.ai//call/web, which is used for Web Call creation. All other
34+
https://api.vapi.ai/call/web, which is used for Web Call creation. All other
3535
endpoints are privately scoped.
3636
</Note>
3737

@@ -136,18 +136,7 @@ If you set the scope to `public`, you can use it to make authenticated API reque
136136
```
137137
import Vapi from '@vapi-ai/web';
138138
139-
const vapi = new Vapi({
140-
token: 'your-jwt-token',
141-
});
139+
const vapi = new Vapi('your-jwt-token');
142140
143141
vapi.start('your-assistant-id');
144142
```
145-
146-
## Notes
147-
148-
- With the generated token, you can authenticate API requests to any endpoint requiring authentication. The token will be valid for the duration specified in the options (1 hour in this case).
149-
- If you don't specify `token` in the JWT payload, the token will be public.
150-
151-
## Conclusion
152-
153-
This documentation covered the basics of generating a JWT token and demonstrated how to use the token to make authenticated API requests. Ensure that your environment variables (e.g., `ORG_ID` and `PRIVATE_KEY`) are correctly set up before running the code.

fern/examples/docs-agent.mdx

Lines changed: 146 additions & 145 deletions
Large diffs are not rendered by default.

fern/examples/inbound-support.mdx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ We will be creating a customer support agent for VapiBank, a bank that wants to
5252
</Tab>
5353
<Tab title="TypeScript (Server SDK)">
5454
```typescript
55-
import { Vapi } from "@vapi-ai/server-sdk";
55+
import { VapiClient } from "@vapi-ai/server-sdk";
5656
import fs from 'fs';
5757

58-
const vapi = new Vapi({ apiKey: "YOUR_VAPI_API_KEY" });
58+
const vapi = new VapiClient({ token: "YOUR_VAPI_API_KEY" });
5959

6060
async function uploadFile(filePath: string) {
6161
try {
@@ -138,9 +138,9 @@ We will be creating a customer support agent for VapiBank, a bank that wants to
138138
</Tab>
139139
<Tab title="TypeScript (Server SDK)">
140140
```typescript
141-
import { Vapi } from "@vapi-ai/server-sdk";
141+
import { VapiClient } from "@vapi-ai/server-sdk";
142142

143-
const vapi = new Vapi({ apiKey: "YOUR_VAPI_API_KEY" });
143+
const vapi = new VapiClient({ token: "YOUR_VAPI_API_KEY" });
144144

145145
const systemPrompt = `You are Tom, a friendly VapiBank customer support assistant. Help customers check balances and view recent transactions. Always verify identity with phone number first.`;
146146

@@ -159,7 +159,7 @@ We will be creating a customer support agent for VapiBank, a bank that wants to
159159
},
160160
voice: {
161161
provider: "11labs",
162-
voiceId: "burt"
162+
voice_id: "burt"
163163
}
164164
});
165165

@@ -193,7 +193,7 @@ We will be creating a customer support agent for VapiBank, a bank that wants to
193193
},
194194
"voice": {
195195
"provider": "11labs",
196-
"voiceId": "burt"
196+
"voice_id": "burt"
197197
}
198198
}
199199

@@ -222,7 +222,7 @@ We will be creating a customer support agent for VapiBank, a bank that wants to
222222
},
223223
"voice": {
224224
"provider": "11labs",
225-
"voiceId": "burt"
225+
"voice_id": "burt"
226226
}
227227
}'
228228
```
@@ -245,9 +245,9 @@ We will be creating a customer support agent for VapiBank, a bank that wants to
245245
</Tab>
246246
<Tab title="TypeScript (Server SDK)">
247247
```typescript
248-
import { Vapi } from "@vapi-ai/server-sdk";
248+
import { VapiClient } from "@vapi-ai/server-sdk";
249249

250-
const vapi = new Vapi({ apiKey: "YOUR_VAPI_API_KEY" });
250+
const vapi = new VapiClient({ token: "YOUR_VAPI_API_KEY" });
251251

252252
const updatedAssistant = await vapi.assistants.update("YOUR_ASSISTANT_ID", {
253253
firstMessage: "Hello, you've reached VapiBank customer support! My name is Tom, how may I assist you today?"
@@ -351,9 +351,9 @@ You have access to CSV files with account and transaction data:
351351
</Tab>
352352
<Tab title="TypeScript (Server SDK)">
353353
```typescript
354-
import { Vapi } from "@vapi-ai/server-sdk";
354+
import { VapiClient } from "@vapi-ai/server-sdk";
355355

356-
const vapi = new Vapi({ apiKey: "YOUR_VAPI_API_KEY" });
356+
const vapi = new VapiClient({ token: "YOUR_VAPI_API_KEY" });
357357

358358
// Use the system prompt from above
359359
const systemPrompt = `# VapiBank - Phone Support Agent Prompt...`;
@@ -430,9 +430,9 @@ You have access to CSV files with account and transaction data:
430430
</Tab>
431431
<Tab title="TypeScript (Server SDK)">
432432
```typescript
433-
import { Vapi } from "@vapi-ai/server-sdk";
433+
import { VapiClient } from "@vapi-ai/server-sdk";
434434

435-
const vapi = new Vapi({ apiKey: "YOUR_VAPI_API_KEY" });
435+
const vapi = new VapiClient({ token: "YOUR_VAPI_API_KEY" });
436436

437437
async function updateAssistantLLMSettings(assistantId: string) {
438438
const updatedAssistant = await vapi.assistants.update(assistantId, {
@@ -531,9 +531,9 @@ You have access to CSV files with account and transaction data:
531531
</Tab>
532532
<Tab title="TypeScript (Server SDK)">
533533
```typescript
534-
import { Vapi } from "@vapi-ai/server-sdk";
534+
import { VapiClient } from "@vapi-ai/server-sdk";
535535

536-
const vapi = new Vapi({ apiKey: "YOUR_VAPI_API_KEY" });
536+
const vapi = new VapiClient({ token: "YOUR_VAPI_API_KEY" });
537537

538538
async function testAssistantWithCall(assistantId: string) {
539539
const call = await vapi.calls.create({
@@ -668,9 +668,9 @@ You have access to CSV files with account and transaction data:
668668
</Tab>
669669
<Tab title="TypeScript (Server SDK)">
670670
```typescript
671-
import { Vapi } from "@vapi-ai/server-sdk";
671+
import { VapiClient } from "@vapi-ai/server-sdk";
672672

673-
const vapi = new Vapi({ apiKey: "YOUR_VAPI_API_KEY" });
673+
const vapi = new VapiClient({ token: "YOUR_VAPI_API_KEY" });
674674

675675
// Step 1: Create the account lookup tool
676676
const lookupAccountTool = await vapi.tools.create({
@@ -921,9 +921,9 @@ You have access to CSV files with account and transaction data:
921921
</Tab>
922922
<Tab title="TypeScript (Server SDK)">
923923
```typescript
924-
import { Vapi } from "@vapi-ai/server-sdk";
924+
import { VapiClient } from "@vapi-ai/server-sdk";
925925

926-
const vapi = new Vapi({ apiKey: "YOUR_VAPI_API_KEY" });
926+
const vapi = new VapiClient({ token: "YOUR_VAPI_API_KEY" });
927927

928928
const phoneNumber = await vapi.phoneNumbers.create({
929929
name: "Vapi Support Hotline",
@@ -1007,9 +1007,9 @@ You have access to CSV files with account and transaction data:
10071007
</Tab>
10081008
<Tab title="TypeScript (Server SDK)">
10091009
```typescript
1010-
import { Vapi } from "@vapi-ai/server-sdk";
1010+
import { VapiClient } from "@vapi-ai/server-sdk";
10111011

1012-
const vapi = new Vapi({ apiKey: "YOUR_VAPI_API_KEY" });
1012+
const vapi = new VapiClient({ token: "YOUR_VAPI_API_KEY" });
10131013

10141014
const testSuite = await vapi.testSuites.create({
10151015
name: "Support Hotline Test Suite",

fern/examples/voice-widget.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,11 @@ const EcommerceSupportWidget = () => {
379379
config={{
380380
position: 'bottom-right',
381381
theme: 'ecommerce',
382-
greeting: 'Hi! Need help with your order?'
382+
greeting: 'Hi! Need help with your order?',
383+
voice: {
384+
provider: 'playht',
385+
voice_id: 'jennifer',
386+
},
383387
}}
384388
/>
385389
);
@@ -396,7 +400,11 @@ const HealthcareWidget = () => {
396400
config={{
397401
position: 'bottom-left',
398402
theme: 'healthcare',
399-
greeting: 'Hello! I can help schedule your appointment.'
403+
greeting: 'Hello! I can help schedule your appointment.',
404+
voice: {
405+
provider: 'playht',
406+
voice_id: 'jennifer',
407+
},
400408
}}
401409
/>
402410
);

fern/quickstart/dashboard.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ Vapi makes it easy to build end-to-end voice agents, which we call ***assistants
187187
},
188188
voice: {
189189
provider: "11labs",
190-
voiceId: "paula"
190+
voice_id: "paula"
191191
},
192192
transcriber: {
193193
provider: "deepgram",
@@ -241,10 +241,10 @@ Vapi makes it easy to build end-to-end voice agents, which we call ***assistants
241241

242242
<Step title="Create your assistant">
243243
```typescript
244-
import Vapi from '@vapi-ai/server-sdk';
244+
import { VapiClient } from '@vapi-ai/server-sdk';
245245

246-
const vapi = new Vapi({
247-
apiKey: 'your_private_api_key_here',
246+
const vapi = new VapiClient({
247+
token: 'your_private_api_key_here',
248248
});
249249

250250
const assistant = await vapi.assistants.create({
@@ -266,7 +266,7 @@ Vapi makes it easy to build end-to-end voice agents, which we call ***assistants
266266
},
267267
voice: {
268268
provider: "11labs",
269-
voiceId: "paula"
269+
voice_id: "paula"
270270
},
271271
transcriber: {
272272
provider: "deepgram",
@@ -284,15 +284,15 @@ Vapi makes it easy to build end-to-end voice agents, which we call ***assistants
284284
<Steps>
285285
<Step title="Install the SDK">
286286
```bash
287-
pip install vapi-python
287+
pip install vapi_server_sdk
288288
```
289289
</Step>
290290

291291
<Step title="Create your assistant">
292292
```python
293-
from vapi_python import Vapi
293+
from vapi import Vapi
294294

295-
vapi = Vapi(api_key="your_private_api_key_here")
295+
vapi = Vapi(token="your_private_api_key_here")
296296

297297
assistant = vapi.assistants.create(
298298
name="TechSolutions Support Assistant",
@@ -313,7 +313,7 @@ Vapi makes it easy to build end-to-end voice agents, which we call ***assistants
313313
},
314314
voice={
315315
"provider": "11labs",
316-
"voiceId": "paula"
316+
"voice_id": "paula"
317317
},
318318
transcriber={
319319
"provider": "deepgram",
@@ -359,7 +359,7 @@ Vapi makes it easy to build end-to-end voice agents, which we call ***assistants
359359
},
360360
"voice": {
361361
"provider": "11labs",
362-
"voiceId": "paula"
362+
"voice_id": "paula"
363363
},
364364
"transcriber": {
365365
"provider": "deepgram",
@@ -662,7 +662,7 @@ Vapi makes it easy to build end-to-end voice agents, which we call ***assistants
662662
},
663663
voice: {
664664
provider: "11labs",
665-
voiceId: "paula"
665+
voice_id: "paula"
666666
},
667667
transcriber: {
668668
provider: "deepgram",

fern/quickstart/phone.mdx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ Vapi makes it easy to build voice agents that can make and receive phone calls.
7979

8080
<Step title="Create the assistant">
8181
```typescript
82-
import Vapi from '@vapi-ai/server-sdk';
82+
import { VapiClient } from '@vapi-ai/server-sdk';
8383

8484
// Initialize the Vapi client
85-
const vapi = new Vapi({
85+
const vapi = new VapiClient({
8686
token: 'your-api-key', // Replace with your actual API key
8787
});
8888

@@ -111,7 +111,7 @@ Vapi makes it easy to build voice agents that can make and receive phone calls.
111111
// Configure the voice
112112
voice: {
113113
provider: 'playht',
114-
voiceId: 'jennifer',
114+
voice_id: 'jennifer',
115115
},
116116
// Set the first message
117117
firstMessage: 'Hi there, this is Alex from TechSolutions customer support. How can I help you today?',
@@ -136,16 +136,16 @@ Vapi makes it easy to build voice agents that can make and receive phone calls.
136136
<Steps>
137137
<Step title="Install the SDK">
138138
```bash
139-
pip install vapi-python
139+
pip install vapi_server_sdk
140140
```
141141
</Step>
142142

143143
<Step title="Create the assistant">
144144
```python
145-
import vapi_python as vapi
145+
from vapi import Vapi
146146

147147
# Initialize the Vapi client
148-
client = vapi.Vapi(api_key="your-api-key") # Replace with your actual API key
148+
client = Vapi(token="your-api-key") # Replace with your actual API key
149149

150150
# Define the system prompt for customer support
151151
system_prompt = """You are Alex, a customer service voice assistant for TechSolutions. Your primary purpose is to help customers resolve issues with their products, answer questions about services, and ensure a satisfying support experience.
@@ -172,7 +172,7 @@ Vapi makes it easy to build voice agents that can make and receive phone calls.
172172
# Configure the voice
173173
voice={
174174
"provider": "playht",
175-
"voiceId": "jennifer",
175+
"voice_id": "jennifer",
176176
},
177177
# Set the first message
178178
first_message="Hi there, this is Alex from TechSolutions customer support. How can I help you today?",
@@ -212,7 +212,7 @@ Vapi makes it easy to build voice agents that can make and receive phone calls.
212212
},
213213
"voice": {
214214
"provider": "playht",
215-
"voiceId": "jennifer"
215+
"voice_id": "jennifer"
216216
},
217217
"firstMessage": "Hi there, this is Alex from TechSolutions customer support. How can I help you today?"
218218
}'
@@ -420,9 +420,7 @@ Vapi makes it easy to build voice agents that can make and receive phone calls.
420420
def make_outbound_call(assistant_id: str, phone_number: str):
421421
try:
422422
call = client.calls.create(
423-
assistant={
424-
"assistantId": assistant_id,
425-
},
423+
assistant_id=assistant_id,
426424
phone_number_id="your-phone-number-id", # Your Vapi phone number ID
427425
customer={
428426
"number": phone_number, # Target phone number

fern/quickstart/web.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ This guide shows you how to integrate live, two-way voice conversations into any
8989
},
9090
voice: {
9191
provider: "playht",
92-
voiceId: "jennifer",
92+
voice_id: "jennifer",
9393
},
9494
model: {
9595
provider: "openai",

fern/workflows/examples/appointment-scheduling.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ We will be creating an appointment scheduling workflow for Tony's Barbershop, a
6464
</Tab>
6565
<Tab title="TypeScript (Server SDK)">
6666
```typescript
67-
import { Vapi } from "@vapi-ai/server-sdk";
67+
import { VapiClient } from "@vapi-ai/server-sdk";
6868
import fs from 'fs';
6969

70-
const vapi = new Vapi({ apiKey: "YOUR_VAPI_API_KEY" });
70+
const vapi = new VapiClient({ token: "YOUR_VAPI_API_KEY" });
7171

7272
async function uploadAppointmentFiles() {
7373
try {
@@ -182,9 +182,9 @@ We will be creating an appointment scheduling workflow for Tony's Barbershop, a
182182
</Tab>
183183
<Tab title="TypeScript (Server SDK)">
184184
```typescript
185-
import { Vapi } from "@vapi-ai/server-sdk";
185+
import { VapiClient } from "@vapi-ai/server-sdk";
186186

187-
const vapi = new Vapi({ apiKey: "YOUR_VAPI_API_KEY" });
187+
const vapi = new VapiClient({ token: "YOUR_VAPI_API_KEY" });
188188

189189
async function createAppointmentWorkflow() {
190190
try {
@@ -621,9 +621,9 @@ You'll start with a default template that includes a "Call Start" node. We'll mo
621621
</Tab>
622622
<Tab title="TypeScript (Server SDK)">
623623
```typescript
624-
import { Vapi } from "@vapi-ai/server-sdk";
624+
import { VapiClient } from "@vapi-ai/server-sdk";
625625

626-
const vapi = new Vapi({ apiKey: "YOUR_VAPI_API_KEY" });
626+
const vapi = new VapiClient({ token: "YOUR_VAPI_API_KEY" });
627627

628628
async function createAppointmentPhoneNumber(workflowId: string) {
629629
try {

0 commit comments

Comments
 (0)