Skip to content

Conversation

cartland
Copy link
Contributor

@cartland cartland commented Oct 8, 2025

This commit introduces a collection of code snippets demonstrating the usage of the Gemini Developer API. It includes examples for model configuration, text-only and multimodal inputs (image, audio, video), multi-turn chat, and image generation/editing.

The necessary dependencies for Firebase AI, Guava, and Reactive Streams have been added to gradle/libs.versions.toml and misc/build.gradle.kts.

Intended documentation pages:

Copy link

snippet-bot bot commented Oct 8, 2025

Here is the summary of changes.

You are about to add 24 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@cartland
Copy link
Contributor Author

cartland commented Oct 8, 2025

This PR will make the following PRs obsolete:
#642
#643
#644
#645
#646

Copy link

@askandroid askandroid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this, Cartland!

@cartland cartland force-pushed the cartland/gemini-developer-api branch from 61a97f5 to e04c9fd Compare October 8, 2025 22:37
This commit introduces a collection of code snippets demonstrating the usage of the Gemini Developer API. It includes examples for model configuration, text-only and multimodal inputs (image, audio, video), multi-turn chat, and image generation/editing.

The necessary dependencies for Firebase AI, Guava, and Reactive Streams have been added to gradle/libs.versions.toml and misc/build.gradle.kts.

Region-Tag: android_gemini_developer_api_gemini_25_flash_model
Region-Tag: android_gemini_developer_api_gemini_25_flash_image_model
Region-Tag: android_gemini_developer_api_text_only_input
Region-Tag: android_gemini_developer_api_multimodal_input
Region-Tag: android_gemini_developer_api_multimodal_audio_input
Region-Tag: android_gemini_developer_api_multimodal_video_input
Region-Tag: android_gemini_developer_api_multiturn_chat
Region-Tag: android_gemini_developer_api_generate_image_from_text
Region-Tag: android_gemini_developer_api_edit_image
Region-Tag: android_gemini_developer_api_edit_image_chat
Region-Tag: android_gemini_developer_api_gemini_25_flash_model_java
Region-Tag: android_gemini_developer_api_gemini_25_flash_image_model_java
Region-Tag: android_gemini_developer_api_text_only_input_java
Region-Tag: android_gemini_developer_api_multimodal_input_java
Region-Tag: android_gemini_developer_api_multimodal_audio_input_java
Region-Tag: android_gemini_developer_api_multimodal_video_input_java
Region-Tag: android_gemini_developer_api_multiturn_chat_java
Region-Tag: android_gemini_developer_api_generate_image_from_text_java
Region-Tag: android_gemini_developer_api_edit_image_java
Region-Tag: android_gemini_developer_api_edit_image_chat_java
This commit adds new Kotlin snippets for the Firebase AI Imagen API.

The snippets demonstrate how to:
- Configure the Imagen model with options like image count, aspect ratio, and safety settings.
- Generate an image from a text prompt.

Region-Tags:
- `android_imagen_model_configuration`
- `android_imagen_generate_images`
This commit introduces snippets for Imagen 4.0, a text-to-image generation model. It adds new files, `ImagenSnippets.kt` and `ImagenSnippetsJava.java`, which demonstrate how to configure the model and generate images from a text prompt.

The commit also includes the following changes:
- Adds the `@PublicPreviewAPI` annotation to the new Imagen snippets.
- Refactors existing Gemini snippets to initialize models within a static block for consistency.
- Adds `@SuppressWarnings("unused")` to several functions and classes to handle linter warnings.
- Updates the `build.gradle.kts` file to exclude the `.idea` directory from Spotless XML formatting.
@cartland cartland force-pushed the cartland/gemini-developer-api branch from c921479 to e25629f Compare October 10, 2025 17:24
object Gemini25FlashImagePreviewModelConfiguration {
// [START android_gemini_developer_api_gemini_25_flash_image_model]
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
modelName = "gemini-2.5-flash-image-preview",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to use dev site variables in our snippets?
I want us to try to move away from hardcoding the model names in our DAC code blocks.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question. :) Further to this point, we're sharing values with other teams. Can we just add those variables in here or will that cause questionable results?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation does not currently use variables. If you want to turn those into variables, we could make a separate standalone hard-coded snippet in the documentation that uses the documentation tool variables, but we cannot use the same variables in GitHub. We could then modify the GitHub code to use the same variable name, and define the variable somewhere outside of the snippet region tags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanbeiji do you have any additional feedback on this? Since there aren't any equivalent documentation variables to consider right now, perhaps we can address that later if those variables are created?

@cartland cartland merged commit 7f45bcf into main Oct 14, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants