How to set system prompt via API
# support
o
How can I set the Vapi assistant's "system prompt" (which is called that in the vapi UI) via API? I do not see any options here: https://docs.vapi.ai/api-reference/assistants/update
v
To set the Vapi assistant's "system prompt" via API, you'll need to update the assistant using the appropriate API endpoint. Here’s how you can do it: ### API Endpoint and Method - Endpoint:
https://api.vapi.ai/assistants/{assistantId}
- Replace
{assistantId}
with your assistant's actual ID. - HTTP Method: Use either PUT or PATCH to update the assistant. ### Request Payload You need to include the system prompt in your request payload as part of a JSON object. Here’s an example of how to structure it:
Copy code
json
{
  "model": {
    "provider": "openai",
    "model": "gpt-4o",
    "messages": [
      {
        "role": "system",
        "content": "You are a smart assistant who responds to user queries using the information you know, or information supplied by outside context."
      }
    ]
  }
}
### Curl Example Here’s a Curl command to update the assistant’s system prompt:
Copy code
bash
curl --location --request PATCH 'https://api.vapi.ai/assistants/{assistantId}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--data '{
  "model": {
    "provider": "openai",
    "model": "gpt-4o",
    "messages": [
      {
        "role": "system",
        "content": "insert-your-system-prompt-here"
      }
    ],
    "temperature": 0.2
  }
}'
Make sure to replace
{assistantId}
and
YOUR_API_TOKEN
with your actual values. ### Key Considerations 1. Ensure that the field names and structure match the Vapi API documentation, as they are case-sensitive. 2. If you encounter issues, check for any error messages that might indicate what went wrong with the update. For more detailed information, you can refer to the [Vapi API documentation](https://docs.vapi.ai/api-reference/assistants/update). Source: - [Vapi API Reference Update Assistants](https://docs.vapi.ai/api-reference/assistants/update)
Message marked as helpful by @one.hedge! 🎉
s
@one.hedge checking if this is resolved for you!!
2 Views