Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions 26 vapi_python/vapi_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
CHANNELS = 1


def create_web_call(api_url, api_key, assistant):
def create_web_call(api_url, api_key, payload):
url = f"{api_url}/call/web"
headers = {
'Authorization': 'Bearer ' + api_key,
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, json=assistant)
response = requests.post(url, headers=headers, json=payload)
data = response.json()
if response.status_code == 201:
call_id = data.get('id')
Expand All @@ -27,15 +27,29 @@ def __init__(self, *, api_key, api_url="https://api.vapi.ai"):
self.api_key = api_key
self.api_url = api_url

def start(self, *, assistant_id=None, assistant=None, assistant_overrides=None):
def start(
self,
*,
assistant_id=None,
assistant=None,
assistant_overrides=None,
squad_id=None,
squad=None,
):
# Start a new call
if assistant_id:
assistant = {'assistantId': assistant_id, 'assistantOverrides': assistant_overrides}
payload = {'assistantId': assistant_id, 'assistantOverrides': assistant_overrides}
elif assistant:
assistant = {'assistant': assistant, 'assistantOverrides': assistant_overrides}
payload = {'assistant': assistant, 'assistantOverrides': assistant_overrides}
elif squad_id:
payload = {'squadId': squad_id}
elif squad:
payload = {'squad': squad}
else:
raise Exception("Error: No assistant specified.")

call_id, web_call_url = create_web_call(
self.api_url, self.api_key, assistant)
self.api_url, self.api_key, payload)

if not web_call_url:
raise Exception("Error: Unable to create call.")
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.