Add Gemini 4 Hydrogen to Android with Firebase AI Logic
Step-by-step how-to integrate Gemini 4 Hydrogen into Android apps using Firebase AI Logic for fast everyday coding and agentic tasks.
Android developers can now call Gemini 4 Hydrogen directly from client apps with Firebase AI Logic. Hydrogen is Google’s fast, efficient model for everyday coding, multimodal work, and agentic workflows. It launched on November 12, 2026, and is available on both free and paid Gemini API tiers.
Unlike Gemini 4 Carbon and Argon, Hydrogen does not require billing for basic use. It delivers high intelligence with lower latency and cost. Firebase AI Logic client SDKs support it immediately. You do not need a custom backend. The SDK handles authentication, App Check, and routing.
This guide walks through adding Gemini 4 Hydrogen to an existing Android project and running your first prompt.
Prerequisites
Your Android project must already use Firebase and target API level 24 or higher. Create a Firebase project if needed, register your Android app, and download google-services.json. In the Firebase console, open AI Logic, enable it, and select the Gemini Developer API provider. App Check enforcement became required on November 2, 2026.
Hydrogen works on the free tier with rate limits. Paid usage is priced at $1.50 per million input tokens and $7.50 per million output tokens across its full 1 million-token context window. Thinking tokens count toward output costs.
If you already integrated earlier models, see our guide on adding Gemini 4 Carbon to Android with Firebase AI Logic.
Add the Firebase AI Logic dependency
Open your app-level build.gradle.kts. Add the latest Firebase BOM and the AI Logic library:
dependencies {
implementation(platform("com.google.firebase:firebase-bom:35.1.0"))
implementation("com.google.firebase:firebase-ai")
implementation("com.google.firebase:firebase-appcheck-debug")
}
Sync the project. The BOM keeps versions compatible. Include the App Check debug provider for local testing. Switch to a production provider (Play Integrity) before release.
Initialize the model
Create a GenerativeModel instance that targets Gemini 4 Hydrogen:
import com.google.firebase.Firebase
import com.google.firebase.ai.ai
import com.google.firebase.ai.type.GenerativeBackend
val model = Firebase.ai(backend = GenerativeBackend.googleAI())
.generativeModel("gemini-4-hydrogen")
The model name string must be exactly gemini-4-hydrogen. Hydrogen supports a unified 1M token context window that covers both input and output tokens.
Generate content
Call generateContent with a prompt. Hydrogen handles text, images, video, audio, and PDFs:
val response = model.generateContent(
"Write a clean Kotlin function that retries an HTTP call with exponential backoff. " +
"Include proper logging and a maximum retry limit of five attempts."
)
val output = response.text
Use streaming for longer outputs. Always check safety ratings before showing results to users. Wrap calls in try-catch for network or blocked-prompt failures.
Configure thinking levels
Hydrogen supports four thinking levels: low, medium, high (default), and xhigh. Raise the level for deeper multi-step reasoning on complex tasks:
import com.google.firebase.ai.type.generationConfig
import com.google.firebase.ai.type.thinkingConfig
import com.google.firebase.ai.type.ThinkingLevel
val model = Firebase.ai(backend = GenerativeBackend.googleAI())
.generativeModel(
modelName = "gemini-4-hydrogen",
generationConfig = generationConfig {
thinkingConfig = thinkingConfig {
thinkingLevel = ThinkingLevel.HIGH
}
}
)
Higher levels improve results on coding, debugging, and analysis but increase latency and token cost. Start with high (the default) and lower it for simple, high-volume tasks. Setting thinking level to minimal returns an error on Hydrogen.
Production checklist
Enable App Check with a production provider before shipping. Requests fail without it after the November 2 enforcement date.
Monitor token usage in the Firebase console. Set budget alerts on your Google Cloud project if you move beyond the free tier. Hydrogen is billed at Gemini API rates when you exceed free quotas.
Test edge cases: empty responses, safety blocks, and timeouts. Provide clear user messages for failures.
Tips for better results
Write specific prompts that describe the desired output format and constraints. For agentic workflows, break large tasks into steps and feed intermediate results back into follow-up calls.
Use system instructions or few-shot examples for consistent style. Combine Hydrogen with function calling for tool use inside your app.
Hydrogen finishes many everyday coding tasks faster than Gemini 3.8 Flash while reducing fabricated claims. It pairs well with frontier models like Carbon for multi-model workflows where Hydrogen handles rapid execution and Carbon handles deep architectural decisions.
Conclusion
Gemini 4 Hydrogen is available today through Firebase AI Logic for Android apps on both free and paid Gemini API tiers. Integration usually requires only a dependency update and a model name change. Enable App Check, monitor costs, and start with the default high thinking level before adjusting for your use case.
Check the official Firebase AI Logic models page and Gemini API documentation for the latest details and pricing.
Sources
- Blog.google: Introducing Gemini 4 Hydrogen (November 12, 2026)
- Firebase documentation: Learn about supported models (Gemini 4 Hydrogen)
- Firebase AI Logic getting started guide for Android
- Google AI: Gemini 4 Hydrogen developer guide
Share this story