Model=auto in Practice: How to Confirm Which Backend Actually Served Your Request
Learn how to inspect API responses to identify which model backend actually served a request when using model=auto. This guide covers examining response bodies and headers, with practical logging strategies for cost attribution.
Why model=auto needs verification
When you set model=auto, the routing system chooses a model based on availability, capabilities, or other heuristics. But for debugging and cost attribution, you need to know which backend actually handled each request. Fortunately, most APIs reveal this information in the response—either in the body or in headers.
Inspecting the response body
The response body is the most straightforward place to find the served model. Look for fields such as model, backend, or similar metadata. For example:
{
"id": "chatcmpl-abc123",
"model": "claude-3-sonnet-20240229",
"choices": [...]
}
Check the model field—it typically indicates the exact model version used. Some APIs also include additional details like provider or system_fingerprint. Always consult your API documentation for the exact field names.
Inspecting response headers
If the body doesn’t include model information, headers often do. Look for headers like x-model, x-backend, or x-provider. For instance:
X-Model: gpt-4-turbo
X-Provider: openai
These headers can be logged alongside the request for later analysis. Note that header names vary by provider, so check your API’s documentation.
Logging for cost attribution
Once you identify the backend, log it with the request metadata (timestamp, user ID, token counts). This lets you attribute costs accurately, especially when different models have different prices. With our pricing model (official price × 1.3), knowing the backend helps you verify charges and calculate contributor credits if applicable.
Example log entry:
{
"timestamp": "2025-03-01T12:00:00Z",
"request_id": "req_123",
"served_model": "claude-3-sonnet-20240229",
"input_tokens": 50,
"output_tokens": 100
}
Handling missing information
If neither the body nor headers reveal the model, contact the API provider. Some systems may not expose this data, but knowing the limitation helps you plan alternative verification (e.g., comparing response characteristics). Always rely on official documentation for the most accurate method.
Best practices
- Always inspect both body and headers—one might have the info when the other doesn’t.
- Log the served model consistently for all requests, not just those using
model=auto. - Use structured logging to make analysis easy.
- Periodically audit logs to ensure routing behaves as expected.