This guide was prepared with AI assistance using the linked documentation. Code examples are illustrative; verify them against your environment and current API documentation before use.
A voice assistant can sound responsive and still make someone wait. Imagine a caller asking for an available appointment. The assistant immediately says, “I’ll check,” then spends several seconds waiting for the booking service. A dashboard that measures only the first sound will show a fast response, while the caller is still waiting for the answer.
The solution is to measure the whole experience in stages. Capture when the caller finishes speaking, when the first audio begins, when a useful answer is available, and whether the task actually succeeds. Measure the backend work that occurs between those points without pretending that timestamps from different machines share a perfect clock.
This guide is for developers and product teams building browser, telephone, or other conversational voice experiences. It provides an instrumentation plan, small TypeScript examples, a repeatable test protocol, and a way to connect latency with accuracy and cost. The examples are illustrative and have not been run against your live voice service. They do not establish a performance target or guarantee an outcome for your application.
Start with the experience you want to improve
“Latency” can refer to several different waits. A person starting a new call may wait for a connection. During a call, they may wait after finishing a sentence. They may then hear an acknowledgement before the agent has enough information to answer. Each wait needs its own measurement.
Use clear names and definitions:
| Measure | Start | End | What it tells you |
|---|---|---|---|
| Connection setup | User starts a session | The client reports a usable connection | How long a new session takes to become ready. |
| First acknowledgement | A defined end-of-speech reference | First audible acknowledgement | How quickly the agent appears to react. |
| First useful answer | The same end-of-speech reference | First audible information that answers the request | How long the person waits for meaningful information. |
| Tool duration | Your service starts a tool request | Your service receives a result or failure | How long a particular dependency takes from that service’s perspective. |
| Task completion | A defined user request | A verified completed action or answer | Whether the interaction solved the task, and how long it took. |
Choose definitions before collecting numbers. If two teams use “first response” to mean different things, their charts cannot be compared reliably. Write down whether the measurement includes microphone permission, session setup, silence detection, network delay, audio playback, and human confirmation. The answer depends on the user journey, so there is no universal formula that fits every application.
The practical measure for an appointment lookup might be: from the end of the user’s request to the first audible available appointment, provided that the appointment information is correct. That measure is different from the time until the agent says “one moment.” Keep both; they answer different questions.
Draw the path before placing timers
A voice interaction often crosses multiple components. Your architecture may use a speech-to-speech model, a delegated backend, or a chained transcription-and-speech pipeline. The exact stages differ, but a simple diagram helps reveal which component can observe each boundary.
Loading diagram…
For each arrow, ask three questions. First, which process can observe the start and end? Second, does it have a monotonic clock for measuring that interval? Third, does the event represent the thing the user experienced, or merely an earlier internal milestone? A tool result can be ready before it has been spoken. An audio packet can arrive before it reaches a speaker.
Map the actual route taken by a request. Some turns need no tool. Others perform several sequential or parallel lookups. A full-duplex system may continue a conversation while a backend works; a chained system may expose transcription and synthesis as distinct steps. The OpenAI voice-agent guide describes different voice architectures. Do not force every turn into a single stage model that does not match your product.
Start with a modest set of spans you can verify. A detailed tracing diagram with unreliable boundaries is less useful than three honest measurements: connection setup, a backend lookup, and time to a useful answer. Add more detail when it can answer a question about a real bottleneck.
Define the end of speech carefully
An end-of-speech reference sounds obvious until you try to measure it. A speaker may pause before finishing a sentence. A voice activity detector can wait for silence or use other signals before declaring a turn complete. Its event may reach the client after the actual acoustic boundary. That event is useful, but it is not automatically ground truth for the moment the user stopped talking.
For a controlled test with a known recording, annotate the last relevant speech sample or use a verified test harness that can identify that point. For a live session, you may use a documented turn-end event as a practical proxy. Name it accordingly, such as turn_end_event_received_to_first_audio, and explain that it excludes any delay between the person’s actual speech ending and that event reaching the observer.
This distinction prevents a misleading improvement. If you make the detector wait longer before reporting the end of speech, the interval from the event to the first response may look shorter even though the person waited longer overall. Pair proxy measurements with a user-experience measurement from a controlled reference when possible.
Turn detection is also a product decision. OpenAI documents silence-based server_vad and semantic turn detection for supported sessions. More aggressive detection can react sooner but may interrupt a speaker who pauses naturally; a more patient setting may improve turn completion while adding wait. Test the settings with the actual speech patterns and environments your users have, and record both interruption and latency outcomes. See the voice activity detection guide for current configuration and model support.
Separate audio arrival from audible playback
An event saying that audio data has arrived is not proof that the user heard it. The browser or telephony stack may buffer audio, the output device may be muted, autoplay may be blocked, and network jitter can affect playback. Similarly, creating an audio element or setting its source does not by itself identify the instant the first meaningful sound reached the speaker.
When your client exposes a reliable playback milestone, record it and document exactly what it means. If it is an application-level callback or a media-element event, call the metric a playback proxy unless you have validated it against actual output. For a controlled lab test, a loopback recording or an instrumented audio output path may provide a closer approximation to audible playback; account for the measuring device’s own delay.
Do not infer “first useful answer” automatically from the first audio byte. A spoken preamble can precede the answer by a long time. For an evaluation set, human reviewers can mark the first point at which an answer contains the information needed to progress. Keep a written rubric so reviewers agree about cases such as a partially correct appointment or a vague response that still requires another question.
For privacy-sensitive production traffic, you may not be able to inspect recordings or transcripts. Use a consented evaluation environment for detailed labeling, and collect only approved operational timings in production. Explain which metrics are proxies and which were verified through listening.
Use monotonic clocks for local durations
A duration should normally be measured by the same process at both ends of the span. In a browser, performance.now() provides a high-resolution time relative to a local time origin and is monotonic for measuring elapsed time. See MDN’s documentation for its behavior and limitations. Server runtimes offer their own monotonic timing facilities.
The following example measures a function in one process. It records a duration and outcome but does not record request content. emitMetric is a placeholder for your approved telemetry client; implement it so telemetry failures do not prevent the user’s operation from completing.
type Outcome = "ok" | "error";
function emitMetric(name: string, durationMs: number, outcome: Outcome): void {
// Replace with your telemetry client. Never include secrets or transcript text.
try {
console.log({ name, durationMs, outcome });
} catch {
// Metrics must not change the result of the measured operation.
}
}
async function measure<T>(name: string, operation: () => Promise<T>): Promise<T> {
const start = performance.now();
let outcome: Outcome = "error";
try {
const result = await operation();
outcome = "ok";
return result;
} finally {
emitMetric(name, performance.now() - start, outcome);
}
}
// Example: the lookup function belongs to your application.
const slots = await measure("availability_lookup", () => lookupAvailableSlots());If lookupAvailableSlots() throws, the original error still reaches the caller while the duration is recorded as an error. In a real telemetry client, prevent asynchronous exporter failures from becoming unhandled rejections as well. Add an explicit timeout outcome if your system can distinguish timeout from other failures. The example does not include network instrumentation outside the function and does not prove the returned slots are correct.
Use low-cardinality labels such as operation name, environment, model version, or broad outcome category. Avoid user IDs, full URLs with query strings, appointment details, audio, transcripts, and other sensitive or high-cardinality values as metric labels. Your observability system may have additional limits; follow your organization’s privacy and retention rules.
Avoid subtracting unrelated machine clocks
Suppose a browser records a wall-clock timestamp when the user finishes speaking, and a backend server records another when a tool starts. Subtracting them assumes both clocks are synchronized and that you understand the placement of each timestamp. Clock skew, scheduling, clock adjustments, and network transit can produce a misleading result or even a negative duration.
Measure local spans where possible: browser start to browser playback proxy, server request start to server response, and tool client start to tool client result. Use a trace identifier to relate spans from the same interaction, and use a distributed tracing system designed to represent cross-service operations. Treat the trace as a way to understand the path and relationships, not as permission to treat independent clocks as perfectly aligned.
If a cross-machine estimate is necessary, document clock synchronization, measurement uncertainty, and where network time is included. Verify that the tooling handles skew appropriately. Avoid adding local span durations as if they always formed a continuous, non-overlapping chain: parallel tool calls, streaming, buffering, and asynchronous work can overlap.
For example, two independent lookups that start together and take different amounts of time contribute roughly the length of the critical path to a response that waits for both. Adding their durations would overstate the user’s wait. Conversely, reporting only the faster lookup would hide the slower one. Record each operation and the enclosing backend span.
Instrument an end-to-end turn without claiming too much
A practical event record can be small. Give each evaluated turn a pseudonymous correlation identifier and record the version of the application, model configuration, transport, and scenario. Then associate approved spans and outcome labels with that identifier. Keep any mapping back to a person in a separate controlled system, if it is needed at all.
type TurnTimings = {
turnId: string; // random correlation ID; do not encode personal information
endEventReceivedAt?: number;
firstAudioProxyAt?: number;
usefulAnswerProxyAt?: number;
};
function duration(start?: number, end?: number): number | undefined {
if (start === undefined || end === undefined || end < start) return undefined;
return end - start;
}
// Capture all values with performance.now() in the same browser context.
const timings: TurnTimings = { turnId: crypto.randomUUID() };
timings.endEventReceivedAt = performance.now(); // Your verified turn-end callback.
// Later, your validated playback callback supplies firstAudioProxyAt.
const firstAudioMs = duration(timings.endEventReceivedAt, timings.firstAudioProxyAt);The code is a pattern, not a complete voice SDK integration. In particular, it does not show how to identify a particular provider event, detect audible playback, or determine whether spoken content is useful. Those boundaries must be implemented and validated for your transport and evaluation workflow. A timestamp captured in a different page, worker, or process may use a different time origin; keep the measurement in a single context or explicitly convert using a verified method.
Include missing values and failures in reports. If the assistant never produced audio, leaving the record out of the latency chart makes the system look faster. Report the success rate and the number of eligible attempts beside any latency distribution. Distinguish cancellation by the user, connection failures, timeouts, playback failures, and failed business actions.
For long interactions, associate each span with both the session and the relevant turn. A single session can contain a quick greeting and a slow lookup. A session-level average will not show which turn caused the wait. Avoid carrying an identifier from one user’s session into another, and define when correlation data is deleted.
Measure the backend and every tool that matters
Tool latency is frequently where a useful answer waits. Wrap each external operation at the boundary you control: database query, inventory lookup, scheduling service, retrieval system, or other dependency. Record start, end, outcome, timeout, and retry count. If a tool returns a cached value, record that fact using a safe label so cached and uncached results can be analyzed separately.
Measure the enclosing backend operation too. A tool may complete quickly while the backend spends time preparing a prompt, waiting in a queue, validating a response, or performing another sequential call. Conversely, the backend may receive the correct answer promptly while voice generation or playback causes the remaining delay.
Parallelize independent reads only after checking that they are truly independent and authorized. A customer record lookup and a public opening-hours lookup may be parallel; a payment or reservation write that depends on confirmed details should not be speculatively executed. A speculative read can also incur cost or retrieve data that the user never needed. Include that unused work in your cost and privacy assessment.
Do not hide retries. A fast first attempt that fails followed by a slow retry is still a slow and potentially unreliable user experience. Record attempt count and total elapsed time through the final outcome. If a retry risks duplicate writes, use the operation’s documented idempotency mechanism and check the system of record before claiming success.
Build a repeatable benchmark
Begin with a small set of representative tasks. For example, a caller asks for opening hours; another asks for an available appointment; a third asks to change an existing booking and must confirm details before a write. Define the expected answer or state change for each task, along with the tools involved and what counts as a successful outcome.
For each scenario, record the application version, model and voice configuration, prompt revision, audio format, transport, client device, region, network conditions, and test date. Use the same input recording or a controlled speaking protocol when comparing two configurations. If a scenario depends on live inventory or a third-party service, use a stable test environment or record the dependency state; changing data can otherwise dominate the comparison.
Run enough repetitions to see variation. A single demonstration is a smoke test, not a distribution. The number of runs needed depends on the variability and confidence required for the decision. Predefine a reasonable sample and include failures; avoid stopping after an unusually fast result. If the sample is small, say so and avoid presenting a tail percentile as a precise guarantee.
Separate cold and warm conditions. A first connection after an idle period can exercise different paths from a turn inside an already active session. Report them separately if both occur in production. Include a realistic range of network and device conditions rather than testing only a developer laptop on a fast local connection.
Randomize or alternate the order of candidate configurations when feasible. Running every baseline test first and every candidate test later can confound your result with time-of-day load or a changing dependency. Change one factor at a time where practical, then verify the final combination together because interactions between changes can matter.
Report distributions with their denominators
Median latency describes the middle of a set of successful observations. A high percentile, such as p95, helps show slower experiences, but it is sensitive to sample size and collection method. Always report the number of attempts, successful measurements, failures, and the percentile method. Do not quietly calculate percentiles only for calls that produced a clean answer.
The following local helper uses the nearest-rank definition. It expects finite non-negative durations in milliseconds. The example is educational; production monitoring systems may use histograms or a different quantile method, so label the method when comparing results.
function nearestRank(values: number[], percentile: number): number | undefined {
if (percentile <= 0 || percentile > 1) throw new Error("percentile must be in (0, 1]");
const sorted = values.filter((x) => Number.isFinite(x) && x >= 0).sort((a, b) => a - b);
if (sorted.length === 0) return undefined;
return sorted[Math.ceil(percentile * sorted.length) - 1];
}
const exampleMs = [450, 500, 520, 610, 900]; // Illustrative values only.
console.log({ count: exampleMs.length, median: nearestRank(exampleMs, 0.5), p95: nearestRank(exampleMs, 0.95) });The illustrative values are not a benchmark or an expected result for any provider. With only five observations, the nearest-rank p95 is the largest sample and tells you little about a real population tail. The code makes that limitation easy to see; it does not replace a statistically sound experiment.
Segment distributions when the segments are meaningful and sufficiently populated: for example, tool-free answers versus booking lookups, or desktop browser versus telephone. Keep the denominator visible in each segment. If one segment has too few samples, report the count and collect more data rather than declaring it faster.
Pair speed with task success
Latency is not the outcome a caller ultimately wants. A person wants an accurate answer or a completed task. A system that responds faster by guessing an available slot has made the experience worse. Track success, correctness, user interruption, fallback, and recovery alongside timing.
For an appointment task, define success in the booking system of record. A spoken “You’re booked” is not proof that a reservation exists. Verify that the right user, service, date, and time zone were recorded, and check whether confirmation was delivered through the intended channel. For a read-only question, compare the spoken answer with the source of truth available at the time of the test.
Some quality checks require human review. Use a written rubric and examples of acceptable and unacceptable answers. If a reviewer marks the first useful answer, they should also indicate whether it was correct and complete enough for the task. An answer that arrives early but needs correction should not be treated as an unqualified success.
Measure interruption behavior as well. If tuning turn detection reduces the measured wait but increases the number of users cut off mid-sentence, the change may not be an improvement. Similarly, a shorter answer can be clearer, but it may omit a necessary confirmation. Consider the interaction as a whole before selecting a configuration based on one chart.
Diagnose common bottlenecks
Connection setup dominates. Inspect the path from the user’s start action through credential issuance, signaling, network setup, and client readiness. Separate microphone permission time from technical connection time so a user’s decision is not misclassified as server delay. Check cold and warm sessions independently. Do not expose long-lived credentials in a browser merely to save a request.
Turn detection dominates. Compare the true or annotated speech boundary with the detector event. Test natural pauses and background noise. Adjust supported settings conservatively, measure premature interruptions, and consider whether push-to-talk suits the audience. A smaller delay is not useful if it causes the agent to answer before the person finishes.
A tool dominates. Inspect the tool’s own dependency spans, timeouts, and retry behavior. Reduce unnecessary calls, use safe caching where the data’s freshness and permissions allow it, and parallelize independent reads. Verify authorization and correctness after any caching change. A stale available slot can be worse than a slower live lookup.
The backend result is ready but the user still waits. Investigate response generation, streaming, client buffering, output device behavior, and playback policy. Compare server-ready time with an honest client playback proxy. If the browser refuses autoplay, show an action to enable playback; counting data arrival as success hides that failure.
The acknowledgement is fast but the useful answer is slow. Look at the backend and tool critical path. An acknowledgement may improve the perceived experience for a long task, but it should not be used to claim that the task is complete. Provide a realistic status, a way to cancel when cancellation is supported, and an appropriate fallback when the dependency fails.
Only the slowest cases are affected. Inspect concurrency, queuing, rate limits, retries, network quality, and downstream tail latency. Compare the relevant p95 or other chosen tail measure with sample size and error rate. An average can remain stable while a subset of users has a poor experience.
Reduce delay without creating new risks
Optimization should follow the measured bottleneck. A smaller model or shorter context may reduce some response times, but it can change accuracy, instruction following, or tool selection. Run the same task evaluation before and after the change. Keep a rollback path and monitor failures after rollout.
Streaming can reduce time to the first visible or audible output, depending on the architecture. It does not necessarily reduce the time to a correct final answer. If the earliest output is only a generic acknowledgement, measure it separately. Test interruptions during streaming and ensure a partially spoken response does not imply an unconfirmed action succeeded.
Caching can help repeated read-only requests when data is stable and access rules permit reuse. Define the cache key, lifetime, invalidation, and tenant boundary. Do not share private customer information across users. For volatile inventory or appointments, verify the actual availability at the moment of the write even if an earlier lookup was cached.
Use timeouts and fallbacks that reflect the task. If a lookup times out, the assistant can explain that it could not confirm availability and offer another route. It should not invent a slot. If a write times out, determine whether the action may have completed before retrying. A status check or idempotency key can be necessary to avoid duplicate bookings.
Avoid optimizing by removing security checks, skipping user confirmation, or concealing uncertainty. Those steps may shorten a timer while increasing the chance of a wrong or unauthorized outcome. Measure their cost and improve their implementation if needed, but preserve the boundary.
Include the cost of waiting and unused work
Voice cost depends on the provider, model, session type, duration, and other usage. Backend models and tools may have separate charges. OpenAI’s voice cost guide discusses the cost of active voice sessions and backend work for supported architectures. Consult current pricing and usage reports for your account rather than copying an example price into a budget.
For a delegated backend, a longer wait may keep a voice session open while other work runs. In some product designs, closing an idle voice session and letting a long task continue separately may be appropriate; that requires a clear resume experience and saved context. Muting a microphone is not necessarily the same as closing the session. Verify the lifecycle and billing behavior of the actual integration.
Record the cost of speculative or parallel work as well as work used in the final answer. A faster response may require more backend operations. Whether that trade-off is worthwhile depends on task success, user experience, and spending limits. Compare cost per successful task alongside latency and failure rate when the available usage data supports it.
Do not calculate cost by multiplying an invented average by a guessed price. Use measured usage, the current pricing for each component, and the same test workload for both configurations. Include retries, failed sessions, and idle time when they are billable. If billing data is delayed or aggregated, state the limit of the estimate.
A practical experiment plan
Suppose your baseline appointment lookup feels slow. First, define the scenario: a caller asks for the next available appointment, and the answer must include a valid date and time zone. Record the speech boundary method, client playback proxy, tool duration, and verified outcome. Run a representative set of attempts and record configuration and failures.
Next, inspect the spans. If the tool is slow, compare a candidate that removes an unnecessary sequential read while preserving authorization and freshness. Keep the same recordings and test data. Alternate baseline and candidate runs, then compare time to useful answer, tool duration, success rate, interruptions, and cost. If the candidate is faster but returns stale or unauthorized data, reject it.
If the result is promising, test under realistic concurrency and less favorable networks. A change that helps one user at a time may overload a dependency at higher traffic. Verify timeout behavior and recovery paths. Roll out gradually if your deployment process supports it, watch the agreed metrics, and be prepared to revert if quality or failure rate worsens.
Document what was actually measured. A useful experiment record includes the hypothesis, scenario, sample size, configuration, metric definitions, results, known limitations, and next decision. Do not write “voice latency improved by 30%” unless the measurement, denominator, and comparison justify that statement.
Privacy and telemetry checklist
Instrumentation creates data of its own. Apply the same care to measurements that you apply to the voice product:
- Record operational durations and broad outcomes by default; avoid raw audio and transcripts in routine metrics.
- Use random, scoped correlation identifiers and restrict access to any mapping back to individuals.
- Keep API keys, temporary secrets, authorization headers, and full sensitive URLs out of logs.
- Define retention and deletion for traces, recordings, and evaluation artifacts.
- Obtain the permissions needed for any recorded test audio and explain how it will be used.
- Protect telemetry endpoints from unauthorized access and avoid unbounded metric labels.
- Make measurement failures non-blocking so the product can still respond to the user.
- Review the provider’s data controls and your own obligations for the deployment.
If a production incident requires more detailed diagnostics, use an approved, time-limited process with appropriate access and retention. Do not permanently collect every conversation just because it might someday be useful for debugging.
Frequently asked questions
What is the most useful voice latency metric?
It depends on the task. For a conversational lookup, the time from a defined end-of-speech reference to the first correct, useful answer is often more informative than the first acknowledgement alone. Also track connection setup, errors, and task completion, and explain how each boundary was observed.
Can I use a turn-end event as the exact moment the user stopped speaking?
Treat it as a proxy unless you have validated it against the acoustic boundary. Detection and event delivery take time, and the user may have paused rather than finished. For controlled tests, use an annotated recording or another known reference.
Why not subtract the browser timestamp from the server timestamp?
They come from different clocks and may have different time origins or skew. Measure durations locally and relate them using a trace designed for distributed systems. If you need a cross-machine estimate, document synchronization and uncertainty.
Is a fast acknowledgement enough?
It can reassure the user, but it does not answer the request. Record the acknowledgement and the first useful answer separately. Verify that any spoken claim about a business action matches the system of record.
How many runs do I need for p95?
There is no single number that fits every decision. Tail estimates become unstable with small samples and variable workloads. Report the number of observations, failures, and percentile method, and gather enough representative data for the confidence your decision requires.
Should I optimize for the lowest latency setting?
Choose a setting that balances speed with turn-taking quality and task success. A detector that responds too aggressively may interrupt users; a faster backend may provide a less accurate answer. Compare the complete experience using the same scenarios.
Sources and further reading
- OpenAI: Voice agents — voice architectures and evaluation considerations.
- OpenAI: Voice activity detection — turn detection options for supported sessions.
- OpenAI: Voice cost optimization — session duration and backend cost considerations.
- OpenAI: Data controls — provider data-handling information.
- MDN:
performance.now()— local monotonic timing. - OpenTelemetry: Traces — spans and distributed tracing concepts.
Documentation reviewed November 13, 2026. The examples are illustrative; validate event boundaries, timing, privacy controls, and costs in your own environment before using the resulting metrics for decisions.
