Prompt

Why is my gateway not logging token usage correctly?

Artificial Intelligence / AI Infrastructure2 observationsLast seen Nov 13, 2026

Latest observation

Nov 13, 2026OpenAI APIWeb search: off

A gateway usually “misses” token usage logs for one of a few common reasons:

  1. The model response doesn’t include usage

    • Some providers only return token counts when you request it or when the model/API supports it.
    • Example: you may need something like include_usage=true, stream_options.include_usage, or a non-streamed response.
  2. Streaming responses aren’t being handled correctly

    • With streaming, usage often comes in a final chunk/event, not the first ones.
    • If your gateway stops reading early or only logs the initial response, token usage will look missing or zero.
  3. Your gateway isn’t parsing the right field

    • Different providers use different shapes:
      • usage.total_tokens
      • usage.prompt_tokens / usage.completion_tokens
      • nested metadata fields
    • If the gateway expects one schema but the provider returns another, logging can fail silently.
  4. Retries / fallbacks are confusing the accounting

    • If the gateway retries a request or falls back to another model, the usage may be logged against the wrong request ID or not merged properly.
  5. The response is cached

    • Cached responses may not produce fresh usage data, or your gateway might intentionally skip billing/logging on cache hits.
  6. Async logging is failing

    • The gateway may receive usage, but the log write fails due to:
      • queue backpressure
      • DB errors
      • timeouts
      • dropped telemetry events
  7. Tool/function calls or partial outputs are not accounted for

    • Some providers report token usage differently when tool calls, structured outputs, or multiple turns are involved.
  8. Mismatch between provider and gateway versions

    • Upgrading the model API without updating the gateway’s adapter can break usage parsing.

What to check first

  • Look at the raw API response and confirm usage exists there.
  • Verify your gateway is handling streaming final events.
  • Check whether the gateway is parsing the correct usage field names.
  • Inspect logs for errors in the telemetry/billing pipeline.
  • Confirm whether the request was a cache hit, retry, or fallback.

If you want, paste:

  • the gateway/provider you’re using,
  • whether the request is streamed,
  • and a sample raw response/log snippet,

and I can help pinpoint the exact cause.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.