Generate Response
Generate a response from a clone to a user message
Body
The id
of the conversation that you want the clone generated response to be
a part of Clone responses use the history of the selectd conversation while
generating a response, so ensure that this id
is correct Use the Get
Conversation History endpoint if you
would like to see the previous messages in a given conversation in order to
validate
The text of the message that you are sending to the clone to get a response.
Publicly accessible link to an image if you want to use clone vision capabilities.
Your audio sent as a single blob of base64 encoded bytes. Audio MUST be a
single-channel .wav file in 44.1lkHz sample rate
and pcm_s16le
encoding.
Make sure to review the code example below for the specific format required
when sending and receiving audio.
Format of the response you want to receive. Valid inputs are text
or
voice
. Defaults to text
. If set to voice
, clone will respond with base64
encoded audio.
Determines whether or not the response will be the default response format, or
if the clone’s response will be streamed back to the requester token by token
in a stream of Server-Sent Events
. If streaming is turned on and
response_type
is set to voice
, the clone will respond with a stream of
base64 encoded audio snippets. See the audio code example below for more info.
⚠️ Prerequisite ⚠️
In order for the clone to be able to generate responses it must have a purpose, description, and at least one document all added on the clone editing page.
If your clone does not yet, you will receive a 403 response from this endpoint warning you to add these before continuing.
Default Response
The id
of the clone’s message
The id
of the conversation that the generated clone response belongs to
The text of the generated clone response. This field will be called transcript
if response_type == voice
.
This field will only exist if response_type == voice
and stream == false
. It includes the complete base64 encoded audio response from the clone.
UTC datetime
string of when the clone’s response was generated
An array of citations that are used in the clone’s response (url, title, text, and type)
A publicly accessible image url (if any) that the clone may send when appropriate for its response.
Affiliate product (if any) related to the user’s query.
Stream Response
The stream
response will send the clone response back to the user in a stream of server-sent events
as tokens in the response become available
The format of the events are similar to the Default Response except:
- There is one extra field in the stream response type called
current_token
ifresponse_type == text
.audio_chunk
ifresponse_type == voice
. - If
response_type
is set totext
,current_token
will be text. Ifresponse_type
is set tovoice
,audio_chunk
will be a chunk of base64 encoded audio. - The
clone_response
field isnull
while the response is still generating. The response event will include the full details at the end of the stream in the last event
View the Example Stream Response on the sidebar to see an example
The next generated token in the clone’s response string
The clone has finished generating when this is [DONE]
, indicating the last event in the stream
During the stream of events before the final event this field will not be present.
In the last event in the stream, when current_token
is [DONE]
. this will contain the same information as the Default Response above
Example Python code to accept a stream of server-sent
events
Example Python code to send and receive AUDIO as a stream of server-sent
events
Was this page helpful?