> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apiyi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# What Should I Do When Gemini 4 Reports a Different Model?

> Learn how to handle a Gemini 4 native response whose modelVersion differs from the requested model: raise an alert, record responseId, isolate the task, and create a second-pass list.

## Short Answer

When calling Gemini 4 models such as `gemini-4-argon` or `gemini-4-hydrogen`, if `modelVersion` in the native response differs from the requested model, **do not mark the task as successful merely because it returned HTTP 200, and do not immediately retry it automatically**.

Keep the response and record the requested model, returned model, `responseId`, and your business task ID. Mark the task as `needs_rerun`. After the batch finishes, generate an exception report and decide whether to run a second pass over only those tasks.

> [!WARNING]
>
> This is a model-reporting or routing anomaly that can occur on Google's provider side. **It does not mean your request violated a policy or that your account was downgraded.** `modelVersion` alone cannot prove that different serving weights generated the answer, but consistency-sensitive tasks should not accept the result as valid output from the requested model.

## How to Confirm the Condition

A native Gemini `generateContent` response includes both `modelVersion` and `responseId` at the top level:

```json theme={null}
{
  "candidates": [
    {
      "content": {
        "parts": [{ "text": "Example answer" }]
      },
      "finishReason": "STOP"
    }
  ],
  "modelVersion": "3.1-flash-lite-05-2026",
  "responseId": "example-response-id"
}
```

If the request was for `gemini-4-argon`, this returned model is unexpected. Flag it separately at the business layer even if the text looks normal and `finishReason` is `STOP`.

* **Non-streaming:** check `modelVersion` in the complete response.
* **Streaming:** inspect every chunk, not only the first one. Public reproductions show that earlier chunks and the final `STOP` chunk can report different models under the same `responseId`.
* **OpenAI-compatible format:** do not use the response's `model` field as a substitute for this check, because it usually echoes the requested model name. Use the native Gemini format when you need to verify the provider's returned model.

## Recommended Workflow

**1. Verify the model for every request**

For a fixed model ID, use a strict comparison: `response.model_version == requested_model`. A missing value also needs an exception marker because the actual model cannot be confirmed; do not treat it as a pass by default.

**2. Alert and preserve the original result**

Record the anomaly without discarding the returned text or usage. The result helps with diagnosis, and a model mismatch alone should not immediately create a second billable request.

**3. Isolate the task without stopping the batch**

Mark the current task as `needs_rerun` and continue with the remaining tasks. The batch report should summarize at least successes, model-reporting anomalies, other failures, and tasks awaiting a second pass.

**4. Run a second pass after review**

Generate a list containing only the affected task IDs. Check every returned model again during the second pass, keep the first report unchanged, and avoid unlimited automatic retries.

## Python Validation Example

This example uses the `google-genai` SDK. It makes only one request and leaves the decision to the calling batch program; it does not retry automatically:

```python theme={null}
import json
import os
import sys

from google import genai
from google.genai import types

requested_model = "gemini-4-argon"
task_id = "task-001"

with genai.Client(
    api_key=os.environ["APIYI_API_KEY"],
    http_options=types.HttpOptions(base_url="https://api.apiyi.com"),
) as client:
    response = client.models.generate_content(
        model=requested_model,
        contents="Introduce yourself in one sentence",
    )

actual_model = response.model_version
needs_rerun = actual_model != requested_model
record = {
    "task_id": task_id,
    "requested_model": requested_model,
    "model_version": actual_model,
    "response_id": response.response_id,
    "needs_rerun": needs_rerun,
    "answer": response.text,
}

if needs_rerun:
    print(
        f"WARNING {task_id}: requested={requested_model}, "
        f"returned={actual_model}, response_id={response.response_id}; "
        "not retrying automatically",
        file=sys.stderr,
    )

print(json.dumps(record, ensure_ascii=False))
```

For streaming calls, collect the model reported by every chunk instead of keeping only the last value:

```python theme={null}
versions = set()
response_id = ""

for chunk in client.models.generate_content_stream(
    model=requested_model,
    contents="Introduce yourself in one sentence",
):
    if chunk.model_version:
        versions.add(chunk.model_version)
    if chunk.response_id:
        response_id = chunk.response_id

needs_rerun = versions != {requested_model}
```

`needs_rerun` is `True` when the set is empty, contains another model, or contains multiple models. Continue assembling the text chunk by chunk, and check `finishReason` and usage separately.

## What to Record in a Batch Report

| Field | Purpose |
| - | - |
| `task_id` or relative business-file path | Identify which task needs a second pass |
| `requested_model` | The exact model ID sent in the request |
| `model_version` | The model returned in the native response |
| `response_id` | Locate the specific request together with its timestamp |
| `needs_rerun` / exception reason | Build a targeted second-pass list instead of rerunning the whole batch |
| Timestamp with time zone, latency, and tokens | Analyze anomaly distribution and cost |
| Original text and `finishReason` | Preserve evidence and distinguish model anomalies from empty or truncated responses |

> [!NOTE]
>
> Never log API keys. When contacting support, provide the requested model, returned model, `responseId`, timestamp with time zone, and a sanitized reproduction request. Do not share customer content or complete business datasets.

## FAQ

> [accordion] Why not retry immediately after detecting a mismatch?
>
> Immediate retries increase traffic and cost, and can create a retry storm while the anomaly persists. Preserving the first-pass evidence and isolating affected tasks before a bounded second pass makes diagnosis and accounting easier. If your business requires automatic retries, set a maximum attempt count, backoff, and circuit breaking, and record every response.

> [accordion] Does a mismatched value prove that Flash-Lite generated the answer?
>
> No conclusion can be drawn from this field alone. The cause could be an actual routing change or an anomaly in version or metering metadata. In either case, tasks with a hard requirement for a specific model should treat the result as failing model-consistency validation.

> [accordion] Should every model name be compared strictly?
>
> Strict equality is the clearest rule for the fixed Gemini 4 model IDs covered here. If you deliberately use an alias such as `latest`, receiving a concrete version can be normal. Validate against your explicitly accepted set of versions instead of applying the fixed-ID rule.

> [accordion] What if the second pass still returns a different model?
>
> Stop further automatic retries and preserve both reports. Collect the affected `responseId` values, requested and returned models, timestamps, and a sanitized reproduction request, then contact APIYI support to investigate the provider-side condition.

## Related Docs

> [card] [Gemini Native Response Parsing](https://docs.apiyi.com/en/api-capabilities/gemini/response-handling.md)
>
> Non-streaming, streaming, modelVersion, responseId, and usage fields

> [card] [Gemini Native API Guide](https://docs.apiyi.com/en/api-capabilities/gemini/native.md)
>
> The google-genai SDK, native endpoint, and thinking configuration

> [card] [Gemini 4 Carbon Model-Switching Notes](https://docs.apiyi.com/en/api-capabilities/gemini-4-carbon/overview.md)
>
> Previously observed behavior, impact, and recommendations

> [card] [Gemini 4 Argon Text Generation](https://docs.apiyi.com/en/api-capabilities/gemini-4-argon/overview.md)
>
> Argon's model ID, dual endpoints, and calling examples


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.