https://retellai.com/?utm_source=discord&utm_medium=seo logo
can i update the prompt via API
# ❓・ai-evy-support
n
@AI Evy can i update the prompt via API?
a
Thanks for tagging me @nicottone. I'll look through relevant sources and get back to you shortly.
### Answer Yes, you can update the prompt via the API using the Update Retell LLM endpoint. [(1) ]() Use the
PATCH /update-retell-llm/{llm_id}
endpoint to update the
general_prompt
field. Here's an example using the JavaScript SDK:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const llmResponse = await client.llm.update('16b980523634a6dc504898cda492e939', {
  begin_message: 'Hey I am a virtual assistant calling from Retell Hospital.',
}) ;
console.log(llmResponse.llm_id) ;
You can include
general_prompt
in the request body to update the prompt content. Note: If you want changes to take effect immediately without publishing from the dashboard, set your agent to use the Draft version at the phone number level. [(5) ]()
​ To learn more, see the sources I considered: [[1] Update Retell LLM](https://docs.retellai.com/api-references/update-retell-llm) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
n
Give me the API REST
@AI Evy Give me the curl to use the API REST
a
Thanks for the follow-up, @nicottone. I'll get back to you soon.
### Answer To update the prompt via REST API, use the PATCH endpoint for Update Retell LLM. [(1) ]() Here's the curl command:
Copy code
bash
curl --request PATCH \
  --url <https://api.retellai.com/update-retell-llm/%7Bllm_id%7D> \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "general_prompt": "Your updated prompt here"
  }'
, [(2) ]() Replace: -
{llm_id}
with your Retell LLM ID [(1) ]() -
YOUR_API_KEY
with your Retell API key [(2) ]() The
general_prompt
field is the prompt appended to the system prompt regardless of agent state. [(1) ]()
​ To learn more, see the sources I considered: [[1] Update Retell LLM](https://docs.retellai.com/api-references/update-retell-llm) [[2] API Key Overview](https://docs.retellai.com/accounts/api-keys-overview) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
n
@AI Evy Give me the curl to update the initial message, prompt and voice of the agent
a
Thanks for the follow-up, @nicottone. I'll get back to you soon.
### Answer ### Answer You'll need two separate API calls since the initial message and prompt are on the LLM, while the voice is on the Agent. 1. Update initial message and prompt (Retell LLM) :
Copy code
bash
curl --request PATCH \
  --url <https://api.retellai.com/update-retell-llm/%7Bllm_id%7D> \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "begin_message": "Hey I am a virtual assistant calling from Retell Hospital.",
    "general_prompt": "You are ..."
  }'
[(1) ]() 2. Update voice (Voice Agent) :
Copy code
bash
curl --request PATCH \
  --url <https://api.retellai.com/update-agent/%7Bagent_id%7D> \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "voice_id": "11labs-Adrian"
  }'
[(2) ]() Key fields: - `begin_message`: First utterance said by the agent in the call [(1) ]() - `general_prompt`: Prompt appended to system prompt regardless of state - `voice_id`: Unique voice id for the agent (find available voices in Dashboard) [(2) ]() Replace
{llm_id}
,
{agent_id}
, and
YOUR_API_KEY
with your actual values.
​ To learn more, see the sources I considered: [[1] Update Retell LLM](https://docs.retellai.com/api-references/update-retell-llm) [[2] Update Voice Agent](https://docs.retellai.com/api-references/update-agent) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.