How to Verify Which AI Model Served Your Request

Résumé

Pixel’s announcement explains how OpenRouter’s opt-in X-OpenRouter-Metadata header can reveal routing strategy, considered endpoints, and provider/model details for each attempt. It matters because a requested model label may differ from the model that actually served a response, and routing details are hidden by default.

DEV Community

The router can tell you which model served you. It won't unless you ask.

Last week a reader pushed back on something I wrote about proving which model answered a request. His objection was the good kind: the response's model field is the router's claim, and treating it as a fact is the error. He then ran a behavioural check over his own logs: 45 routed calls to one model, 20 direct calls to it, 29 calls to another, and the names and the behaviour agreed on every one of the 94. He also said he couldn't answer the harder question, because he only logged the model field and the router headers, and the routing header was empty or missing on every single call. So I went and read one router's documentation instead of arguing. OpenRouter, because it is the one with its docs fully public and because it is the router in the thread. What I found is less dramatic than "you can never know" and more useful than "trust the label". The router will hand you a receipt. It just will not hand you one you forgot to ask for. The receipt is an opt-in header Send X-OpenRouter-Metadata: enabled with the request and the response comes back with an openrouter_metadata object. Their docs describe it as capturing "exactly what the router did": the strategy used (direct, auto, alias, fallback, and so on), the endpoints considered, and an attempts array with the provider, model and status of each attempt, when the router retried against fallbacks. The field that matters is requested. Their own description of it: The model slug (or alias) the client sent. May differ from the provider/model that actually served the request. That is the router stating the failure mode in its own words. The thing you asked for and the thing that served you are two different rows, and by default both are invisible: "By default, none of that is visible on the response." The one field the router did not write Metadata is the router describing itself. Useful, but it is still the party whose claim is in question talking about its own work. One field is different. GET /api/v1/generation?id= returns the generation record, including provider_name, upstream_id, and upstream_inference_cost. The docs call upstream_id "Upstream provider's identifier for this generation", and the example value is a provider-shaped id, not a router-shaped one. That is the only field in this chain that originates somewhere other than the router. If a dispute ever needs a handle, this is the one a third party could look up on their own side. Which is exactly why it is worth capturing: it converts "your logs say X" into "your provider's record, id such and such, says X". The money check has the same shape The response also carries usage accounting: cost, and a breakdown with upstream_inference_cost, described as "the actual cost charged by the upstream AI provider". But when you fetch the record by generation id, the same docs say: "the upstream_inference_cost field is only available for BYOK requests. For all other requests it will be 0 or null." And then their reference example for that endpoint shows a generation with is_byok: false and upstream_inference_cost: 0.0012 sitting right there. Two pages, one contradiction. I cannot settle it from the documents, and I am not going to pretend otherwise. This is the part people skip: reading the docs does not produce a verdict, it produces a list of things that do not agree, and the honest output of an audit is that list. One more billing wrinkle for anyone reconciling an invoice: OpenRouter charges a 5.5% fee ($0.80 minimum) when you buy credits, and no per-request markup on inference. So your card statement and the sum of cost across your generations will never match exactly, and the difference is not attributable to any single request. Where the evidence disappears Three limits, all from their docs, all relevant if you are doing this after the fact rather than before: Cache hits never include the metadata. "Both streaming and non-streaming cache replays strip the field so clients cannot pin behavior on stale routin...
How to Verify Which AI Model Served Your Request
Powered by Readybot.io

Les dernières actus de Pixel

Incident Response: Look Beyond the Red Alert

Pixel’s DEV Community announcement explores how teams can fixate on one failing service while overlooking the real cause of an outage, such as a full …

Sach: AI Fact-Checks WhatsApp Forwards in India

Pixel’s announcement introduces Sach, a tool that checks forwarded messages in English, Hindi, Telugu, and 14 other Indian languages against official sources. It gives cited …

Java 25 Removes SecurityManager: What to Fix

Pixel’s announcement explains how Java 24’s JEP 486 permanently disabled the SecurityManager, breaking test workarounds that intercept System.exit. It recommends returning exit codes or throwing …