All insights

Inference economics

How should a gateway meter queued time, provider compute time, and token usage separately?

A gateway should meter queued time, provider or model compute time, and token usage as separate telemetry dimensions, then connect them with a request-level correlation ID. Queue time explains capacity and scheduling pressure, provider compute time explains model/provider/runtime behavior, and token usage explains workload shape and billing exposure. Collapsing them into one blended latency or cost metric makes it harder to tell whether a slow or expensive call was caused by admission delay, model execution, retries, cache behavior, routing, batching, or token volume.

A gateway should meter queued time, provider or model compute time, and token usage as separate telemetry dimensions, then connect them with a request-level correlation ID. Queue time explains capacity and scheduling pressure, provider compute time explains model/provider/runtime behavior, and token usage explains workload shape and billing exposure. Collapsing them into one blended latency or cost metric makes it harder to tell whether a slow or expensive call was caused by admission delay, model execution, retries, cache behavior, routing, batching, or token volume.

Direct answer: keep queue time, compute time, and tokens as separate correlated signals

In production LLM systems, the gateway should avoid treating “request duration” as a single sufficient measurement. A complete call may include gateway receipt, authentication, policy checks, routing, queuing, batching, provider request setup, model execution, streaming delivery, retries, response serialization, and final client delivery. Those steps do not have the same operational meaning.

A practical design separates three core signals:

  • Queued time: time spent before active provider or model execution. This can include admission control, rate-limit waits, batching windows, GPU availability, routing decisions, provider quota waits, or upstream backpressure.
  • Provider compute time: the interval attributable to the provider/model execution path after the request has been accepted for processing. The exact boundary depends on provider APIs, deployment topology, streaming behavior, and what the gateway can observe.
  • Token usage: input/prompt tokens, output/completion tokens, total tokens, and, where available from the model or provider, categories such as cached tokens or reasoning-related tokens. Token usage is not a latency metric; it is a demand and cost-exposure signal.

The gateway should then tie these signals together at the request level. A correlation ID lets teams inspect one call end to end without mixing unrelated aggregates. For example, an operations team can compare high queue time with normal provider duration, while a finance team can compare high output-token volume with normal latency. Both situations matter, but they require different decisions.

This separation is especially important for enterprise teams operating multiple workloads. Token Forge Cloud treats latency-sensitive chat, batch enrichment, and agentic workflows as different serving-policy problems. Those workloads often have different tolerance for delay, different token shapes, and different economics. Clean metering helps leaders decide whether they are looking at a capacity problem, a routing problem, a model/runtime problem, or a workload design problem.

Set timing boundaries from gateway receipt through response completion

The best metering design starts with explicit timing boundaries. Teams should decide which timestamps the gateway records, which durations are derived from those timestamps, and which intervals are observable versus inferred. Precision will vary by architecture, but the goal is to prevent every delay from being labeled as “model latency.”

A practical gateway timeline can include:

  1. Gateway receive time: when the gateway receives the client request.
  2. Enqueue time: when the request enters an internal queue, admission controller, batching buffer, or scheduler.
  3. Dequeue or admission time: when the request is admitted for provider/model execution or selected for a batch.
  4. Provider request start: when the gateway sends the call to the provider, runtime, or model-serving layer.
  5. First token time: for streaming or token-by-token delivery, when the first generated token or first response chunk is observed.
  6. Provider end or final token time: when the provider/model execution path is complete, as observed by the gateway.
  7. Gateway response completion: when the gateway finishes delivering the response to the client.

From these timestamps, teams can derive more meaningful durations:

MeasurementTypical boundaryWhat it helps explain
Queue durationEnqueue to dequeue/admissionAdmission pressure, rate limits, batching wait, GPU scheduling, backpressure
Gateway overheadGateway receipt to provider start, excluding queue where possibleAuth, policy checks, routing logic, serialization, middleware, retries, transit overhead
Provider compute durationProvider request start to provider end, or provider-observed execution interval where exposedProvider/model/runtime behavior, model selection impact, execution path issues
End-to-end durationGateway receipt to response completionUser-perceived completion time, including all gateway and delivery effects

The key architectural point is that queue duration and provider compute duration should not be derived from the same broad “request completed in X seconds” number. If a request spends most of its time waiting for admission, adding faster model hardware may not address the problem. If queue time is low but provider compute time is high, the team may need to evaluate model choice, runtime configuration, prompt length, output length, or provider behavior.

Gateway overhead also deserves a separate view where practical. Authentication, policy evaluation, input validation, serialization, retry logic, network transit, and response transformation can add time that is neither queue pressure nor model execution. If those steps are merged into provider compute time, model and infrastructure teams may chase the wrong issue.

Treat token usage as workload and cost exposure, not as a latency substitute

Token usage should be recorded separately from timing metrics because it answers a different question. Time measurements describe how long the request took and where it waited. Token measurements describe how much text or model work the request consumed from a workload and billing perspective.

A gateway should generally record token usage in categories such as:

  • Prompt or input tokens: tokens submitted to the model, including system instructions, user input, retrieved context, tool descriptions, and conversation history where applicable.
  • Completion or output tokens: tokens generated by the model.
  • Total tokens: the combined token volume used for aggregate reporting.
  • Provider-specific token categories where available: some providers expose additional categories, such as cached-input tokens or reasoning-related tokens. These should be captured only when the provider or runtime exposes them clearly.

Token usage helps product and finance teams understand workload shape. A customer-support assistant may have short prompts and moderate completions. A retrieval-augmented workflow may have large prompts because it inserts long context windows. A code-generation or agentic workflow may have repeated tool calls, retries, and long outputs. Those differences affect cost exposure even when latency appears acceptable.

However, token usage should not be treated as a universal substitute for compute time or cost. Two requests with the same token count can behave differently depending on model architecture, provider pricing, cache state, batching behavior, quantization, runtime efficiency, and hardware availability. A long prompt may be cheap in one route and expensive in another. A shorter request may still be slow if it waits behind capacity constraints or triggers retries.

Token Forge Cloud Private LLM Inference is a serving-layer control plane for private LLM deployments that applies workload-aware caching, routing, batching, quantization, and GPU scheduling. In that kind of serving environment, token usage is one input into cost control, but it should be interpreted alongside queue pressure, execution timing, route selection, and cache behavior.

Token Forge Cloud Managed Model APIs provide a lightweight API-first path for model access, usage data, and evaluation before private deployment. For teams still validating demand, separating token counts from timing metrics helps build a more accurate picture of which workloads are predictable enough to optimize through private serving capacity.

Measure streaming calls with first-token, inter-token, and final-completion timing

Streaming responses need more detailed timing than non-streaming responses because the user experience is not defined only by final completion time. A streaming chat response may feel responsive if the first token arrives quickly, even if the total completion takes longer. Conversely, a response may begin quickly but stall during generation, pointing to a different bottleneck.

For streaming calls, a gateway telemetry design should distinguish:

  • Time to first token: the interval from gateway receipt or provider request start to the first streamed token or first response chunk. This can reveal admission delays, provider startup latency, prompt processing time, and gateway buffering behavior.
  • Inter-token timing: the cadence between streamed chunks or tokens, measured as distributions rather than only averages. This can reveal runtime throughput issues, provider-side throttling, network effects, or client delivery problems.
  • Total completion time: the interval from request start to final streamed token or gateway response completion. This is still needed for overall service-level analysis and user-experience measurement.

The exact boundaries vary. Some providers expose usage only at the end of a stream. Some gateways buffer chunks before forwarding them. Some SDKs report events at the application layer rather than the network layer. A good design records what it can observe directly and avoids presenting inferred timings as more precise than they are.

Streaming also changes how teams interpret token metrics. Output tokens arrive over time, so total output token count may not be known until the stream ends. If a user cancels early, the gateway should avoid treating the intended maximum output size as actual usage. If a provider returns partial usage metadata, the gateway should mark the accounting state clearly rather than mixing complete and incomplete records without distinction.

Token Forge Cloud offers a lightweight API-first path for teams that want managed model access before committing to private serving capacity. For teams comparing API-first usage with later private deployment, streaming telemetry design should be considered early, because first-token responsiveness, total completion time, and token volume can influence model choice, workload design, and capacity planning.

Account for caching, routing, batching, and GPU scheduling without mixing metrics

Serving-layer controls can change both latency and economics, which is why gateway metrics must stay separate. Token Forge Cloud helps enterprises reduce LLM inference costs and improve control by optimizing the serving layer with caching, routing, batching, quantization, and GPU scheduling. Those controls are useful precisely because they affect how requests move through the system—but they can also make blended metrics misleading.

Caching is a common example. If the gateway serves a cache hit, there may be no active provider/model execution for that response. That cache hit should not be counted as provider compute time for actual model execution. Teams may still want token-equivalent accounting to understand served demand, or avoided-provider-call accounting to estimate how much external execution was bypassed. Those are useful views, but they should be labeled separately from provider compute duration.

Routing can also change interpretation. A request may be routed to a different model, provider, region, runtime, or deployment path based on policy, cost, latency target, tenant, or workload type. If routing time grows, the problem may be gateway policy complexity or upstream availability rather than model execution. If one route has higher provider compute time but lower queue time, teams need both signals to decide whether the route is acceptable for that workload.

Batching intentionally introduces waiting in exchange for more efficient execution in some serving patterns. That waiting belongs in queue or admission time, not provider compute time. Batch status is therefore an important dimension: a request that waited for a batch window should be distinguishable from a request that was admitted immediately.

GPU scheduling creates another important boundary. In private inference deployments, a request may wait for GPU availability, model residency, admission policy, or scheduler priority before execution begins. That waiting is operationally different from the model’s active compute interval. If all scheduler delay is folded into model compute time, teams may incorrectly tune prompts or switch models when the real issue is capacity allocation.

Token Forge Cloud Private LLM Inference supports this broader serving-layer approach for private LLM deployments. Because caching, routing, batching, quantization, and GPU scheduling can alter queue behavior, execution paths, and token economics, gateway telemetry should preserve the distinctions rather than flatten them.

Choose dimensions that explain operations without unsafe cardinality

Metrics become useful when they can be filtered by dimensions that explain operational behavior. They become risky or expensive when labels contain sensitive data, high-cardinality values, or unbounded identifiers. A gateway should strike a balance: enough context to diagnose the system, not so much raw detail that metrics become unsafe or unusable.

Useful dimensions often include:

  • Model: the model or model family used, at a stable level of detail.
  • Provider or runtime: the external provider, private runtime, or serving path where available.
  • Route or policy: the routing decision category, not the full internal rule text.
  • Tenant, workspace, or business unit: where governance allows and values are bounded.
  • Endpoint or workload type: chat, batch enrichment, agentic workflow, summarization, retrieval-augmented generation, or similar categories.
  • Status or error class: success, timeout, rate limited, provider error, client cancellation, validation failure, or retry-exhausted categories.
  • Cache state: hit, miss, bypassed, stale, or not applicable where the implementation supports those states.
  • Batch status: batched, not batched, batch wait, or batch execution category.
  • Deployment or runtime class: managed API path, private deployment path, region group, or runtime tier where available.

The dimensions should support decision-making. Operations leaders need to identify capacity pressure. Product leaders need to see which experiences are latency-sensitive. Finance leaders need to understand token-driven exposure by workload, route, and model. Technical leaders need to evaluate whether routing, caching, batching, or scheduler behavior is working as intended.

At the same time, metric labels should avoid raw prompts, full responses, secrets, access tokens, personal identifiers, and unbounded user-level identifiers. Even when logs or traces have controlled access, metrics are often replicated, aggregated, exported, retained, or queried broadly. High-cardinality labels can also make observability systems expensive and hard to operate.

A safer pattern is to store bounded categories in metrics and keep sensitive diagnostic detail out of labels. If deeper inspection is required, use controlled traces or logs with appropriate retention and access policies, and link them through a request-level correlation ID rather than copying sensitive content into every metric.

Token Forge Cloud supports managed model API access and private LLM inference paths. As teams move from API-first experimentation into private deployment, dimension design becomes more important: the same gateway may need to compare managed routes, private routes, cache behavior, and workload categories without exposing unnecessary user or prompt detail.

Implementation checklist and illustrative gateway telemetry schema

Use this checklist when designing or reviewing gateway telemetry for separated queue time, provider compute time, and token usage:

  • Define the gateway’s observable lifecycle: receive, enqueue, admission, provider start, first token, provider end, and response completion.
  • Record a request-level correlation ID so timing components, token counts, status, cache state, and route metadata can be joined for the same call.
  • Separate queue duration from provider/model execution duration; do not label admission waits or batch waits as compute time.
  • Separate gateway overhead where possible, including authentication, policy checks, serialization, retries, middleware, and network transit.
  • Record prompt/input tokens, completion/output tokens, total tokens, and provider-specific token categories only where available.
  • Treat streaming separately: time to first token, inter-token cadence, final-token time, and total completion time answer different questions.
  • Mark cache hits distinctly from actual provider execution; decide whether to report token-equivalent served demand, avoided-provider-call accounting, or both.
  • Include operational dimensions such as model, provider, route, endpoint, tenant/workspace, status/error class, cache state, batch status, and deployment/runtime where available.
  • Avoid raw prompts, full responses, secrets, personal identifiers, and unbounded user IDs in metric labels.
  • Review metric cardinality before production rollout, especially for tenant, route, tool, agent, and workflow dimensions.
  • Use OpenTelemetry-style GenAI observability concepts—metrics, attributes, spans, and events—as a useful reference category, while adapting field names and boundaries to the actual gateway architecture.

An illustrative gateway telemetry record might look like this. It is not a required standard or a Token Forge Cloud API contract; it shows the type of structure teams often need when separating timing and token signals.

``yaml request_id: req_abc123 workload_type: chat route: private_inference_route_a model: model_family_or_alias provider_or_runtime: private_runtime endpoint: /v1/chat/completions status_class: success cache_state: miss batch_state: batched timestamps: gateway_received_at: 2026-08-25T10:00:00.000Z enqueued_at: 2026-08-25T10:00:00.020Z admitted_at: 2026-08-25T10:00:00.180Z provider_started_at: 2026-08-25T10:00:00.210Z first_token_at: 2026-08-25T10:00:00.620Z provider_completed_at: 2026-08-25T10:00:02.400Z gateway_completed_at: 2026-08-25T10:00:02.460Z durations_ms: queue_time: 160 gateway_overhead_before_provider: 50 time_to_first_token_from_provider_start: 410 provider_compute_observed: 2190 end_to_end: 2460 tokens: input_tokens: 1800 output_tokens: 420 total_tokens: 2220 cached_tokens: available_if_reported_by_provider notes: sensitive_prompt_content_in_metrics: false ``

This type of structure gives each stakeholder a clearer operating view. Engineering can inspect first-token and provider-compute distributions. Operations can identify queue growth and scheduler pressure. Product teams can compare workload types. Finance can analyze token exposure by model, route, and tenant category without assuming token count alone explains cost.

Token Forge Cloud supports private deployment paths where models, prompts, and telemetry remain in the customer's controlled environment. For enterprises evaluating private LLM inference, this makes telemetry design part of the serving architecture—not an afterthought. Clean separation between queued time, provider compute time, and token usage helps teams reason about caching, routing, batching, quantization, GPU scheduling, and workload-specific inference economics.

Contact Token Forge Cloud to discuss API access, private deployment, and LLM inference cost control.

Contact us