{"id":28486503,"url":"https://github.com/techwithty/vapi-python-template","last_synced_at":"2025-07-03T08:30:52.793Z","repository":{"id":285882282,"uuid":"959531805","full_name":"TechWithTy/vapi-python-template","owner":"TechWithTy","description":null,"archived":false,"fork":false,"pushed_at":"2025-05-26T23:35:23.000Z","size":211,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-08T01:43:29.533Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TechWithTy.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-02T23:58:34.000Z","updated_at":"2025-05-26T23:35:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"2ec79881-e90c-4a9f-ba4c-e12c98d7f787","html_url":"https://github.com/TechWithTy/vapi-python-template","commit_stats":null,"previous_names":["techwithty/vapi-python-template"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/TechWithTy/vapi-python-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechWithTy%2Fvapi-python-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechWithTy%2Fvapi-python-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechWithTy%2Fvapi-python-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechWithTy%2Fvapi-python-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TechWithTy","download_url":"https://codeload.github.com/TechWithTy/vapi-python-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TechWithTy%2Fvapi-python-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263290267,"owners_count":23443562,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-08T01:35:08.892Z","updated_at":"2025-07-03T08:30:52.784Z","avatar_url":"https://github.com/TechWithTy.png","language":"Python","readme":"# VAPI API Integration Template\n\nThis template provides pre-implemented functions for all VAPI endpoints, making it suitable for creating an SDK or streamlining API integration with Python applications. Each endpoint function is already implemented with proper request formatting and error handling.\n\n## Overview\n\n[VAPI](https://vapi.ai/) is a platform for building AI voice applications that can handle phone calls, voice messaging, and other voice-based interactions. This template simplifies the integration process with pre-built functions for all available endpoints.\n\n## Installation\n\n1. Clone this repository:\n   ```bash\n   git clone https://github.com/yourusername/vapi-python-template.git\n   cd vapi-python-template\n   ```\n\n2. Install required dependencies:\n   ```bash\n   pip install requests  # Or other HTTP client library used in the template\n   ```\n\n3. Set your VAPI API key:\n   ```python\n   # In your code\n   VAPI_API_KEY = \"your_api_key_here\"\n   \n   # Or as an environment variable\n   # export VAPI_API_KEY=\"your_api_key_here\"\n   ```\n\n## Authentication\n\nAll functions in the template handle authentication automatically by including your API key in the headers:\n\n```python\nheaders = {\n    \"Authorization\": f\"Bearer {api_key}\",\n    \"Content-Type\": \"application/json\"\n}\n```\n\n## Available Endpoints\n\n### Phone Calls\n\n#### Create a Call\n\n```python\ndef create_call(recipient_number, assistant_id, caller_id=None, webhook_url=None, webhook_events=None):\n    \"\"\"\n    Start a new phone call.\n    \n    Args:\n        recipient_number (str): Phone number to call (E.164 format)\n        assistant_id (str): ID of the assistant to use for the call\n        caller_id (str, optional): Phone number to show as caller ID\n        webhook_url (str, optional): URL to receive webhook events\n        webhook_events (list, optional): List of webhook events to subscribe to\n        \n    Returns:\n        dict: Call details including call_id\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### List Calls\n\n```python\ndef list_calls(limit=10, offset=0, status=None):\n    \"\"\"\n    List phone calls with pagination and optional filtering.\n    \n    Args:\n        limit (int, optional): Maximum number of calls to return\n        offset (int, optional): Pagination offset\n        status (str, optional): Filter by call status\n        \n    Returns:\n        dict: List of calls and pagination metadata\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Get Call Details\n\n```python\ndef get_call(call_id):\n    \"\"\"\n    Get details about a specific call.\n    \n    Args:\n        call_id (str): ID of the call to retrieve\n        \n    Returns:\n        dict: Call details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### End Call\n\n```python\ndef end_call(call_id):\n    \"\"\"\n    End an active call.\n    \n    Args:\n        call_id (str): ID of the call to end\n        \n    Returns:\n        dict: Updated call details\n    \"\"\"\n    # Implementation already available in template\n```\n\n### Assistants\n\n#### Create Assistant\n\n```python\ndef create_assistant(name, voice, first_message, model=\"gpt-4\", instructions=None, metadata=None):\n    \"\"\"\n    Create a new voice assistant.\n    \n    Args:\n        name (str): Name of the assistant\n        voice (str): Voice ID to use (e.g., \"shimmer\", \"echo\", \"nova\")\n        first_message (str): First message the assistant will say\n        model (str, optional): Language model to use\n        instructions (str, optional): Custom instructions for the assistant\n        metadata (dict, optional): Custom metadata\n        \n    Returns:\n        dict: Created assistant details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### List Assistants\n\n```python\ndef list_assistants(limit=10, offset=0):\n    \"\"\"\n    List voice assistants with pagination.\n    \n    Args:\n        limit (int, optional): Maximum number of assistants to return\n        offset (int, optional): Pagination offset\n        \n    Returns:\n        dict: List of assistants and pagination metadata\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Get Assistant\n\n```python\ndef get_assistant(assistant_id):\n    \"\"\"\n    Get details about a specific assistant.\n    \n    Args:\n        assistant_id (str): ID of the assistant to retrieve\n        \n    Returns:\n        dict: Assistant details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Update Assistant\n\n```python\ndef update_assistant(assistant_id, updates):\n    \"\"\"\n    Update an existing assistant.\n    \n    Args:\n        assistant_id (str): ID of the assistant to update\n        updates (dict): Fields to update\n        \n    Returns:\n        dict: Updated assistant details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Delete Assistant\n\n```python\ndef delete_assistant(assistant_id):\n    \"\"\"\n    Delete an assistant.\n    \n    Args:\n        assistant_id (str): ID of the assistant to delete\n        \n    Returns:\n        dict: Deletion confirmation\n    \"\"\"\n    # Implementation already available in template\n```\n\n### Phone Numbers\n\n#### List Phone Numbers\n\n```python\ndef list_phone_numbers(limit=10, offset=0):\n    \"\"\"\n    List phone numbers associated with your account.\n    \n    Args:\n        limit (int, optional): Maximum number of phone numbers to return\n        offset (int, optional): Pagination offset\n        \n    Returns:\n        dict: List of phone numbers and pagination metadata\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Get Phone Number\n\n```python\ndef get_phone_number(phone_number_id):\n    \"\"\"\n    Get details about a specific phone number.\n    \n    Args:\n        phone_number_id (str): ID of the phone number to retrieve\n        \n    Returns:\n        dict: Phone number details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Update Phone Number\n\n```python\ndef update_phone_number(phone_number_id, assistant_id=None, webhook_url=None, webhook_events=None):\n    \"\"\"\n    Update configuration for a phone number.\n    \n    Args:\n        phone_number_id (str): ID of the phone number to update\n        assistant_id (str, optional): ID of the assistant to use for inbound calls\n        webhook_url (str, optional): URL to receive webhook events\n        webhook_events (list, optional): List of webhook events to subscribe to\n        \n    Returns:\n        dict: Updated phone number details\n    \"\"\"\n    # Implementation already available in template\n```\n\n### Messages\n\n#### Send Message\n\n```python\ndef send_message(to_number, assistant_id, content, from_number=None, webhook_url=None):\n    \"\"\"\n    Send a voice message to a phone number.\n    \n    Args:\n        to_number (str): Phone number to send the message to (E.164 format)\n        assistant_id (str): ID of the assistant to use for the message\n        content (str): Text content of the message\n        from_number (str, optional): Phone number to send from\n        webhook_url (str, optional): URL to receive webhook events\n        \n    Returns:\n        dict: Message details including message_id\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### List Messages\n\n```python\ndef list_messages(limit=10, offset=0, status=None):\n    \"\"\"\n    List messages with pagination and optional filtering.\n    \n    Args:\n        limit (int, optional): Maximum number of messages to return\n        offset (int, optional): Pagination offset\n        status (str, optional): Filter by message status\n        \n    Returns:\n        dict: List of messages and pagination metadata\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Get Message\n\n```python\ndef get_message(message_id):\n    \"\"\"\n    Get details about a specific message.\n    \n    Args:\n        message_id (str): ID of the message to retrieve\n        \n    Returns:\n        dict: Message details\n    \"\"\"\n    # Implementation already available in template\n```\n\n### Test Suites\n\n#### Create Test Suite\n\n```python\ndef create_test_suite(name, assistant_id, description=None):\n    \"\"\"\n    Create a new test suite for an assistant.\n    \n    Args:\n        name (str): Name of the test suite\n        assistant_id (str): ID of the assistant to test\n        description (str, optional): Description of the test suite\n        \n    Returns:\n        dict: Created test suite details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### List Test Suites\n\n```python\ndef list_test_suites(limit=10, offset=0):\n    \"\"\"\n    List test suites with pagination.\n    \n    Args:\n        limit (int, optional): Maximum number of test suites to return\n        offset (int, optional): Pagination offset\n        \n    Returns:\n        dict: List of test suites and pagination metadata\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Get Test Suite\n\n```python\ndef get_test_suite(test_suite_id):\n    \"\"\"\n    Get details about a specific test suite.\n    \n    Args:\n        test_suite_id (str): ID of the test suite to retrieve\n        \n    Returns:\n        dict: Test suite details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Update Test Suite\n\n```python\ndef update_test_suite(test_suite_id, updates):\n    \"\"\"\n    Update an existing test suite.\n    \n    Args:\n        test_suite_id (str): ID of the test suite to update\n        updates (dict): Fields to update\n        \n    Returns:\n        dict: Updated test suite details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Delete Test Suite\n\n```python\ndef delete_test_suite(test_suite_id):\n    \"\"\"\n    Delete a test suite.\n    \n    Args:\n        test_suite_id (str): ID of the test suite to delete\n        \n    Returns:\n        dict: Deletion confirmation\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Run Test Suite\n\n```python\ndef run_test_suite(test_suite_id):\n    \"\"\"\n    Run a test suite.\n    \n    Args:\n        test_suite_id (str): ID of the test suite to run\n        \n    Returns:\n        dict: Test run details including run_id\n    \"\"\"\n    # Implementation already available in template\n```\n\n### Test Cases\n\n#### Create Test Case\n\n```python\ndef create_test_case(test_suite_id, name, conversation_turns, description=None):\n    \"\"\"\n    Create a new test case within a test suite.\n    \n    Args:\n        test_suite_id (str): ID of the test suite\n        name (str): Name of the test case\n        conversation_turns (list): List of conversation turn objects\n        description (str, optional): Description of the test case\n        \n    Returns:\n        dict: Created test case details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### List Test Cases\n\n```python\ndef list_test_cases(test_suite_id, limit=10, offset=0):\n    \"\"\"\n    List test cases for a test suite with pagination.\n    \n    Args:\n        test_suite_id (str): ID of the test suite\n        limit (int, optional): Maximum number of test cases to return\n        offset (int, optional): Pagination offset\n        \n    Returns:\n        dict: List of test cases and pagination metadata\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Get Test Case\n\n```python\ndef get_test_case(test_case_id):\n    \"\"\"\n    Get details about a specific test case.\n    \n    Args:\n        test_case_id (str): ID of the test case to retrieve\n        \n    Returns:\n        dict: Test case details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Update Test Case\n\n```python\ndef update_test_case(test_case_id, updates):\n    \"\"\"\n    Update an existing test case.\n    \n    Args:\n        test_case_id (str): ID of the test case to update\n        updates (dict): Fields to update\n        \n    Returns:\n        dict: Updated test case details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Delete Test Case\n\n```python\ndef delete_test_case(test_case_id):\n    \"\"\"\n    Delete a test case.\n    \n    Args:\n        test_case_id (str): ID of the test case to delete\n        \n    Returns:\n        dict: Deletion confirmation\n    \"\"\"\n    # Implementation already available in template\n```\n\n### Custom Voices\n\n#### Create Custom Voice\n\n```python\ndef create_custom_voice(name, samples, description=None):\n    \"\"\"\n    Create a new custom voice.\n    \n    Args:\n        name (str): Name of the custom voice\n        samples (list): List of audio samples (base64 encoded)\n        description (str, optional): Description of the custom voice\n        \n    Returns:\n        dict: Created custom voice details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### List Custom Voices\n\n```python\ndef list_custom_voices(limit=10, offset=0):\n    \"\"\"\n    List custom voices with pagination.\n    \n    Args:\n        limit (int, optional): Maximum number of custom voices to return\n        offset (int, optional): Pagination offset\n        \n    Returns:\n        dict: List of custom voices and pagination metadata\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Get Custom Voice\n\n```python\ndef get_custom_voice(custom_voice_id):\n    \"\"\"\n    Get details about a specific custom voice.\n    \n    Args:\n        custom_voice_id (str): ID of the custom voice to retrieve\n        \n    Returns:\n        dict: Custom voice details\n    \"\"\"\n    # Implementation already available in template\n```\n\n#### Delete Custom Voice\n\n```python\ndef delete_custom_voice(custom_voice_id):\n    \"\"\"\n    Delete a custom voice.\n    \n    Args:\n        custom_voice_id (str): ID of the custom voice to delete\n        \n    Returns:\n        dict: Deletion confirmation\n    \"\"\"\n    # Implementation already available in template\n```\n\n### Webhooks\n\n```python\ndef verify_webhook_signature(payload, signature, secret):\n    \"\"\"\n    Verify the signature of a webhook event.\n    \n    Args:\n        payload (str): Raw webhook payload\n        signature (str): Signature from the X-VAPI-Signature header\n        secret (str): Your webhook secret\n        \n    Returns:\n        bool: Whether the signature is valid\n    \"\"\"\n    # Implementation already available in template\n```\n\n## Data Types\n\n### Call Object\n\n```python\n{\n    \"id\": \"call_abc123\",\n    \"object\": \"call\",\n    \"created_at\": \"2023-01-01T12:00:00.000Z\",\n    \"updated_at\": \"2023-01-01T12:05:00.000Z\",\n    \"status\": \"completed\",  # queued, ringing, in-progress, completed, failed\n    \"duration\": 300,  # seconds\n    \"recipient\": {\n        \"phone_number\": \"+15551234567\"\n    },\n    \"caller\": {\n        \"phone_number\": \"+15559876543\"\n    },\n    \"assistant_id\": \"asst_abc123\",\n    \"metadata\": { }\n}\n```\n\n### Assistant Object\n\n```python\n{\n    \"id\": \"asst_abc123\",\n    \"object\": \"assistant\",\n    \"created_at\": \"2023-01-01T12:00:00.000Z\",\n    \"updated_at\": \"2023-01-01T12:05:00.000Z\",\n    \"name\": \"Customer Support\",\n    \"model\": \"gpt-4\",\n    \"voice\": \"shimmer\",\n    \"first_message\": \"Hello, how can I help you today?\",\n    \"instructions\": \"You are a helpful customer support agent.\",\n    \"metadata\": { }\n}\n```\n\n### Phone Number Object\n\n```python\n{\n    \"id\": \"pn_abc123\",\n    \"object\": \"phone_number\",\n    \"created_at\": \"2023-01-01T12:00:00.000Z\",\n    \"updated_at\": \"2023-01-01T12:05:00.000Z\",\n    \"phone_number\": \"+15551234567\",\n    \"country\": \"US\",\n    \"active\": true,\n    \"configuration\": {\n        \"assistant_id\": \"asst_abc123\",\n        \"webhook_url\": \"https://example.com/webhook\",\n        \"webhook_events\": [\"call.completed\", \"call.failed\"]\n    }\n}\n```\n\n### Message Object\n\n```python\n{\n    \"id\": \"msg_abc123\",\n    \"object\": \"message\",\n    \"created_at\": \"2023-01-01T12:00:00.000Z\",\n    \"updated_at\": \"2023-01-01T12:05:00.000Z\",\n    \"status\": \"delivered\",  # queued, sending, delivered, failed\n    \"to\": \"+15551234567\",\n    \"from\": \"+15559876543\",\n    \"assistant_id\": \"asst_abc123\",\n    \"content\": \"Hello, this is your reminder about tomorrow's appointment.\",\n    \"duration\": 15,  # seconds\n    \"metadata\": { }\n}\n```\n\n### Test Suite Object\n\n```python\n{\n    \"id\": \"ts_abc123\",\n    \"object\": \"test_suite\",\n    \"created_at\": \"2023-01-01T12:00:00.000Z\",\n    \"updated_at\": \"2023-01-01T12:05:00.000Z\",\n    \"name\": \"Customer Support Tests\",\n    \"description\": \"Tests for the customer support assistant\",\n    \"assistant_id\": \"asst_abc123\",\n    \"test_cases_count\": 5\n}\n```\n\n### Test Case Object\n\n```python\n{\n    \"id\": \"tc_abc123\",\n    \"object\": \"test_case\",\n    \"created_at\": \"2023-01-01T12:00:00.000Z\",\n    \"updated_at\": \"2023-01-01T12:05:00.000Z\",\n    \"name\": \"Order Status Inquiry\",\n    \"description\": \"Customer asking about order status\",\n    \"test_suite_id\": \"ts_abc123\",\n    \"conversation_turns\": [\n        {\n            \"role\": \"user\",\n            \"content\": \"Can you tell me the status of my order?\"\n        },\n        {\n            \"role\": \"assistant\",\n            \"expected_response_contains\": [\"order\", \"status\", \"check\"]\n        }\n    ]\n}\n```\n\n### Custom Voice Object\n\n```python\n{\n    \"id\": \"cv_abc123\",\n    \"object\": \"custom_voice\",\n    \"created_at\": \"2023-01-01T12:00:00.000Z\",\n    \"updated_at\": \"2023-01-01T12:05:00.000Z\",\n    \"name\": \"Company Voice\",\n    \"description\": \"Custom voice for company branding\",\n    \"status\": \"ready\",  # processing, ready, failed\n    \"samples_count\": 3\n}\n```\n\n## Error Handling\n\nAll functions include proper error handling with descriptive error messages:\n\n```python\ndef example_function():\n    try:\n        # API request\n        response = requests.post(url, json=data, headers=headers)\n        response.raise_for_status()  # Raise exception for 4XX/5XX responses\n        return response.json()\n    except requests.exceptions.RequestException as e:\n        if hasattr(e, 'response') and e.response is not None:\n            error_message = e.response.json().get('message', str(e))\n            status_code = e.response.status_code\n            raise Exception(f\"VAPI API Error ({status_code}): {error_message}\")\n        else:\n            raise Exception(f\"VAPI API Connection Error: {str(e)}\")\n```\n\n## Pagination\n\nFunctions that return lists support pagination:\n\n```python\n# Example use of pagination\npage1 = list_calls(limit=10, offset=0)\npage2 = list_calls(limit=10, offset=10)\n```\n\n## Webhook Handling\n\nExample of processing a VAPI webhook:\n\n```python\n# Flask example\nfrom flask import Flask, request, jsonify\n\napp = Flask(__name__)\n\n@app.route('/vapi-webhook', methods=['POST'])\ndef vapi_webhook():\n    event = request.json\n    \n    # Verify webhook signature\n    signature = request.headers.get('X-VAPI-Signature')\n    is_valid = verify_webhook_signature(\n        request.data.decode('utf-8'),\n        signature,\n        \"your_webhook_secret\"\n    )\n    \n    if not is_valid:\n        return jsonify({\"error\": \"Invalid signature\"}), 401\n    \n    # Handle different event types\n    event_type = event.get('type')\n    \n    if event_type == 'call.completed':\n        # Handle completed call\n        call_id = event.get('data', {}).get('id')\n        # Process call data\n        \n    elif event_type == 'message.delivered':\n        # Handle delivered message\n        message_id = event.get('data', {}).get('id')\n        # Process message data\n    \n    return jsonify({\"status\": \"success\"}), 200\n```\n\n## Resources\n\n- [VAPI Documentation](https://docs.vapi.ai/)\n- [API Reference](https://docs.vapi.ai/api-reference)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechwithty%2Fvapi-python-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechwithty%2Fvapi-python-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechwithty%2Fvapi-python-template/lists"}