RelayVano

← All postcards

The 4 PM Usage Check on Our API Integration Team

Protocols and gates EN

What the usage object tells you at 4 PM

When an AI request finishes, the response usually contains more than the generated text. It may also include a usage object: a small collection of numbers describing how much processing the request consumed.

For a developer watching an integration during a busy afternoon, those numbers answer practical questions. How much input did the model receive? How much output did it generate? Did a long conversation cause the request to become expensive? Are retries increasing consumption? The usage object gives you evidence instead of forcing you to estimate from message length.

Where usage appears in an API response

In an OpenAI-compatible response, usage is commonly a top-level field alongside the response identifier, model name, and choices. A simplified response may look like this:

{ "id": "resp_123", "model": "GPT-6.1 Sol", "choices": [ ... ], "usage": { "prompt_tokens": 842, "completion_tokens": 196, "total_tokens": 1038 } }

The exact field names depend on the provider and endpoint. Some APIs call the input value prompt_tokens and the output value completion_tokens. Others use input_tokens and output_tokens. Some responses include additional details, such as cached input tokens, reasoning tokens, or the number of tokens used by a tool call.

How to read input, output, and total tokens

  • Input tokens represent the material sent to the model. This can include system instructions, conversation history, user text, tool results, and other request fields.
  • Output tokens represent the text or structured result generated by the model. A detailed answer usually consumes more output tokens than a short classification.
  • Total tokens are commonly the sum of input and output tokens, although an API may calculate or report additional categories separately.

A token is not exactly the same as a word. Common words may take one token, while unusual words, code, punctuation, and non-English text may take several. For that reason, character counts are a poor substitute for the usage object.

Why the input number grows across a conversation

A frequent surprise appears when a chat works correctly but becomes steadily more expensive. The reason is that many applications send the previous conversation again with every new request. The latest question may be short, but the request can still contain many earlier messages and tool results.

Compare the input token count for the first message with the count after ten turns. If it rises each time, the application is accumulating context. You may need to summarize older messages, remove irrelevant tool output, or start a fresh conversation at a sensible boundary.

Using usage data to debug production requests

Log the usage object with the request identifier, selected model, application feature, and timestamp. Avoid logging private prompts or user content unless your data policy explicitly allows it. The numbers alone are often enough to identify a problem.

  • A sudden input spike can indicate duplicated history, an oversized document, or an accidentally repeated system prompt.
  • A sudden output spike can indicate a missing length limit, a prompt that asks for unnecessary detail, or a loop in tool-driven work.
  • A high retry count can multiply otherwise normal usage, especially when the first response was received but your client failed to record it.
  • A missing usage object can indicate streaming behavior, an endpoint-specific response format, or an error path that your parser does not handle.

Accounting for streaming and provider differences

Streaming responses arrive in several chunks, so usage may appear only in the final chunk or in a separate completion event. Do not calculate cost from the first chunk. Collect the complete stream and inspect the documented final usage data.

Also treat usage fields as optional. A robust parser should handle missing values, unknown fields, and provider-specific names without crashing. Store the raw response version or provider name when possible, then normalize known fields into your own internal format.

Turning token counts into a useful budget

Token counts become operationally useful when you aggregate them by user, feature, model, day, and request. Set alerts for unusual totals rather than relying only on a monthly invoice. A feature that looks cheap per request may become costly when called thousands of times.

RelayVano is a practical option for pay-as-you-go access across compatible AI model APIs, including Claude Haiku 4.5 and Gemini 3.1 Pro, while keeping usage visible at the response level. Developers can sign up for RelayVano and use the API base at https://api.relayvano.com with compatible tools and SDKs.

The small checklist for your next integration

  • Print one complete successful response in a development environment.
  • Find the usage field and record its actual field names.
  • Test a short request, a long conversation, and a streamed response.
  • Store normalized input and output counts with request metadata.
  • Use changes in those counts to investigate cost, latency, and context problems.

Once you treat the usage object as operational data rather than decoration, it becomes one of the fastest ways to understand what your AI integration is really doing.

More postcards from this route