Skip to main content

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

Final transcription text or stream of transcription events