### Install Vapi Python SDK Source: https://github.com/vapiai/server-sdk-python/blob/main/README.md Install the Vapi server SDK package using pip. This command fetches and installs the latest version of the library from PyPI. ```sh pip install vapi_server_sdk ``` -------------------------------- ### Create Assistant with Vapi Python SDK Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Provides a basic example of creating an assistant using the Vapi Python SDK. This operation requires an initialized Vapi client with a valid authentication token. Further customization options for assistant creation are available but not shown in this basic example. ```python from vapi import Vapi client = Vapi( token="YOUR_TOKEN", ) client.assistants.create() ``` -------------------------------- ### Initialize and Use Async Vapi Client (Python) Source: https://github.com/vapiai/server-sdk-python/blob/main/README.md Shows how to create an asynchronous Vapi client for non-blocking API calls. It includes an example of running an async function to create a call using the client. ```python import asyncio from vapi import AsyncVapi client = AsyncVapi( token="YOUR_TOKEN", ) async def main() -> None: await client.calls.create() asyncio.run(main()) ``` -------------------------------- ### List Tools using Vapi Python SDK Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md This code example demonstrates how to list available tools using the Vapi Python SDK. It initializes the Vapi client and calls the list method for tools. Optional parameters allow filtering the results by creation or update timestamps, and controlling the number of items returned. ```python from vapi import Vapi import datetime as dt client = Vapi( token="YOUR_TOKEN", ) client.tools.list() # Example with parameters: # client.tools.list( # limit=50, # created_at_gt=dt.datetime(2023, 1, 1), # updated_at_lt=dt.datetime(2023, 12, 31) # ) ``` -------------------------------- ### Initialize Async Vapi Client (Python) Source: https://context7.com/vapiai/server-sdk-python/llms.txt Shows how to initialize the asynchronous Vapi client for non-blocking operations. This is suitable for async applications where I/O operations should not block the event loop. Includes an example of fetching assistants. ```python import asyncio from vapi import AsyncVapi async def main(): client = AsyncVapi(token="your_api_token_here") # Perform async operations assistants = await client.assistants.list() # Process results for assistant in assistants: print(f"Assistant: {assistant.name}") asyncio.run(main()) ``` -------------------------------- ### Create Voice Assistant (Python) Source: https://context7.com/vapiai/server-sdk-python/llms.txt Example of creating a new AI voice assistant using the Vapi Python SDK. This snippet demonstrates configuring the assistant's name, initial message, AI model, voice, transcriber, call duration, background sound, end call phrases, and webhook server URL. ```python from vapi import Vapi client = Vapi(token="your_api_token_here") assistant = client.assistants.create( name="Customer Support Agent", first_message="Hello! How can I help you today?", model={ "provider": "openai", "model": "gpt-4", "messages": [ { "role": "system", "content": "You are a friendly customer support agent. Be helpful and concise." } ], "temperature": 0.7 }, voice={ "provider": "11labs", "voiceId": "rachel" }, transcriber={ "provider": "deepgram", "model": "nova-2", "language": "en" }, max_duration_seconds=600, background_sound="office", end_call_phrases=["goodbye", "have a nice day"], server={ "url": "https://your-webhook-url.com/vapi" } ) print(f"Created assistant: {assistant.id}") ``` -------------------------------- ### Create Squad with Members in Python Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Create a new squad by specifying a list of assistant members. The first member in the list becomes the starting assistant. Optional name and member overrides can be applied globally across all squad members. ```python from vapi import SquadMemberDto, Vapi client = Vapi( token="YOUR_TOKEN", ) client.squads.create( members=[SquadMemberDto()], name="string", members_overrides=AssistantOverrides(...), request_options=RequestOptions(...) ) ``` -------------------------------- ### Tools API Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md APIs for managing tools, including listing, creating, getting, and deleting them. ```APIDOC ## GET /tools ### Description Retrieves a list of available tools. ### Method GET ### Endpoint `/tools` ### Parameters #### Query Parameters - **limit** (float) - Optional - The maximum number of items to return. Defaults to 100. - **created_at_gt** (datetime) - Optional - Filters tools created after the specified date. - **created_at_lt** (datetime) - Optional - Filters tools created before the specified date. - **created_at_ge** (datetime) - Optional - Filters tools created on or after the specified date. - **created_at_le** (datetime) - Optional - Filters tools created on or before the specified date. - **updated_at_gt** (datetime) - Optional - Filters tools updated after the specified date. - **updated_at_lt** (datetime) - Optional - Filters tools updated before the specified date. - **updated_at_ge** (datetime) - Optional - Filters tools updated on or after the specified date. - **updated_at_le** (datetime) - Optional - Filters tools updated on or before the specified date. #### Request Body None ### Response #### Success Response (200) - **tools** (array) - A list of tool objects. ### Request Example ```python from vapi import Vapi client = Vapi(token="YOUR_TOKEN") client.tools.list(limit=50) ``` ### Response Example ```json { "tools": [ { "id": "tool_abc", "name": "Example Tool" } ] } ``` ``` ```APIDOC ## POST /tools ### Description Creates a new tool. ### Method POST ### Endpoint `/tools` ### Parameters #### Request Body - **request** (CreateToolsRequest) - Required - The details for creating the tool. ### Response #### Success Response (200) - **created_tool** (object) - The details of the newly created tool. ### Request Example ```python from vapi import CreateApiRequestToolDto, Vapi client = Vapi(token="YOUR_TOKEN") client.tools.create(request=CreateApiRequestToolDto(method="POST", url="url")) ``` ### Response Example ```json { "created_tool": { "id": "tool_xyz", "name": "New Tool" } } ``` ``` ```APIDOC ## GET /tools/{id} ### Description Retrieves details of a specific tool. ### Method GET ### Endpoint `/tools/{id}` ### Parameters #### Path Parameters - **id** (str) - Required - The unique identifier of the tool. #### Request Body None ### Response #### Success Response (200) - **tool_details** (object) - Details of the tool. ### Request Example ```python from vapi import Vapi client = Vapi(token="YOUR_TOKEN") client.tools.get(id="id") ``` ### Response Example ```json { "tool_details": { "id": "tool_abc", "name": "Example Tool" } } ``` ``` ```APIDOC ## DELETE /tools/{id} ### Description Deletes a specific tool. ### Method DELETE ### Endpoint `/tools/{id}` ### Parameters #### Path Parameters - **id** (str) - Required - The unique identifier of the tool to delete. #### Request Body None ### Response #### Success Response (200) - **message** (str) - Confirmation message of deletion. ### Request Example ```python from vapi import Vapi client = Vapi(token="YOUR_TOKEN") client.tools.delete(id="id") ``` ### Response Example ```json { "message": "Tool deleted successfully." } ``` ``` -------------------------------- ### Vapi Python SDK: List Phone Numbers Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Provides an example of how to list available phone numbers using the Vapi Python SDK. It demonstrates initializing the Vapi client with a token and calling the list method on the phone_numbers client. ```python from vapi import Vapi client = Vapi( token="YOUR_TOKEN", ) client.phone_numbers.list() ``` -------------------------------- ### GET /campaigns Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves a list of campaigns, with options for filtering, pagination, and sorting. ```APIDOC ## GET /campaigns ### Description Retrieves a list of campaigns, with options for filtering, pagination, and sorting. ### Method GET ### Endpoint /campaigns ### Parameters #### Query Parameters - **id** (Optional[str]) - Filters campaigns by ID. - **status** (Optional[CampaignControllerFindAllRequestStatus]) - Filters campaigns by status. - **page** (Optional[float]) - The page number to return. Defaults to 1. - **sort_order** (Optional[CampaignControllerFindAllRequestSortOrder]) - The sort order for pagination. Defaults to 'DESC'. - **limit** (Optional[float]) - The maximum number of items to return. Defaults to 100. - **created_at_gt** (Optional[datetime]) - Returns items where the createdAt is greater than the specified value. - **created_at_lt** (Optional[datetime]) - Returns items where the createdAt is less than the specified value. - **created_at_ge** (Optional[datetime]) - Returns items where the createdAt is greater than or equal to the specified value. - **created_at_le** (Optional[datetime]) - Returns items where the createdAt is less than or equal to the specified value. - **updated_at_gt** (Optional[datetime]) - Returns items where the updatedAt is greater than the specified value. - **updated_at_lt** (Optional[datetime]) - Returns items where the updatedAt is less than the specified value. - **updated_at_ge** (Optional[datetime]) - Returns items where the updatedAt is greater than or equal to the specified value. - **updated_at_le** (Optional[datetime]) - Returns items where the updatedAt is less than or equal to the specified value. - **request_options** (Optional[RequestOptions]) - Request-specific configuration. ### Response #### Success Response (200 OK) - **data** (Array) - A list of campaign objects. - Each campaign object may contain fields like id, name, status, etc. - **page** (float) - The current page number. - **limit** (float) - The number of items per page. - **total** (float) - The total number of campaigns available. #### Response Example ```json { "data": [ { "id": "campaignId1", "name": "Q2 Sales Campaign", "status": "running" }, { "id": "campaignId2", "name": "Q3 Marketing Push", "status": "completed" } ], "page": 1, "limit": 10, "total": 2 } ``` ``` -------------------------------- ### List Vapi Sessions using Python SDK Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md This code example shows how to retrieve a list of all Vapi sessions using the Python SDK. It requires authentication with a Vapi token. This function does not take any specific parameters other than the client initialization. ```python from vapi import Vapi client = Vapi( token="YOUR_TOKEN", ) client.sessions.list() ``` -------------------------------- ### Create Campaign for Batch Calling Source: https://context7.com/vapiai/server-sdk-python/llms.txt Sets up a new campaign designed for scheduled batch calling operations. Requires campaign name, assistant ID, phone number ID, customer list, and a schedule plan with start time and time zone. Returns the created campaign's ID and status. ```python from vapi import Vapi client = Vapi(token="your_api_token_here") campaign = client.campaigns.create( name="Q4 Product Survey", assistant_id="assistant_id_here", phone_number_id="phone_number_id_here", customers=[ {"number": "+14155551111", "name": "Customer A"}, {"number": "+14155552222", "name": "Customer B"} ], schedule_plan={ "start_time": "2024-12-01T09:00:00Z", "time_zone": "America/New_York" } ) print(f"Campaign created: {campaign.id}") print(f"Status: {campaign.status}") ``` -------------------------------- ### Create Structured Output Schema Source: https://context7.com/vapiai/server-sdk-python/llms.txt Defines a schema for structured outputs to extract specific data from conversations. This example creates a schema named 'Appointment Details' to capture date, time, service, and customer name, specifying required fields and data formats. Dependencies: `Vapi` client. ```python from vapi import Vapi client = Vapi(token="your_api_token_here") # Create structured output schema structured_output = client.structured_outputs.create( name="Appointment Details", schema={ "type": "object", "properties": { "date": {"type": "string", "format": "date"}, "time": {"type": "string"}, "service": {"type": "string"}, "customer_name": {"type": "string"} }, "required": ["date", "time", "service"] }, description="Extract appointment details from customer conversation" ) print(f"Structured output created: {structured_output.id}") ``` -------------------------------- ### Update Assistant Configuration (Python) Source: https://context7.com/vapiai/server-sdk-python/llms.txt Provides an example of how to update the configuration of an existing voice assistant using its ID. This allows for dynamic adjustments to the assistant's behavior, such as changing its initial message, AI model, or call termination messages. ```python from vapi import Vapi client = Vapi(token="your_api_token_here") updated_assistant = client.assistants.update( id="assistant_id_here", first_message="Hi there! I'm your updated assistant.", model={ "provider": "openai", "model": "gpt-4-turbo", "temperature": 0.8 }, voicemail_message="Sorry we missed you. Please leave a message.", end_call_message="Thank you for calling. Goodbye!" ) print(f"Updated assistant: {updated_assistant.id}") ``` -------------------------------- ### Configure Request Options and Retries Source: https://context7.com/vapiai/server-sdk-python/llms.txt Shows how to configure default request options like timeout for the Vapi client and override them for specific requests. This example sets a default timeout and then customizes the timeout and maximum retries for an assistant creation call using `request_options`. Dependencies: `Vapi`. ```python from vapi import Vapi client = Vapi( token="your_api_token_here", timeout=60.0 # Default timeout for all requests ) # Override timeout and retries for specific request assistant = client.assistants.create( name="Test Assistant", request_options={ "timeout_in_seconds": 120, # 2 minute timeout for this request "max_retries": 3 # Retry up to 3 times } ) print(f"Assistant created: {assistant.id}") ``` -------------------------------- ### Get Tool by ID using Vapi Python SDK Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md This code example demonstrates retrieving a specific tool by its ID using the Vapi Python SDK. After initializing the client with an authentication token, the `get` method is called with the tool's unique identifier. This operation is useful for fetching details of a particular tool. ```python from vapi import Vapi client = Vapi( token="YOUR_TOKEN", ) client.tools.get( id="id", ) ``` -------------------------------- ### Initialize Vapi Client (Python) Source: https://context7.com/vapiai/server-sdk-python/llms.txt Demonstrates how to initialize the synchronous Vapi client. It covers basic initialization with a token, as well as advanced configurations for custom timeouts, environments, and integrating with httpx for proxy support. ```python from vapi import Vapi # Basic synchronous client client = Vapi(token="your_api_token_here") # Client with custom timeout and environment from vapi import VapiEnvironment client = Vapi( token="your_api_token_here", environment=VapiEnvironment.DEFAULT, timeout=30.0 ) # Client with custom httpx configuration for proxy support import httpx client = Vapi( token="your_api_token_here", httpx_client=httpx.Client( proxies="http://proxy.example.com:8080", transport=httpx.HTTPTransport(local_address="0.0.0.0") ) ) ``` -------------------------------- ### Initialize and Use Vapi Client (Python) Source: https://github.com/vapiai/server-sdk-python/blob/main/README.md Demonstrates how to instantiate the synchronous Vapi client with an authentication token and make a basic call to create a call. Ensure you replace 'YOUR_TOKEN' with your actual API token. ```python from vapi import Vapi client = Vapi( token="YOUR_TOKEN", ) client.calls.create() ``` -------------------------------- ### GET Eval Controller Get Paginated Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves paginated eval results from the system. This endpoint returns a paginated list of evaluations with optional filtering and sorting parameters. ```APIDOC ## GET /eval ### Description Retrieves a paginated list of evaluations from the system. ### Method GET ### Endpoint `/eval` ### Parameters #### Query Parameters - Pagination parameters (page, limit, etc.) - Optional - Control pagination of results #### Request Options - **request_options** (typing.Optional[RequestOptions]) - Optional - Request-specific configuration ### Usage Example ```python from vapi import Vapi client = Vapi( token="YOUR_TOKEN", ) client.eval.eval_controller_get_paginated() ``` ### Response #### Success Response (200) - **items** (array) - List of evaluation objects - **total** (number) - Total count of evaluations - **page** (number) - Current page number - **limit** (number) - Items per page ``` -------------------------------- ### GET /provider-resources - Get Provider Resources Paginated Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves paginated provider resources with filtering by provider and resource name. Used to access and manage external provider resources. ```APIDOC ## GET /provider-resources ### Description Retrieves a paginated list of provider resources filtered by provider type and resource name. Supports pagination for managing large resource sets. ### Method GET ### Endpoint `/provider-resources` ### Parameters #### Query Parameters - **provider** (string) - Required - Provider identifier (e.g., "11labs" for ElevenLabs) - **resource_name** (string) - Required - Name of the resource to retrieve (e.g., "pronunciation-dictionary") - **page** (float) - Optional - Page number for pagination. Defaults to 1 - **limit** (float) - Optional - Maximum number of items to return. Defaults to 100 - **request_options** (RequestOptions) - Optional - Request-specific configuration ### Request Example ```python from vapi import Vapi client = Vapi( token="YOUR_TOKEN", ) client.provider_resources.provider_resource_controller_get_provider_resources_paginated( provider="11labs", resource_name="pronunciation-dictionary", ) ``` ### Response #### Success Response (200) - **items** (array) - List of provider resource objects - **page** (float) - Current page number - **limit** (float) - Number of items per page - **total** (float) - Total number of resources available - **provider** (string) - Provider identifier - **resource_name** (string) - Resource name ``` -------------------------------- ### Structured Output Suggestions Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Analyzes assistant configuration and generates contextual structured output recommendations. ```APIDOC ## POST /structured_outputs/suggest ### Description Analyzes assistant configuration and generates contextual structured output recommendations. ### Method POST ### Endpoint /structured_outputs/suggest ### Parameters #### Query Parameters - **assistant_id** (str) - Required - The assistant ID to analyze and generate suggestions for - **count** (float) - Optional - Number of suggestions to generate - **exclude_ids** (Sequence[str]) - Optional - Existing structured output IDs to exclude from suggestions - **seed** (float) - Optional - Iteration/seed for generating diverse suggestions (0 = first generation, 1+ = regenerations with increasing specificity) - **request_options** (RequestOptions) - Optional - Request-specific configuration. ### Request Example ```json { "assistant_id": "550e8400-e29b-41d4-a716-446655440000" } ``` ### Response #### Success Response (200) - **suggestions** (list) - A list of suggested structured outputs #### Response Example ```json { "suggestions": [ { "id": "string", "name": "string", "description": "string" } ] } ``` ``` -------------------------------- ### GET /campaigns/{id} Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves a specific campaign by its ID. ```APIDOC ## GET /campaigns/{id} ### Description Retrieves a specific campaign by its ID. ### Method GET ### Endpoint /campaigns/{id} ### Parameters #### Path Parameters - **id** (str) - Required - The unique identifier of the campaign to retrieve. #### Query Parameters - **request_options** (Optional[RequestOptions]) - Request-specific configuration. ### Response #### Success Response (200 OK) - **id** (str) - The unique identifier for the campaign. - **name** (str) - The name of the campaign. - **status** (str) - The current status of the campaign. - **...other campaign details** #### Response Example ```json { "id": "campaignId", "name": "Q2 Sales Campaign", "status": "running", "createdAt": "2023-10-27T10:00:00Z", "updatedAt": "2023-10-27T10:05:00Z" } ``` ``` -------------------------------- ### GET /chats/{id} Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves a specific chat by its ID. ```APIDOC ## GET /chats/{id} ### Description Retrieves the details of a specific chat using its unique identifier. ### Method GET ### Endpoint /chats/{id} ### Parameters #### Path Parameters - **id** (str) - Required - The unique identifier of the chat to retrieve. #### Query Parameters - **request_options** (Optional[RequestOptions]) - Request-specific configuration. ### Response #### Success Response (200) - **chat_details** (object) - An object containing the details of the chat. #### Response Example ```json { "chat_id": "chat_abcdef123456", "status": "active", "created_at": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Initialize Vapi Client in Python Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Demonstrates how to initialize the Vapi client with an API token. This is the first step before interacting with the Vapi API. ```python from vapi import Vapi client = Vapi( token="YOUR_TOKEN", ) ``` -------------------------------- ### GET /provider-resources/{id} Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves a specific provider resource by its ID. ```APIDOC ## GET /provider-resources/{id} ### Description Retrieves a specific provider resource by its ID. ### Method GET ### Endpoint /provider-resources/{id} ### Parameters #### Path Parameters - **id** (str) - Required - The ID of the provider resource to retrieve. #### Query Parameters - **provider** (ProviderResourceControllerGetProviderResourceRequestProvider) - Required - The provider (e.g., 11labs) - **resource_name** (ProviderResourceControllerGetProviderResourceRequestResourceName) - Required - The resource name (e.g., pronunciation-dictionary) - **request_options** (typing.Optional[RequestOptions]) - Optional - Request-specific configuration. ### Response #### Success Response (200) - **id** (str) - The ID of the provider resource. - **provider** (str) - The provider of the resource. - **resource_name** (str) - The name of the resource. - **createdAt** (str) - The timestamp when the resource was created. - **updatedAt** (str) - The timestamp when the resource was last updated. #### Response Example ```json { "id": "resource-id-123", "provider": "11labs", "resource_name": "pronunciation-dictionary", "createdAt": "2023-10-27T10:00:00Z", "updatedAt": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### GET /eval/runs Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves a paginated list of all evaluation runs, with options for filtering and sorting. ```APIDOC ## GET /eval/runs ### Description Retrieves a paginated list of evaluation runs. ### Method GET ### Endpoint /eval/runs ### Parameters #### Query Parameters - **id** (Optional[str]) - Optional - Filter by evaluation run ID. - **page** (Optional[float]) - Optional - The page number to retrieve. Defaults to 1. - **sort_order** (Optional[EvalControllerGetRunsPaginatedRequestSortOrder]) - Optional - The sort order for pagination. Defaults to 'DESC'. - **limit** (Optional[float]) - Optional - The maximum number of items to return per page. Defaults to 100. - **created_at_gt** (Optional[datetime]) - Optional - Filter for runs created after a specific datetime. - **created_at_lt** (Optional[datetime]) - Optional - Filter for runs created before a specific datetime. - **created_at_ge** (Optional[datetime]) - Optional - Filter for runs created on or after a specific datetime. - **created_at_le** (Optional[datetime]) - Optional - Filter for runs created on or before a specific datetime. - **updated_at_gt** (Optional[datetime]) - Optional - Filter for runs updated after a specific datetime. - **updated_at_lt** (Optional[datetime]) - Optional - Filter for runs updated before a specific datetime. - **updated_at_ge** (Optional[datetime]) - Optional - Filter for runs updated on or after a specific datetime. - **updated_at_le** (Optional[datetime]) - Optional - Filter for runs updated on or before a specific datetime. - **request_options** (Optional[RequestOptions]) - Optional - Request-specific configuration. ### Request Example ```python client.eval.eval_controller_get_runs_paginated(limit=50, sort_order='ASC') ``` ### Response #### Success Response (200) - **runs** (List[object]) - A list of evaluation runs. - **total** (int) - The total number of evaluation runs available. #### Response Example ```json { "runs": [ { "runId": "run_abc789", "status": "completed", "createdAt": "2023-10-27T10:00:00Z" }, { "runId": "run_def456", "status": "failed", "createdAt": "2023-10-26T15:30:00Z" } ], "total": 2 } ``` ``` -------------------------------- ### Create Session in Python Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Demonstrates how to initiate a session using the Vapi Python SDK. This function allows for the creation of new sessions, potentially with various configurations passed as arguments. ```python from vapi import Vapi client = Vapi( token="YOUR_TOKEN", ) client.sessions.create() ``` -------------------------------- ### GET /eval/run/{id} Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves the details of a specific evaluation run using its ID. ```APIDOC ## GET /eval/run/{id} ### Description Retrieves the details of a specific evaluation run. ### Method GET ### Endpoint /eval/run/{id} ### Parameters #### Path Parameters - **id** (str) - Required - The ID of the evaluation run to retrieve. #### Query Parameters - **request_options** (Optional[RequestOptions]) - Optional - Request-specific configuration. ### Request Example ```python client.eval.eval_controller_get_run(id="run_abc789") ``` ### Response #### Success Response (200) - **runId** (str) - The ID of the evaluation run. - **status** (str) - The current status of the evaluation run. - **results** (object) - The results of the evaluation. #### Response Example ```json { "runId": "run_abc789", "status": "completed", "results": { "score": 0.95, "feedback": "The model performed well." } } ``` ``` -------------------------------- ### Create Campaign with Vapi SDK Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Demonstrates how to create a new campaign using the Vapi Python SDK. Requires campaign name, phone number ID, and customer details. Optionally accepts assistant or workflow IDs, scheduling plans, and request options. ```python from vapi import CreateCustomerDto, Vapi client = Vapi( token="YOUR_TOKEN", ) client.campaigns.campaign_controller_create( name="Q2 Sales Campaign", phone_number_id="phoneNumberId", customers=[CreateCustomerDto()], ) ``` -------------------------------- ### Generate Structured Output Recommendations (Python) Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Analyzes assistant configuration and generates contextual structured output recommendations. Requires an assistant ID and optionally accepts count, exclude_ids, seed, and request_options for fine-tuning the suggestions. ```python from vapi import Vapi client = Vapi( token="YOUR_TOKEN", ) client.structured_outputs.structured_output_controller_suggest( assistant_id="550e8400-e29b-41d4-a716-446655440000", ) ``` -------------------------------- ### Get Session API Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves details for a specific session using its unique identifier. ```APIDOC ## GET /sessions/{id} ### Description Retrieves a specific session by its ID. ### Method GET ### Endpoint /sessions/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the session. #### Query Parameters - **request_options** (RequestOptions) - Optional - Request-specific configuration. ### Request Example ```python client.sessions.get(id="sess_xyz789") ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the session. - **name** (string) - The name of the session. - **status** (string) - The status of the session. #### Response Example ```json { "id": "sess_xyz789", "name": "My new session", "status": "active" } ``` ``` -------------------------------- ### Create Assistant Parameters Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md This section details the parameters available for configuring an assistant's behavior, including transcriber, model, voice, messaging, and integration settings. ```APIDOC ## Create Assistant Parameters ### Description This endpoint allows for the creation and configuration of an assistant with various customizable parameters. ### Method POST ### Endpoint /assistants ### Parameters #### Request Body - **transcriber** (CreateAssistantDtoTranscriber) - Optional - Options for the assistant's transcriber. - **model** (CreateAssistantDtoModel) - Optional - Options for the assistant's LLM. - **voice** (CreateAssistantDtoVoice) - Optional - Options for the assistant's voice. - **first_message** (str) - Optional - The initial message the assistant will speak. Can also be a URL to an audio file. If unspecified, the assistant waits for user input. - **first_message_interruptions_enabled** (bool) - Optional - Controls whether interruptions are allowed for the first message. - **first_message_mode** (CreateAssistantDtoFirstMessageMode) - Optional - Defines the mode for the first message. Defaults to 'assistant-speaks-first'. Options include: - 'assistant-speaks-first': Assistant speaks first. - 'assistant-waits-for-user': Assistant waits for user to speak first. - 'assistant-speaks-first-with-model-generated-message': Assistant speaks first with a model-generated message based on conversation state. - **voicemail_detection** (CreateAssistantDtoVoicemailDetection) - Optional - Settings to configure or disable voicemail detection. Can also be configured using model.tools=[VoicemailTool]. Disabled by default. - **client_messages** (Sequence[CreateAssistantDtoClientMessagesItem]) - Optional - Messages to be sent to Client SDKs. Defaults to a comprehensive list including 'conversation-update', 'function-call', etc. - **server_messages** (Sequence[CreateAssistantDtoServerMessagesItem]) - Optional - Messages to be sent to the Server URL. Defaults to a list including 'conversation-update', 'end-of-call-report', etc. - **max_duration_seconds** (float) - Optional - The maximum duration of the call in seconds. Defaults to 600 (10 minutes). - **background_sound** (CreateAssistantDtoBackgroundSound) - Optional - The background sound for the call. Defaults to 'office' for phone calls and 'off' for web calls. Can also be a URL to a custom audio file. - **model_output_in_messages_enabled** (bool) - Optional - Determines if the model's output is used in conversation history instead of the assistant's transcribed speech. Defaults to `false` (in beta). - **transport_configurations** (Sequence[TransportConfigurationTwilio]) - Optional - Configurations for transport providers like Twilio. - **observability_plan** (LangfuseObservabilityPlan) - Optional - The observability plan for assistant calls. Currently, only Langfuse is supported. - **credentials** (Sequence[CreateAssistantDtoCredentialsItem]) - Optional - Dynamic credentials to be used for assistant calls. Overrides existing credentials. - **hooks** (Sequence[CreateAssistantDtoHooksItem]) - Optional - A set of actions to be performed on certain events. - **name** (str) - Optional - The name of the assistant. Required for transferring between assistants. - **voicemail_message** (str) - Optional - The message the assistant will speak if the call is forwarded to voicemail. If unspecified, the call will hang up. ### Request Example ```json { "transcriber": {"type": "google"}, "model": {"provider": "openai", "model": "gpt-4o"}, "voice": {"provider": "elevenlabs", "voice_id": "21m00Tcm4T8xjWf2Vd27"}, "first_message": "Hello, how can I help you today?", "max_duration_seconds": 1200, "name": "Support Assistant" } ``` ### Response #### Success Response (200) - **assistant_id** (str) - The unique identifier of the created assistant. #### Response Example ```json { "assistant_id": "asst_123abc456def" } ``` ``` -------------------------------- ### Phone Numbers API Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md APIs for managing phone numbers, including getting, deleting, and updating them. ```APIDOC ## GET /phone_numbers/{id} ### Description Retrieves details of a specific phone number. ### Method GET ### Endpoint `/phone_numbers/{id}` ### Parameters #### Path Parameters - **id** (str) - Required - The unique identifier of the phone number. #### Request Body None ### Response #### Success Response (200) - **phone_number_details** (object) - Details of the phone number. ### Request Example ```python from vapi import Vapi client = Vapi(token="YOUR_TOKEN") client.phone_numbers.get(id="id") ``` ### Response Example ```json { "phone_number_details": { "id": "pn_123", "number": "+15551234567" } } ``` ``` ```APIDOC ## DELETE /phone_numbers/{id} ### Description Deletes a specific phone number. ### Method DELETE ### Endpoint `/phone_numbers/{id}` ### Parameters #### Path Parameters - **id** (str) - Required - The unique identifier of the phone number to delete. #### Request Body None ### Response #### Success Response (200) - **message** (str) - Confirmation message of deletion. ### Request Example ```python from vapi import Vapi client = Vapi(token="YOUR_TOKEN") client.phone_numbers.delete(id="id") ``` ### Response Example ```json { "message": "Phone number deleted successfully." } ``` ``` ```APIDOC ## PUT /phone_numbers/{id} ### Description Updates an existing phone number. ### Method PUT ### Endpoint `/phone_numbers/{id}` ### Parameters #### Path Parameters - **id** (str) - Required - The unique identifier of the phone number to update. #### Request Body - **request** (UpdateByoPhoneNumberDto) - Required - The data to update the phone number with. ### Response #### Success Response (200) - **updated_phone_number** (object) - The updated phone number details. ### Request Example ```python from vapi import UpdateByoPhoneNumberDto, Vapi client = Vapi(token="YOUR_TOKEN") client.phone_numbers.update(id="id", request=UpdateByoPhoneNumberDto()) ``` ### Response Example ```json { "updated_phone_number": { "id": "pn_123", "number": "+15551234567", "status": "active" } } ``` ``` -------------------------------- ### Create File - Python Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Creates a new file. Requires a Vapi client initialized with a token. The primary input is the 'file' object, conforming to core.File. ```python from vapi import Vapi client = Vapi( token="YOUR_TOKEN", ) client.files.create() ``` -------------------------------- ### GET /phone_numbers Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves a paginated list of phone numbers. Supports filtering, sorting, and pagination parameters. ```APIDOC ## GET /phone_numbers ### Description Retrieves a paginated list of phone numbers. Supports filtering, sorting, and pagination parameters. ### Method GET ### Endpoint /phone_numbers ### Parameters #### Query Parameters - **search** (typing.Optional[str]) - Optional - Searches phone numbers by name, number, or SIP URI (partial match, case-insensitive). - **page** (typing.Optional[float]) - Optional - The page number to return. Defaults to 1. - **sort_order** (typing.Optional[PhoneNumberControllerFindAllPaginatedRequestSortOrder]) - Optional - The sort order for pagination. Defaults to 'DESC'. - **limit** (typing.Optional[float]) - Optional - The maximum number of items to return. Defaults to 100. - **created_at_gt** (typing.Optional[dt.datetime]) - Optional - Returns items where `createdAt` is greater than the specified value. - **created_at_lt** (typing.Optional[dt.datetime]) - Optional - Returns items where `createdAt` is less than the specified value. - **created_at_ge** (typing.Optional[dt.datetime]) - Optional - Returns items where `createdAt` is greater than or equal to the specified value. - **created_at_le** (typing.Optional[dt.datetime]) - Optional - Returns items where `createdAt` is less than or equal to the specified value. - **updated_at_gt** (typing.Optional[dt.datetime]) - Optional - Returns items where `updatedAt` is greater than the specified value. - **updated_at_lt** (typing.Optional[dt.datetime]) - Optional - Returns items where `updatedAt` is less than the specified value. - **updated_at_ge** (typing.Optional[dt.datetime]) - Optional - Returns items where `updatedAt` is greater than or equal to the specified value. - **updated_at_le** (typing.Optional[dt.datetime]) - Optional - Returns items where `updatedAt` is less than or equal to the specified value. - **request_options** (typing.Optional[RequestOptions]) - Optional - Request-specific configuration. ### Request Example ```python from vapi import Vapi client = Vapi(token="YOUR_TOKEN") client.phone_numbers.phone_number_controller_find_all_paginated() ``` ### Response #### Success Response (200) (Details of the phone number list would be provided here if available in the source) #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### GET /provider-resources Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves a paginated list of provider resources. Supports filtering by ID, creation/update timestamps, and sorting. ```APIDOC ## GET /provider-resources ### Description Retrieves a paginated list of provider resources. Supports filtering by ID, creation/update timestamps, and sorting. ### Method GET ### Endpoint /provider-resources ### Parameters #### Query Parameters - **provider** (ProviderResourceControllerGetProviderResourcesPaginatedRequestProvider) - Required - The provider (e.g., 11labs) - **resource_name** (ProviderResourceControllerGetProviderResourcesPaginatedRequestResourceName) - Required - The resource name (e.g., pronunciation-dictionary) - **id** (typing.Optional[str]) - Optional - Filters resources by their ID. - **resource_id** (typing.Optional[str]) - Optional - Filters resources by their resource ID. - **page** (typing.Optional[float]) - Optional - The page number to return. Defaults to 1. - **sort_order** (typing.Optional[ProviderResourceControllerGetProviderResourcesPaginatedRequestSortOrder]) - Optional - The sort order for pagination. Defaults to 'DESC'. - **limit** (typing.Optional[float]) - Optional - The maximum number of items to return. Defaults to 100. - **created_at_gt** (typing.Optional[dt.datetime]) - Optional - Returns items where the createdAt is greater than the specified value. - **created_at_lt** (typing.Optional[dt.datetime]) - Optional - Returns items where the createdAt is less than the specified value. - **created_at_ge** (typing.Optional[dt.datetime]) - Optional - Returns items where the createdAt is greater than or equal to the specified value. - **created_at_le** (typing.Optional[dt.datetime]) - Optional - Returns items where the createdAt is less than or equal to the specified value. - **updated_at_gt** (typing.Optional[dt.datetime]) - Optional - Returns items where the updatedAt is greater than the specified value. - **updated_at_lt** (typing.Optional[dt.datetime]) - Optional - Returns items where the updatedAt is less than the specified value. - **updated_at_ge** (typing.Optional[dt.datetime]) - Optional - Returns items where the updatedAt is greater than or equal to the specified value. - **updated_at_le** (typing.Optional[dt.datetime]) - Optional - Returns items where the updatedAt is less than or equal to the specified value. - **request_options** (typing.Optional[RequestOptions]) - Optional - Request-specific configuration. ### Response #### Success Response (200) - **data** (list) - A list of provider resources. - **pageInfo** (object) - Pagination information. #### Response Example ```json { "data": [ { "id": "resource-id-123", "provider": "11labs", "resource_name": "pronunciation-dictionary", "createdAt": "2023-10-27T10:00:00Z", "updatedAt": "2023-10-27T10:00:00Z" } ], "pageInfo": { "hasNextPage": true, "endCursor": "cursor-abc" } } ``` ``` -------------------------------- ### GET /phone_numbers/{id} Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves a specific phone number by its ID. This endpoint is implied by the `client.phone_numbers.get(...)` usage. ```APIDOC ## GET /phone_numbers/{id} ### Description Retrieves a specific phone number by its ID. ### Method GET ### Endpoint /phone_numbers/{id} ### Parameters #### Path Parameters - **id** (str) - Required - The unique identifier of the phone number. #### Query Parameters - **request_options** (typing.Optional[RequestOptions]) - Optional - Request-specific configuration. ### Request Example ```python from vapi import Vapi client = Vapi(token="YOUR_TOKEN") # Assuming 'phoneNumberId' is the ID of the phone number you want to retrieve client.phone_numbers.get("phoneNumberId") ``` ### Response #### Success Response (200) (Details of the specific phone number object would be listed here if available in the source) #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Upload and List Files Source: https://context7.com/vapiai/server-sdk-python/llms.txt Demonstrates file management operations, including uploading a local file (e.g., a PDF) and then listing all uploaded files. It uses `client.files.create` for uploads and `client.files.list` for retrieval. Requires a file path and `Vapi` client. ```python from vapi import Vapi client = Vapi(token="your_api_token_here") # Upload a file with open("knowledge_base.pdf", "rb") as f: file = client.files.create( file=f, name="Knowledge Base Document" ) print(f"File uploaded: {file.id}") # List all files files = client.files.list(limit=100) for file in files: print(f"File: {file.name}, Size: {file.size} bytes") ``` -------------------------------- ### GET /evals/{id} Source: https://github.com/vapiai/server-sdk-python/blob/main/reference.md Retrieves a specific evaluation by its ID. Requires the evaluation ID as a path parameter and allows for optional request options. ```APIDOC ## GET /evals/{id} ### Description Retrieves a specific evaluation by its ID. Requires the evaluation ID as a path parameter and allows for optional request options. ### Method GET ### Endpoint /evals/{id} ### Parameters #### Path Parameters - **id** (str) - Required - The unique identifier of the evaluation to retrieve. #### Query Parameters - **request_options** (Optional[RequestOptions]) - Optional - Request-specific configuration. ### Response #### Success Response (200) - **id** (str) - The ID of the evaluation. - **name** (str) - The name of the evaluation. - **description** (str) - The description of the evaluation. - **type** (str) - The type of the evaluation. - **messages** (Array) - The messages associated with the evaluation. - **created_at** (str) - The timestamp when the evaluation was created. - **updated_at** (str) - The timestamp when the evaluation was last updated. #### Response Example ```json { "id": "eval_id_123", "name": "My First Eval", "description": "Evaluating the initial greeting.", "type": "chat.mockConversation", "messages": [ { "role": "assistant", "content": "Hello! How can I help you today?" } ], "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } ``` ```