How to create assistant in python server sdk?
# support
a
Using the python assistant how can I create an assistant and then pass this assistant ID into the client.calls.create()? ```client = Vapi(token=TOKEN) client.calls.create( assistant_id="584067-b15d-9fa8b99675fe", customer={ "number": "+112345678", # Replace with the recipient's phone number in E.164 format "name": "Bill" # Optional, just for reference }, phone_number=ImportTwilioPhoneNumberDto( twilio_phone_number="+1(123) 433-1111", twilio_account_sid=ACCOUNT_SID, twilio_auth_token=TWILIO_AUTH_TOKEN ) ) if __name__ == "__main__": client.calls.create()
v
message has been deleted
@adam21xc To create an assistant and then use its ID in the
client.calls.create()
method, you would first need to make a POST request to the Create Assistant endpoint. Once the assistant is created, you'll receive an assistant ID which you can then pass into the
client.calls.create()
method. Here's a step-by-step guide on how to do this in Python: 1. Use the VAPI to create an assistant. 2. Once the assistant is created, you'll get an assistant ID in the response. 3. Use this assistant ID in the
client.calls.create()
method. Here's a simplified example of how the code might look:
Copy code
python
client = Vapi(token=TOKEN)

# Step 1: Create an assistant and get the assistant ID
assistant_id = client.create_assistant(name="New Assistant", ...).id  # Replace ... with other necessary parameters

# Step 2: Use the assistant ID in the calls.create method
response = client.calls.create(
    assistant_id=assistant_id,
    customer={
        "number": "+112345678",  # Replace with the recipient's phone number in E.164 format
        "name": "Bill"  # Optional, just for reference
    },
    phone_number=ImportTwilioPhoneNumberDto(
        twilio_phone_number="+1(123) 433-1111",
        twilio_account_sid=ACCOUNT_SID,
        twilio_auth_token=TWILIO_AUTH_TOKEN
    )
)

# The rest of your code...
Please note that you need to replace the placeholders (e.g.,
TOKEN
,
ACCOUNT_SID
,
TWILIO_AUTH_TOKEN
, etc.) with actual values and provide any additional required parameters for creating an assistant. If you need to create the assistant as part of this support session, please provide the necessary details to make the POST request to the Create Assistant endpoint, and I can assist you further with that.
You can continue this conversation by mentioning me in the message.
a
@Vapi how do I pass in the other parameters such as the model type, transcriber, voice, etc?
v
@adam21xc To pass in additional parameters such as the model type, transcriber, and voice when creating an assistant or making a call, you would typically use the configuration options provided by the API. These parameters would be part of the payload you send in your API request. Here's an example of how you might specify these parameters when creating an assistant:
Copy code
python
client = Vapi(token=TOKEN)

# Define your assistant configuration
assistant_config = {
    "model": "default",  # Replace with your desired model type
    "transcriber": "default",  # Replace with your desired transcriber
    "voice": "default"  # Replace with your desired voice
    # Add any other configurations as needed
}

# Step 1: Create an assistant with the specified configuration and get the assistant ID
assistant_id = client.create_assistant(name="New Assistant", config=assistant_config).id

# Step 2: Use the assistant ID in the calls.create method
response = client.calls.create(
    assistant_id=assistant_id,
    customer={
        "number": "+112345678",  # Replace with the recipient's phone number in E.164 format
        "name": "Bill"  # Optional, just for reference
    },
    phone_number=ImportTwilioPhoneNumberDto(
        twilio_phone_number="+1(123) 433-1111",
        twilio_account_sid=ACCOUNT_SID,
        twilio_auth_token=TWILIO_AUTH_TOKEN
    )
    # Add any other call configurations as needed
)

# The rest of your code...
Please replace
"default"
with the actual values you want to use for the model, transcriber, and voice. If you have specific values or configurations you'd like to apply, please provide them, and I can help you incorporate those into the code. Remember to replace the placeholders with actual values and ensure that all required parameters are included in your request. If you need more information on the specific parameters and their valid values, please ask support for more info on this.
a
@Vapi for the transcriber I would like to use deepgram, model = groq, voice= 11labs --> sarah, firstMessageMode =assistant-waits-for-user,
s
createCallusingAssistantId
Copy code
py
from vapi import Vapi
from vapi import CreateCustomerDto

client = Vapi(token="YOUR_TOKEN", )        
client.calls.create(
    name="CreateCallUsingAssistantId",
    assistant_id="<insert-your-assistant-id-here>",
    phone_number_id="<insert-phone-number-id-here>",
    customer=CreateCustomerDto(
        number_e_164_check_enabled=false,
        number="<insert-custom-number-here>"
    )
)
createAssistant
Copy code
py
from vapi import Vapi
from vapi.create_assistant_dto import CreateAssistantDto, CreateAssistantDtoModel, CreateAssistantDtoVoice
from vapi.environment import VapiEnvironment

client = Vapi(
    token="YOUR_TOKEN"
)

assistant_params = CreateAssistantDto(
    name="MyVapiAssistant",
    model=CreateAssistantDtoModel(...
    ),
    voice=CreateAssistantDtoVoice(...
    ),
    first_message_mode="assistant-speaks-first",
    silence_timeout_seconds=30,
    max_duration_seconds=600,
    backchanneling_enabled=False,
    # Include any other parameters based on your needs
)

# Create the assistant
assistant_response = client.assistants.create_assistant(assistant_params)
print("Assistant created:", assistant_response)
@adam21xc do let me know how it goes.
Because of no response closing this ticket.
26 Views