Listen
GET/workstations/:workstation_id/audio/listen
Listen to the audio from the Workstation's virtual speakers. When stream=true, get responses via Server-Sent Events (SSE). When stream=false or not specified, get just the final transcription text.
Example usage with JavaScript for streaming:
const id = 'HvcqZjmeoPtP';
const url = `https://api.agentstation.ai/v1/workstations/${id}/audio/listen?stream=true`;
// Connect directly to SSE stream
const eventSource = new EventSource(url, {
headers: {
'Authorization': 'Bearer <your_token>'
}
});
// Handle partial transcriptions (in-progress)
eventSource.addEventListener('partial', (event) => {
const partialResponse = event.data;
console.log('Partial:', partialResponse);
});
// Handle final transcriptions (completed)
eventSource.addEventListener('final', (event) => {
const finalResponse = event.data;
console.log('Final:', finalResponse);
// Final event indicates completion, so close the connection
eventSource.close();
});
eventSource.onerror = (error) => {
console.error('EventSource failed:', error);
eventSource.close();
};
Example for non-streaming:
const id = 'HvcqZjmeoPtP';
const question = encodeURIComponent("What's the weather like today?");
const url = `https://api.agentstation.ai/v1/workstations/${id}/audio/listen?query=${question}`;
const response = await fetch(url, {
headers: {
'Authorization': 'Bearer <your_token>'
}
});
const result = await response.json();
console.log('Final transcription:', result.transcript);
Example SSE stream events (when stream=true):
event: partial
data: "The weather"
event: partial
data: "The weather today is"
event: final
data: "The weather today is sunny with a high of 75 degrees."
Request
Responses
- 200
- 400
- 401
- 402
- 422
- 429
- 500
- 503
Final transcription text or stream of transcription events
Invalid Request Format - check API documentation for proper syntax.
Unauthorized - missing or invalid API key.
Payment Required - you have run out of trial credits or your payment method has expired. Please add payment details to your account.
Unprocessable Entity - cannot find requested asset associated with your API key.
Too Many Requests - you have exceeded the rate limit for your account. Please wait before making additional requests.
Internal Server Error - please retry your request.
Service Unavailable - our servers have dropped the request due to high load - please retry.