Skip to content
VibeSafeDaily

Publishing

Your Firebase AI feature returns a 400 after you switch to Gemini 4

Cataloged November 15, 2026 · Firebase · Cursor · Bolt · v0 · Lovable · Replit

Symptom

The rest of the app still loads. The AI feature returns a 400. The code that calls it still compiles. This applies to an app that calls Firebase AI Logic, including an app built in Lovable, Bolt, Cursor, Replit, or v0 when that app uses Firebase AI Logic. If the app does not call Firebase AI Logic, this card does not apply. Firebase's release notes for November 10, 2026 say Firebase AI Logic supports the Gemini stable model gemini-4-carbon, through the Gemini Developer API or the Agent Platform Gemini API (formerly Vertex AI). The November 12, 2026 notes say Firebase AI Logic supports gemini-4-hydrogen, through the Gemini Developer API (free tier) or the Agent Platform Gemini API (formerly Vertex AI). An AI coding tool asked to upgrade to the newest Gemini usually changes only the model name string and leaves the old generation settings in the call. The settings this card means are thinkingBudget, a thinking level of MINIMAL, frequencyPenalty, presencePenalty, candidateCount, and a prefilled model turn. The Firebase docs page "Thinking" says: "The Gemini 2.5 models use thinking budget instead of thinking level. The general-use Gemini 3.x models and the latest Gemini Nano Banana models support thinking budget for backwards-compatibility. However, the Gemini 4.x models do not support thinking budget (and will return a 400 error if it's set)." The November 10 notes say that on gemini-4-carbon, setting the thinking level to MINIMAL is not supported and the request fails with a 400 error, and that using thinkingBudget is not supported. There is no backwards-compatibility. The request fails with a 400 error. Those notes also say frequency penalty, presence penalty, and candidate count make the request fail with a 400 error, and that prefilled model turns are not supported. If the last non-empty turn in the request is a model turn, the request fails with a 400 error. The November 12 notes say that on gemini-4-hydrogen, MINIMAL is not supported and the request fails with a 400 error, and that unlike gemini-3.8-flash, thinkingBudget is not supported. There is no backwards-compatibility. The request fails with a 400 error. Those notes say frequencyPenalty, presencePenalty, and candidateCount fail with a 400 error. The November 12 notes do not state the prefilled-model-turn rule. The other trap is on gemini-4-hydrogen. Those notes say that if you upgrade from gemini-3.8-flash, or from another Gemini 3.x model, and you remove the old setting without choosing a level, the default thinking level is HIGH. That default changed from MEDIUM on gemini-3.8-flash. Firebase says that may increase latency and token usage unless you explicitly set thinkingLevel to MEDIUM or LOW.

Root cause

The call names gemini-4-carbon or gemini-4-hydrogen and still sends a generation config written for an older Gemini model. The Firebase docs page "Thinking" shows the budget form in its code samples for budget-based models: ThinkingConfig(thinkingBudget: 1024) and thinkingBudget = 1024. The Web sample on that page sets generationConfig to an object whose thinkingConfig is { thinkingBudget: 1024 }, then passes that object to getGenerativeModel. The same page says Gemini 4.x models do not support thinking budget and will return a 400 error if it is set. That page's supported thinking level table says gemini-4-hydrogen does not support MINIMAL, and it does support LOW, MEDIUM, and HIGH, with HIGH as the default. The same table says gemini-4-argon and gemini-4-carbon do not support MINIMAL, and they do support LOW, MEDIUM, and HIGH, with MEDIUM as the default. A footnote on that page says gemini-4-hydrogen, gemini-4-argon, gemini-4-carbon, gemini-3.8-flash, and gemini-3.7-flash do not support MINIMAL, and setting it fails with a 400 error. The November 10, 2026 release notes say the thinking levels supported for gemini-4-carbon are LOW, MEDIUM (the default), and HIGH. Setting MINIMAL fails with a 400 error. Using thinkingBudget fails with a 400 error, and there is no backwards-compatibility. Those notes say temperature, top-K, and top-P are ignored by the model. Frequency penalty, presence penalty, and candidate count make the request fail with a 400 error. For more deterministic responses, those notes say to define system instructions with explicit rules. Those notes say explicit context caching is not supported, and that implicit caching is on by default. Those notes say the output token limits for gemini-4-carbon are 32,768 tokens for non-streaming requests and 65,536 for streaming requests, and that those numbers are the default and the maximum. Those notes say accessing gemini-4-carbon requires the pay-as-you-go Blaze pricing plan regardless of your Gemini API provider. For the Agent Platform Gemini API (formerly Vertex AI), those notes say gemini-4-carbon is a short-term availability model. To avoid service disruptions when models are updated, Firebase strongly recommends using Firebase Remote Config or server prompt templates to manage the model name in the app dynamically. The November 12, 2026 notes say gemini-4-hydrogen is available through the Gemini Developer API (free tier) or the Agent Platform Gemini API (formerly Vertex AI). On that Agent Platform API it is also a short-term availability model, with the same Remote Config or server prompt templates recommendation. Those notes say the supported thinking levels in Firebase AI Logic are LOW, MEDIUM, and HIGH, and that HIGH is the default. XHIGH is not supported in Firebase AI Logic. MINIMAL fails with a 400 error. Unlike gemini-3.8-flash, thinkingBudget is not supported, there is no backwards-compatibility, and the request fails with a 400 error. Those notes say temperature, topP, and topK are ignored, and that frequencyPenalty, presencePenalty, and candidateCount fail with a 400 error. Those notes say explicit caching is not supported. They do not say that implicit caching is on by default, and they do not state the prefilled-model-turn rule or the output token limits. The November 10 and November 12 notes point to the Firebase docs page "Change the model name remotely" for managing the model name with Firebase Remote Config.

Before and after

Both calls use the Web (JavaScript) shape on the Firebase docs page "Thinking": getAI(firebaseApp, { backend: new GoogleAIBackend() }), then getGenerativeModel(ai, { model, generationConfig }). The before call sets the model to gemini-4-hydrogen and sets thinkingConfig to { thinkingBudget: 1024 }. That 1024 is the value in the Thinking page's Web sample for budget-based models. The November 12, 2026 Firebase release notes say using thinkingBudget on gemini-4-hydrogen is not supported and the request fails with a 400 error. The November 10, 2026 notes say the same for gemini-4-carbon. frequencyPenalty, presencePenalty, and candidateCount are the parameter names the November 12 notes say fail with a 400 error. They are shown as names only. Those notes do not publish example values, and the Thinking page's sample does not show those three fields. The after call removes them and sets thinkingLevel to ThinkingLevel.MEDIUM. The Thinking page's Web sample writes the level as ThinkingLevel.LOW. MEDIUM uses that same enum form. That sample does not print ThinkingLevel.MEDIUM or the string "MEDIUM". The November 12 notes say the supported levels in Firebase AI Logic for gemini-4-hydrogen are LOW, MEDIUM, and HIGH, and that HIGH is the default.

Before

const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
const generationConfig = {
  thinkingConfig: { thinkingBudget: 1024 },
  frequencyPenalty,
  presencePenalty,
  candidateCount,
};
const model = getGenerativeModel(ai, {
  model: "gemini-4-hydrogen",
  generationConfig,
});

After

const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
const generationConfig = {
  thinkingConfig: { thinkingLevel: ThinkingLevel.MEDIUM },
};
const model = getGenerativeModel(ai, {
  model: "gemini-4-hydrogen",
  generationConfig,
});

Fix prompt

In this project only. Do not scan or test anyone else's app. Do not open anyone else's Firebase project. Do not print keys, tokens, passwords, or environment variable values. When you mention a variable, print the name only.

1. Find every Firebase AI Logic model call in this project. Search for getAI, getGenerativeModel, GoogleAIBackend, firebase/ai, FirebaseAI, firebase_ai, and GenerativeBackend.googleAI. If this project does not call Firebase AI Logic, say so and stop.

2. For each call, give the file, the line, the model name, and every generation or thinking setting on that call. Include thinkingBudget, thinking_budget, thinkingLevel, thinking_level, MINIMAL, XHIGH, frequencyPenalty, presencePenalty, candidateCount, temperature, topP, topK, top-K, top-P, any explicit caching setting, and any turn this project wrote as a model turn. Do not print keys or env values.

3. Change a call only when it names gemini-4-carbon or gemini-4-hydrogen, or I have said that call is moving to one of those two. If neither name appears and I have not said to move a call, list the model names you found and stop. Do not edit other models.

4. Replace thinkingBudget and thinking_budget with an explicit thinkingLevel. Use LOW or MEDIUM unless I say the feature needs HIGH. The November 12, 2026 Firebase release notes say the default thinking level on gemini-4-hydrogen is HIGH, changed from MEDIUM on gemini-3.8-flash, which may increase latency and token usage unless you explicitly set thinkingLevel to MEDIUM or LOW. The November 10, 2026 notes say the default for gemini-4-carbon is MEDIUM. The Firebase docs page "Thinking" says gemini-4-hydrogen supports LOW, MEDIUM, and HIGH, with HIGH as the default, and gemini-4-carbon supports LOW, MEDIUM, and HIGH, with MEDIUM as the default. Do not set MINIMAL. Both sets of notes say MINIMAL is not supported and the request fails with a 400 error. That Thinking page says the same for gemini-4-hydrogen, gemini-4-argon, gemini-4-carbon, gemini-3.8-flash, and gemini-3.7-flash. Do not set XHIGH. The November 12 notes say XHIGH is not supported in Firebase AI Logic. They do not say XHIGH returns a 400 error. The Thinking page's Web sample writes the level as ThinkingLevel.LOW. Use ThinkingLevel.LOW or ThinkingLevel.MEDIUM in that form, unless this file already spells the level another way. Do not pass the string "MEDIUM" or "LOW" unless this file already does. Show me the diff.

5. Remove frequencyPenalty, presencePenalty, and candidateCount from those calls. The November 12 notes say those fail with a 400 error. The November 10 notes say frequency penalty, presence penalty, and candidate count make the request fail with a 400 error. Show me the diff.

6. Stop relying on temperature, topP, and topK, including top-K and top-P. The November 12 notes say temperature, topP, and topK are ignored. The November 10 notes say temperature, top-K, and top-P are ignored by the model. Remove them from those calls. If this project does not set them on these calls, say so and do not add a system instruction. Where this project used them to keep answers steady, add system instructions with explicit rules. The November 10 notes say to define system instructions with explicit rules for more deterministic responses. Use systemInstruction or system_instruction, whichever name this project already uses. Do not add an import. If this project does set them and neither name appears, stop on this step and tell me. Do not invent a field name. Show me the diff.

7. If a request to gemini-4-carbon ends with a model turn this project wrote in advance, remove that trailing prefilled model turn. The November 10 notes say prefilled model turns are not supported. If the last non-empty turn in the request is a model turn, the request fails with a 400 error. The November 12 notes do not state that rule for gemini-4-hydrogen. On a gemini-4-hydrogen call, still remove a trailing model turn this project wrote in advance, and do not claim those notes say it returns a 400. Show me the diff.

8. Do not add explicit context caching. If one of these calls sets explicit context caching or explicit caching, remove that setting and name the field you found. Do not invent a field name. The November 10 notes say explicit context caching is not supported on gemini-4-carbon, and that implicit caching is on by default. The November 12 notes say explicit caching is not supported on gemini-4-hydrogen. They do not say implicit caching is on by default. Do not turn implicit caching off. Show me the diff only if you remove a setting.

9. Move the model name out of the call and into Firebase Remote Config. Set the default value to the model name this project uses today, the one that already works. The November 10 notes say that on the Agent Platform Gemini API (formerly Vertex AI), gemini-4-carbon is a short-term availability model, and Firebase strongly recommends Firebase Remote Config or server prompt templates to manage the model name dynamically, to avoid service disruptions when models are updated. The November 12 notes say the same for gemini-4-hydrogen on that API. Those notes point to the Firebase docs page "Change the model name remotely". Follow that page. If this project already uses a server prompt template for the model name, use that instead of adding Remote Config. Do not invent a parameter name. If you cannot read that page, stop and tell me. If this project uses GoogleAIBackend, as the Thinking page's Web sample does, say that the notes state the short-term recommendation for the Agent Platform Gemini API, and still make this move. Do not change the Firebase console yourself. Tell me the parameter name that page uses and what I need to set in a Firebase project I own. Show me the diff.

10. If any call will use gemini-4-carbon, stop before you switch it and tell me to confirm this Firebase project is on the pay-as-you-go Blaze pricing plan. The November 10 notes say accessing gemini-4-carbon requires that plan regardless of the Gemini API provider. Do not change the billing plan. The November 12 notes say gemini-4-hydrogen is available through the Gemini Developer API (free tier) or the Agent Platform Gemini API. They do not say gemini-4-hydrogen requires Blaze.

11. The November 10 notes say the output token limits for gemini-4-carbon are 32,768 tokens for non-streaming requests and 65,536 for streaming requests, and that those numbers are the default and the maximum. If a gemini-4-carbon call in this project sets a higher output limit, tell me the file and the line. Do not raise it. The November 12 notes do not state those limits for gemini-4-hydrogen. Do not copy the carbon limits onto a hydrogen call.

12. Show me the diffs. Do not run the feature against anyone else's project. Tell me to trigger this project's own AI feature once on the new model and confirm it answers instead of returning a 400.

Do not print keys. Do not edit unrelated files.

Paste this into the coding tool that has your own project open.

2-minute self-check

These steps are for an app you own. Do not run them against someone else's project.

  1. In your own code, search for thinkingBudget, MINIMAL, frequencyPenalty, presencePenalty, candidateCount, gemini-4-carbon, and gemini-4-hydrogen. The Firebase docs page "Thinking" says Gemini 4.x models do not support thinking budget and will return a 400 error if it is set. The November 10, 2026 Firebase release notes say MINIMAL and thinkingBudget fail with a 400 error on gemini-4-carbon, and that frequency penalty, presence penalty, and candidate count do too. The November 12, 2026 notes say MINIMAL and thinkingBudget fail with a 400 error on gemini-4-hydrogen, and that frequencyPenalty, presencePenalty, and candidateCount do too. Do not search a repository you do not own.
  2. Trigger your own AI feature once on the new model. Confirm it answers instead of returning a 400. The Thinking page says a Gemini 4.x request returns a 400 error if thinking budget is set. Do not call an app you do not own, and do not paste an API key.
  3. If you moved that feature to gemini-4-hydrogen, check your own Firebase usage after a day. The November 12, 2026 notes say the default thinking level is HIGH, changed from MEDIUM on gemini-3.8-flash, which may increase latency and token usage unless you explicitly set thinkingLevel to MEDIUM or LOW. Do not open a Firebase project you do not own.

Common questions

I only changed the model name to Gemini 4. Why does the feature return a 400?

The old generation settings are still on the call. The Firebase docs page "Thinking" says: "The Gemini 2.5 models use thinking budget instead of thinking level. The general-use Gemini 3.x models and the latest Gemini Nano Banana models support thinking budget for backwards-compatibility. However, the Gemini 4.x models do not support thinking budget (and will return a 400 error if it's set)." That page's code samples for budget-based models still show ThinkingConfig(thinkingBudget: 1024) and thinkingBudget = 1024. The Web sample sets thinkingConfig to { thinkingBudget: 1024 }. The November 10, 2026 Firebase release notes say that on gemini-4-carbon, MINIMAL and thinkingBudget each fail with a 400 error, and that frequency penalty, presence penalty, and candidate count do too. Those notes also say a prefilled model turn fails with a 400 error if the last non-empty turn in the request is a model turn. The November 12, 2026 notes say that on gemini-4-hydrogen, MINIMAL and thinkingBudget each fail with a 400 error, and that frequencyPenalty, presencePenalty, and candidateCount do too. Those notes do not state the prefilled-model-turn rule. The code can still compile. The failure is the 400 those notes describe.

I deleted thinkingBudget and did not pick a level. Why might gemini-4-hydrogen use more tokens?

The November 12, 2026 Firebase release notes say the default thinking level on gemini-4-hydrogen is HIGH. That changed from MEDIUM on gemini-3.8-flash. Firebase says that may increase latency and token usage unless you explicitly set thinkingLevel to MEDIUM or LOW. The supported levels in Firebase AI Logic are LOW, MEDIUM, and HIGH, and HIGH is the default. XHIGH is not supported in Firebase AI Logic. MINIMAL is not supported and the request fails with a 400 error. The November 10, 2026 notes say the default for gemini-4-carbon is MEDIUM, not HIGH. Do not treat the hydrogen default as the carbon default. The Firebase docs page "Thinking" agrees: HIGH is the default for gemini-4-hydrogen, and MEDIUM is the default for gemini-4-carbon.

Can I leave the new model name hard-coded, and does gemini-4-carbon need a paid plan?

The November 10, 2026 Firebase release notes say accessing gemini-4-carbon requires the pay-as-you-go Blaze pricing plan regardless of your Gemini API provider. On the Agent Platform Gemini API (formerly Vertex AI), those notes say gemini-4-carbon is a short-term availability model. To avoid service disruptions when models are updated, Firebase strongly recommends Firebase Remote Config or server prompt templates to manage the model name dynamically. Those notes point to the Firebase docs page "Change the model name remotely" for Remote Config. The November 12, 2026 notes say gemini-4-hydrogen is available through the Gemini Developer API (free tier) or the Agent Platform Gemini API (formerly Vertex AI). On that Agent Platform API it is also a short-term availability model, with the same recommendation. Those notes do not say gemini-4-hydrogen requires Blaze.

Sources

Same symptom

Same platform