Speak
curl --request PUT \
--url https://api.trugen.ai/v1/conversation/{conversation_id}/speak \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"text": "Hello, Hi from team trugen."
}
'import requests
url = "https://api.trugen.ai/v1/conversation/{conversation_id}/speak"
payload = { "text": "Hello, Hi from team trugen." }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({text: 'Hello, Hi from team trugen.'})
};
fetch('https://api.trugen.ai/v1/conversation/{conversation_id}/speak', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trugen.ai/v1/conversation/{conversation_id}/speak",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'text' => 'Hello, Hi from team trugen.'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trugen.ai/v1/conversation/{conversation_id}/speak"
payload := strings.NewReader("{\n \"text\": \"Hello, Hi from team trugen.\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.trugen.ai/v1/conversation/{conversation_id}/speak")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Hello, Hi from team trugen.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trugen.ai/v1/conversation/{conversation_id}/speak")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"Hello, Hi from team trugen.\"\n}"
response = http.request(request)
puts response.read_body{
"message": "Agent is speaking the provided text."
}{
"error": "Unauthorized: not a valid authorization api key"
}{
"error": "Conversation not found"
}{
"error": "Failed to process speak request"
}Conversations
Speak
Send a text message to an active conversation and the agent will speak it aloud.
PUT
/
v1
/
conversation
/
{conversation_id}
/
speak
Speak
curl --request PUT \
--url https://api.trugen.ai/v1/conversation/{conversation_id}/speak \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"text": "Hello, Hi from team trugen."
}
'import requests
url = "https://api.trugen.ai/v1/conversation/{conversation_id}/speak"
payload = { "text": "Hello, Hi from team trugen." }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({text: 'Hello, Hi from team trugen.'})
};
fetch('https://api.trugen.ai/v1/conversation/{conversation_id}/speak', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.trugen.ai/v1/conversation/{conversation_id}/speak",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'text' => 'Hello, Hi from team trugen.'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.trugen.ai/v1/conversation/{conversation_id}/speak"
payload := strings.NewReader("{\n \"text\": \"Hello, Hi from team trugen.\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.trugen.ai/v1/conversation/{conversation_id}/speak")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Hello, Hi from team trugen.\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trugen.ai/v1/conversation/{conversation_id}/speak")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"Hello, Hi from team trugen.\"\n}"
response = http.request(request)
puts response.read_body{
"message": "Agent is speaking the provided text."
}{
"error": "Unauthorized: not a valid authorization api key"
}{
"error": "Conversation not found"
}{
"error": "Failed to process speak request"
}Make the agent speak arbitrary text mid-conversation. Overrides whatever the agent was about to say. Use for scripted interjections, custom greetings, or human-in-the-loop takeover.
With
When to use
- Human handoff: a live agent takes over and needs to say a specific thing
- System notifications: announce something the LLM shouldn’t have to reason about (“Your call is being transferred…”)
- Custom greetings: inject a personalized greeting the LLM might otherwise phrase awkwardly
- Scripted flows: force the agent to say a specific line at a specific point in a structured workflow
What it does
The current LLM turn (if any) is interrupted. The text you supply is sent straight to TTS and the avatar renders it. After the utterance completes, the LLM regains control on the user’s next turn.Example
curl --request PUT \
--url https://api.trugen.ai/v1/conversation/{conversation_id}/speak \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"text": "One moment while I transfer you to a human agent.",
"interrupt": true
}'
Interrupt behavior
interrupt | Effect |
|---|---|
true (default) | Cut off any current agent utterance; speak the new text immediately |
false | Wait for the current utterance to finish, then speak the new text |
Add context afterwards
If you want the LLM to know it just said something outside its usual turn:{
"text": "One moment while I transfer you.",
"interrupt": true,
"add_to_context": true
}
add_to_context: true, the utterance is added to the LLM’s message history so it can reason about what was said.
Common uses
Trigger a personalized greeting
// After session starts, before the agent's default greeting
await fetch(
`https://api.trugen.ai/v1/conversation/${conversationId}/speak`,
{
method: "PUT",
headers: { "x-api-key": KEY, "Content-Type": "application/json" },
body: JSON.stringify({
text: `Hi ${userName}, good to see you back. Last time you were asking about ${lastTopic}: where do you want to pick up?`,
interrupt: true,
}),
}
);
Announce transfer to human
{
"text": "Let me connect you with Alex from our team. Please hold for a moment.",
"interrupt": true,
"add_to_context": true
}
Next steps
Authorizations
Path Parameters
The unique identifier of the active conversation.
Example:
"conv_abc123"
Body
application/json
The text the agent should speak in the conversation.
Example:
"Hello, Hi from team trugen."
Response
The agent has spoken the provided text.
Example:
"Agent is speaking the provided text."
Was this page helpful?