curl --request POST \
--url https://guidinghand.ai/v1/agents/{agent_id}/speaking \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"conversation_id": "conv_8f2k1m0q"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({conversation_id: 'conv_8f2k1m0q'})
};
fetch('https://guidinghand.ai/v1/agents/{agent_id}/speaking', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://guidinghand.ai/v1/agents/{agent_id}/speaking"
payload = { "conversation_id": "conv_8f2k1m0q" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"object": "speaking",
"url": "<string>",
"expires_in": 900,
"voice_id": "<string>",
"model": "eleven_v4_turbo",
"output_format": "mp3_44100_128"
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"code": "<string>",
"test_case_ids": [
"<string>"
],
"decided_by": {
"type": "person",
"email": "<string>",
"key_id": "<string>"
},
"conversation_id": "<string>",
"agent_id": "<string>",
"approval_id": "<string>",
"question_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"code": "<string>",
"test_case_ids": [
"<string>"
],
"decided_by": {
"type": "person",
"email": "<string>",
"key_id": "<string>"
},
"conversation_id": "<string>",
"agent_id": "<string>",
"approval_id": "<string>",
"question_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"code": "<string>",
"test_case_ids": [
"<string>"
],
"decided_by": {
"type": "person",
"email": "<string>",
"key_id": "<string>"
},
"conversation_id": "<string>",
"agent_id": "<string>",
"approval_id": "<string>",
"question_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"code": "<string>",
"test_case_ids": [
"<string>"
],
"decided_by": {
"type": "person",
"email": "<string>",
"key_id": "<string>"
},
"conversation_id": "<string>",
"agent_id": "<string>",
"approval_id": "<string>",
"question_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"code": "<string>",
"test_case_ids": [
"<string>"
],
"decided_by": {
"type": "person",
"email": "<string>",
"key_id": "<string>"
},
"conversation_id": "<string>",
"agent_id": "<string>",
"approval_id": "<string>",
"question_id": "<string>"
}
}Open a speech socket for an agent
Speech a line at a time, for a page that says a streamed reply as it is written: a WebSocket address on this API’s host, good for 15 minutes, which carries each line on to ElevenLabs (its text-to-dialogue socket) and the audio back, so the first audio of a line comes sooner than a request per line (POST /v1/agents//speech) and the page only talks to Eager. Once ElevenLabs’ side is open the socket sends {"relay":"ready"}. Then send each line under a context id of your own, as ElevenLabs’ three messages (voice_id is the one in this answer): {"context_id":"l1","voices":["<voice_id>"]}, {"context_id":"l1","inputs":[{"text":"…","voice_id":"<voice_id>"}],"flush":true} and {"context_id":"l1","close_context":true}. It answers with ElevenLabs’ messages, unchanged, each naming its context: audio (base64, in output_format) as it is made, then a last one with is_final, or one with error (ElevenLabs also spells the names contextId and isFinal: read both). Only the agent’s own voice speaks: any other voice id in a message is replaced. With conversation_id, the conversation becomes a web call, and the socket and each line are on its voice trace: a line’s characters, and how long its first audio took when the line had a context id. Not charged for now.
curl --request POST \
--url https://guidinghand.ai/v1/agents/{agent_id}/speaking \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"conversation_id": "conv_8f2k1m0q"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({conversation_id: 'conv_8f2k1m0q'})
};
fetch('https://guidinghand.ai/v1/agents/{agent_id}/speaking', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://guidinghand.ai/v1/agents/{agent_id}/speaking"
payload = { "conversation_id": "conv_8f2k1m0q" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"object": "speaking",
"url": "<string>",
"expires_in": 900,
"voice_id": "<string>",
"model": "eleven_v4_turbo",
"output_format": "mp3_44100_128"
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"code": "<string>",
"test_case_ids": [
"<string>"
],
"decided_by": {
"type": "person",
"email": "<string>",
"key_id": "<string>"
},
"conversation_id": "<string>",
"agent_id": "<string>",
"approval_id": "<string>",
"question_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"code": "<string>",
"test_case_ids": [
"<string>"
],
"decided_by": {
"type": "person",
"email": "<string>",
"key_id": "<string>"
},
"conversation_id": "<string>",
"agent_id": "<string>",
"approval_id": "<string>",
"question_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"code": "<string>",
"test_case_ids": [
"<string>"
],
"decided_by": {
"type": "person",
"email": "<string>",
"key_id": "<string>"
},
"conversation_id": "<string>",
"agent_id": "<string>",
"approval_id": "<string>",
"question_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"code": "<string>",
"test_case_ids": [
"<string>"
],
"decided_by": {
"type": "person",
"email": "<string>",
"key_id": "<string>"
},
"conversation_id": "<string>",
"agent_id": "<string>",
"approval_id": "<string>",
"question_id": "<string>"
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"code": "<string>",
"test_case_ids": [
"<string>"
],
"decided_by": {
"type": "person",
"email": "<string>",
"key_id": "<string>"
},
"conversation_id": "<string>",
"agent_id": "<string>",
"approval_id": "<string>",
"question_id": "<string>"
}
}Authorizations
Body
The conversation the lines are said in: one with this same agent (another agent’s is a 400, an unknown one a 404). It makes the conversation a web call (its call), unless it is a phone call, a scheduled run, a website widget’s chat or an eval’s conversation already: those stay what they are. Either way the socket and each line said on it are written on the conversation’s voice trace (GET /v1/conversations/{conversation_id}/voice) as counts and timings, and its audio is kept with the conversation (GET /v1/conversations/{conversation_id}/audio) unless the agent’s recording is off (GET /v1/agents/{agent_id}/recording). Left out, nothing is kept.
"conv_8f2k1m0q"
Response
OK