{"slug": "the-logs-say-200-which-model-actually-answered", "title": "The logs say 200: which model actually answered?", "summary": "Keystone (KTMS) documents that the model name in a client's code is only a request, not a record of which model answered, because fallback chains, auto-routing, caching and vendor aliasing can all change the serving model while the call still returns HTTP 200. KTMS fills the OpenAI-compatible response's `model` field with the resolved registry model and exposes `X-KTMS-Vendor`, `X-KTMS-Rule`, `X-KTMS-Route-Mode`, `X-KTMS-Placement`, `X-KTMS-Cache` and `X-KTMS-Model` headers, mirrored as fields in gRPC `GenerateTextResponse`, with the legacy `X-LLM-Proxy-*` names kept until a sunset date of 2027-03-01. The gateway cannot see changes made behind the vendor's API, such as Google's announced move of Gemini API requests for `gemini-2.5-pro` to `gemini-3.8-flash` starting December 1.", "body_md": "# The logs say 200: which model actually answered?\n\nThe model name in your code is a request, not a fact. How Keystone reports the model, vendor and rule that served each call, where that shows up (response, headers, usage events, metrics), and the one thing it cannot see.\n\n**A user says the answers got worse last week. Your logs say every call returned 200, and your\ncode says `model=\"gemini-2.5-pro\"`.** So everyone assumes that model answered. It may not have.\n\nThe name in your code is what you asked for. Between that request and the answer there can be a fallback chain, a router, a cache and the vendor’s own aliasing. Each of them can change who answers without changing the status code.\n\nThis post shows what Keystone. The Model Switchboard. (KTMS) records about the model that actually served a call, where you can read it, and where its knowledge stops.\n\n## Four ways the answer comes from somewhere else\n\n1. **Fallback.** A rule in Keystone is an ordered chain of models. If the first one is rate\nlimited, paused after a`Retry-After` , behind an open circuit breaker or times out, the next one\nanswers. The client still gets 200.\n2. **Routing.** With`model: \"auto\"` , a judge picks the effort, and the effort picks the rule\n([how that works](https://blog.ai-process.dev/2026/10/28/how-model-auto-decides/) ). Two identical-looking requests can land\non different models by design.\n3. **Cache.** With the cache on, an answer may be one that was stored earlier, from whichever model\nproduced it then.\n4. **The vendor.** An alias such as`-latest` is moved to new releases by the vendor. Google has\nalso announced that from December 1, Gemini API requests for`gemini-2.5-pro` go to`gemini-3.8-flash` . Same code, same name, different model.\n\nThe first three happen inside the gateway, so the gateway can tell you about them. The fourth happens behind the vendor’s API, and that matters later in this post.\n\n## What the response tells you\n\nOn the OpenAI-compatible endpoint, the `model` field of a chat completion is not an echo of your\nrequest. KTMS fills it with the registry model that served the call\n([`internal/server/openai.go`](https://github.com/ai-process/ktms/blob/main/internal/server/openai.go)):\n\n```\nwriteJSON(w, http.StatusOK, map[string]any{\n\t\"id\": id, \"object\": \"chat.completion\", \"created\": created,\n\t\"model\": resp.ResolvedModel, \"choices\": choices, \"usage\": usage,\n})\n```\n\nStreams carry it in every chunk the same way. The response headers say how the call got there:\n\n| Header | What it holds | \n|---|---|\n| `X-KTMS-Vendor` | The vendor that served the call | \n| `X-KTMS-Rule` | The routing rule that matched (empty with an exact model override) | \n| `X-KTMS-Route-Mode` | `direct` ,`override` ,`auto-judge` ,`auto-default` or`auto-effort` | \n| `X-KTMS-Placement` | `nodes_first` ,`nodes_only` ,`cloud_first` or`cloud_only` | \n| `X-KTMS-Judge-Model` ,`X-KTMS-Judge-Score` | Which judge rated the prompt, and its score (experimental) | \n| `X-KTMS-Cache` | `HIT` or`MISS` when the cache is on | \n| `X-KTMS-Model` | The served model, on speech, image, embedding and decision endpoints | \n\nOver gRPC the same facts are fields of `GenerateTextResponse`: `resolved_model`,\n`resolved_vendor`, `matched_rule`, `route_mode`, `placement`, `cached`\n([`gateway.proto`](https://github.com/ai-process/ktms/blob/main/proto/ktms/v1/gateway.proto)).\nEvery header is also sent under its old `X-LLM-Proxy-*` name until its announced Sunset date,\n2027-03-01.\n\nTake the example configuration from the repository: a rule `high` with the chain\n`[gpt-4o, gpt-4o-mini]`. Ask for high effort while `gpt-4o` is rate limited:\n\n```\ncurl -si localhost:8080/v1/chat/completions \\\n  -H \"Authorization: Bearer ktms_<your key>\" -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"auto:high\",\"messages\":[{\"role\":\"user\",\"content\":\"Say hi\"}]}' \\\n  | grep -iE '^x-ktms-|\"model\"'\n```\n\nThe status is 200. The headers say `X-KTMS-Rule: high`, `X-KTMS-Vendor: openai` and\n`X-KTMS-Route-Mode: auto-effort`, and the body’s `model` is `gpt-4o-mini`, the second link of the\nchain. Without a gateway, the same outage looks like a 429 in one service’s logs, or like nothing\nat all if your client library retries against another model on its own.\n\nFrom a terminal, `ktms chat \"Say hi\"` sends one test call and prints the answer followed by the\nrule, model and vendor that served it. Its source\n([`cmd/ktms/http_cmd.go`](https://github.com/ai-process/ktms/blob/main/cmd/ktms/http_cmd.go))\nis a short reference for reading these headers in your own client.\n\n## What the logs tell you, after the fact\n\nA response header helps the caller. When a user complains a week later, you need history.\n\n**Usage events.** Every upstream call goes through a tracking adapter that records a usage event\nwith the vendor and model of that call, its tokens, duration, cost and status\n([`tracking_adapter.go`](https://github.com/ai-process/ktms/blob/main/internal/llm/adapters/tracking_adapter.go)).\nA failed call is recorded too, with status `ERROR` and no tokens. Vendor SDKs run with their own retries off, so one attempt is one vendor call,\nand the router retries a `429` or `5xx` once on the same model before it falls back. A fallback\ntherefore leaves a trail: error events for `gpt-4o`, then a success event for `gpt-4o-mini`, all\nwith the same `rule` and `effort` in their meta and the same attributes your service sent\n(`user_id`, `action_id`, `metadata`). The events go to light-tokenmeter, where you can group them by model and day.\n\nA cache hit is its own event: zero tokens, the vendor and model of the stored answer, and\n`cache=hit` in its meta (`cache_match=semantic` and the similarity for a semantic hit). A drop in\nquality that coincides with a rise in cache hits is a different problem from a model change, and\nthe events let you tell them apart.\n\n**Metrics.** `ktms_fallbacks_total{from_model, to_model, reason}` counts every move down a chain.\nThe reason is `cooldown`, `circuit_broken`, `upstream_timeout`, `content_filter`,\n`capacity_exhausted` or `schema_failure`. A graph of it per rule answers “how often did the second\nmodel answer last week” without reading a single log line. `ktms_requests_total` carries `vendor`\nand `model` labels on every upstream call.\n\n**Traces.** Each upstream call is a span named after the model, with the OpenTelemetry\n`gen_ai.provider.name` and `gen_ai.request.model` attributes and the KTMS rule.\n\n## Where the gateway’s knowledge stops\n\nHere is the honest part. The model KTMS reports is the **registry id** it called. The registry id\nis also the model name sent to the vendor\n([`internal/registry/build.go`](https://github.com/ai-process/ktms/blob/main/internal/registry/build.go)).\nKTMS does not currently read the vendor’s own report of what answered, such as Gemini’s\n`modelVersion` field. If the vendor redirects a name behind its API, Keystone reports the name it\nasked for.\n\nTwo habits close most of that gap:\n\n- **Register pinned, dated model ids rather than moving aliases.** If a registry id ends in`-latest` , the model behind it changes on the vendor’s schedule, and every log line keeps the\nsame name. A pinned id changes only when you change the configuration, and that change is in\nyour config history.\n- **Watch vendor deprecation pages for the ids you register.** A redirect like the`gemini-2.5-pro` one is announced. Treat it as a configuration change you didn’t make, and\nreplace the id before the date.\n\n## A short checklist\n\n1. Log the model that answered (`model` in the response, or`X-KTMS-Model` ), not the one you\nasked for.\n2. Log `X-KTMS-Rule` and`X-KTMS-Route-Mode` next to it, so “why this model” has an answer.\n3. Alert on `ktms_fallbacks_total` per rule. A chain that falls back all week is a different\nconfiguration from the one you wrote.\n4. Count failed attempts, not just successful calls. They are in the usage events.\n5. Keep cache hits apart when you compare quality across models.\n6. Pin model ids in the registry, and read your vendors’ deprecation notices.\n\n- Response headers and the `model` parameter:[README, OpenAI-compatible API](https://github.com/ai-process/ktms/blob/main/README.md)\n- Metrics: [README, metrics table](https://github.com/ai-process/ktms/blob/main/README.md)\n- Router and fallback reasons: [`internal/router/execute.go`](https://github.com/ai-process/ktms/blob/main/internal/router/execute.go)", "url": "https://wpnews.pro/news/the-logs-say-200-which-model-actually-answered", "canonical_source": "https://blog.ai-process.dev/2026/11/26/which-model-answered/", "published_at": "2026-11-26 07:00:00+00:00", "updated_at": "2026-11-26 08:15:17.438552+00:00", "lang": "en", "topics": ["ai-infrastructure", "large-language-models", "ai-tools", "mlops"], "entities": ["Keystone", "KTMS", "Google", "Gemini", "gemini-2.5-pro", "gemini-3.8-flash", "gpt-4o", "gpt-4o-mini"], "also_reported_by": [], "takeaway": "Read the served model from the response `model` field and the `X-KTMS-*` headers (or gRPC `resolved_model`) rather than trusting the requested model name, since fallback, auto-routing, cache hits and vendor aliasing can all serve a different model under a 200.", "recommendation": {"advice": "Log the resolved model, vendor and route mode from response headers or gRPC fields on every call so fallbacks, cache hits and vendor alias changes are visible when answer quality shifts.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/the-logs-say-200-which-model-actually-answered", "markdown": "https://wpnews.pro/news/the-logs-say-200-which-model-actually-answered.md", "text": "https://wpnews.pro/news/the-logs-say-200-which-model-actually-answered.txt", "jsonld": "https://wpnews.pro/news/the-logs-say-200-which-model-actually-answered.jsonld"}}