{"id":9387,"library":"vapi-server-sdk","title":"Vapi Server SDK","description":"The Vapi Python SDK provides convenient access to the Vapi API, enabling Python developers to easily integrate Vapi's conversational AI capabilities into their applications. It facilitates the creation and deployment of AI-powered virtual assistants, particularly for server-side call management like automated outbound campaigns, inbound call routing, and webhook processing. The library is actively maintained, with frequent releases often multiple times a month, reflecting continuous development and improvements.","status":"active","version":"1.10.0","language":"en","source_language":"en","source_url":"https://github.com/VapiAI/server-sdk-python","tags":["AI","voice AI","conversational AI","SDK","Vapi","API client"],"install":[{"cmd":"pip install vapi-server-sdk","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"HTTP client for API requests.","package":"httpx"},{"reason":"Backports and future-proofing for Python's typing module.","package":"typing-extensions"},{"reason":"Data validation and settings management using Python type hints.","package":"pydantic"},{"reason":"Core validation logic for Pydantic.","package":"pydantic-core"}],"imports":[{"note":"The `VapiClient` import is common in the TypeScript SDK; for Python, use `from vapi import Vapi` for the synchronous client.","wrong":"from vapi_server_sdk import VapiClient","symbol":"Vapi","correct":"from vapi import Vapi"},{"note":"Use this for the asynchronous client to make non-blocking API calls.","symbol":"AsyncVapi","correct":"from vapi import AsyncVapi"},{"note":"Base class for API-specific exceptions (4xx and 5xx responses).","symbol":"ApiError","correct":"from vapi.core.api_error import ApiError"}],"quickstart":{"code":"import os\nimport asyncio\nfrom vapi import Vapi, AsyncVapi\nfrom vapi.core.api_error import ApiError\n\n# Synchronous client example\ndef create_sync_call():\n    client = Vapi(\n        token=os.environ.get('VAPI_API_KEY', 'YOUR_VAPI_PRIVATE_API_KEY')\n    )\n    try:\n        # Example: create an outbound call (replace with actual assistant_id and phone_number_id)\n        print(\"Attempting to create a synchronous call...\")\n        # This method is illustrative; actual API calls will vary based on Vapi's current API.\n        # Refer to Vapi's official documentation for up-to-date API methods and parameters.\n        # Example: call = client.calls.create(assistant_id=\"asst_YOUR_ID\", phone_number_id=\"pn_YOUR_ID\", customer_number=\"+15551234567\")\n        # For demonstration, we'll simulate a success.\n        # In a real scenario, you would call a Vapi API method, e.g., client.calls.create(...)\n        print(\"Synchronous call creation simulated successfully.\")\n    except ApiError as e:\n        print(f\"Synchronous API Error: Status {e.status_code}, Body: {e.body}\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n\n# Asynchronous client example\nasync def create_async_call():\n    client = AsyncVapi(\n        token=os.environ.get('VAPI_API_KEY', 'YOUR_VAPI_PRIVATE_API_KEY')\n    )\n    try:\n        print(\"Attempting to create an asynchronous call...\")\n        # Similar to sync client, actual API calls depend on Vapi's current API.\n        # Example: call = await client.calls.create(assistant_id=\"asst_YOUR_ID\", phone_number_id=\"pn_YOUR_ID\", customer_number=\"+15551234567\")\n        # For demonstration, we'll simulate a success.\n        await asyncio.sleep(0.1) # Simulate async operation\n        print(\"Asynchronous call creation simulated successfully.\")\n    except ApiError as e:\n        print(f\"Asynchronous API Error: Status {e.status_code}, Body: {e.body}\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n\nif __name__ == \"__main__\":\n    print(\"--- Synchronous Vapi Client Example ---\")\n    create_sync_call()\n\n    print(\"\\n--- Asynchronous Vapi Client Example ---\")\n    asyncio.run(create_async_call())\n","lang":"python","description":"This quickstart demonstrates how to instantiate both the synchronous `Vapi` and asynchronous `AsyncVapi` clients using your Vapi API key, preferably loaded from an environment variable. It illustrates basic API interaction for creating a call and includes error handling for `ApiError` responses. Replace placeholder API calls with actual methods from the Vapi API documentation, such as `client.calls.create()` with relevant `assistant_id` and `phone_number_id`."},"warnings":[{"fix":"Migrate to the new evaluation system, call artifacts, monitoring, and updated workflow/model configurations. Refer to the Vapi changelog for details on replacements.","message":"Several legacy API endpoints have been removed as part of Vapi's API modernization, including `/logs`, `/workflow/{id}`, `/test-suite`, and `/knowledge-base` related paths.","severity":"breaking","affected_versions":"Prior to latest API version (v2 introduced)"},{"fix":"Adjust model configurations to remove `knowledgeBaseId` and integrate knowledge directly into model settings or use updated mechanisms.","message":"The `knowledgeBaseId` property has been removed from all model configurations due to a knowledge base architecture change.","severity":"breaking","affected_versions":"Prior to latest API version (v2 introduced)"},{"fix":"Utilize Vapi's smart endpointing plans for improved speech timing control, more precise conversation flow management, and enhanced end-of-turn detection capabilities.","message":"The `AssemblyAITranscriber.wordFinalizationMaxWaitTime` and `FallbackAssemblyAITranscriber.wordFinalizationMaxWaitTime` properties are deprecated.","severity":"deprecated","affected_versions":"1.x.x (exact deprecation version not specified, but mentioned in September 2025 changelog)"},{"fix":"For feature requests or bug fixes that require code changes, it's recommended to open an issue first to discuss with the VapiAI team. Pull requests can serve as proof-of-concept but may not be merged directly.","message":"The SDK is programmatically generated. Direct code contributions (outside of README) will be overwritten in future releases.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Configure the `timeout` option at the client initialization level or for individual requests using `request_options={'timeout_in_seconds': N.0}` to adjust the timeout.","message":"Requests have a default timeout of 60 seconds.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Catch `ApiError` exceptions and inspect `e.status_code` and `e.body` for specific error details. Verify API token, request parameters, and review Vapi service status.","cause":"The Vapi API returned an error response (e.g., bad request, unauthorized, server error).","error":"vapi.core.api_error.ApiError: HTTP status code (4xx or 5xx) received"},{"fix":"Ensure your server is running, publicly accessible (e.g., via ngrok for local development), and returns a valid assistant configuration. Check server logs for errors.","cause":"Your server URL, configured to dynamically provide an assistant, failed to respond or returned an error.","error":"Call failed due to 'assistant-request-failed' or 'assistant-request-returned-error'"},{"fix":"Add more credits to your Vapi account or enable auto-reload for your subscription.","cause":"Your Vapi account has insufficient credits to initiate the call.","error":"call.start.error-subscription-insufficient-credits"},{"fix":"Verify the API key for the specific provider is correct, ensure it has access to the requested models, and check if you've exceeded any rate limits or quotas with that provider.","cause":"Issues with API keys, permissions, or rate limits for integrated LLM or voice providers (e.g., OpenAI, ElevenLabs).","error":"401-incorrect-api-key, 403-model-access-denied, 429-exceeded-quota for LLM/Voice Provider"},{"fix":"This is an open issue (#22) on the GitHub repository. Monitor the official repository for updates or workarounds. Optimize environment setup to minimize pydantic re-evaluation if possible, though a direct fix is pending from the library maintainers.","cause":"Reported issue where pydantic model rendering causes performance overhead and warnings in containerized environments.","error":"High loading time and unnecessary warnings at startup in Docker (related to pydantic models)"}]}