Jump to Content
Developers & Practitioners

Announcing the Google Gen AI SDK for Kotlin 1.0: Idiomatic multiplatform access to Gemini

September 3, 2026
https://storage.googleapis.com/gweb-cloudblog-publish/images/google-genai-sdk-kotlin.max-2600x2600.png
Guillaume Laforge

Developer Advocate

Integrating modern generative AI capabilities into Kotlin applications shouldn't require juggling raw HTTP clients or bridging disparate Java libraries. Today, we're excited to announce the 1.0 release of the Google Gen AI SDK for Kotlin (google-genai-kotlin). You can dive right into the code, explore runnable samples, and star the project today on GitHub at googleapis/kotlin-genai.

Built from the ground up as a Kotlin Multiplatform (KMP) library, the SDK brings idiomatic Kotlin paradigms (including first-class Coroutines, asynchronous Flow streaming, and immutable data classes with named and default parameters) to developers specifically targeting the JVM (backend services, serverless functions, desktop).

The SDK provides a unified surface to interact with both the Gemini Developer API (Google AI Studio) and the Gemini Enterprise Agent Platform (on Google Cloud) with minimal configuration tweaks.

Although this SDK is a Kotlin Multiplatform library, using it directly from a mobile app is blocked for security reasons. Instead, use Firebase AI Logic for direct access to Gemini models from mobile apps.

1. Getting started: Adding the dependency

The SDK is published to Maven Central under com.google.genai:google-genai-kotlin.

Kotlin Multiplatform (KMP)

For multiplatform applications, add the dependency to your commonMain source set:

Loading...

Standard JVM projects

For single-platform Kotlin projects, Gradle automatically selects the optimal variant via Gradle Module Metadata:

Loading...

2. Unary and streaming text generation and chat

The primary entry point is the Client class. It manages HTTP connections and authentication automatically based on your environment variables (GEMINI_API_KEY or GOOGLE_API_KEY for Google AI Studio, and GOOGLE_GENAI_USE_ENTERPRISE=true with standard Google Cloud Application Default Credentials).

Single prompt request with Gemini Flash

Using Kotlin's use extension ensures the client's underlying network engine and HTTP connections are released cleanly:

Loading...

Low-latency streaming with Coroutines Flow

For interactive UIs and responsive CLI tools, generateContentStream returns a cold Kotlin Coroutine Flow<GenerateContentResponse>, delivering token chunks in real time:

Loading...

Multi-turn conversations (chat)

Managing conversation history manually across request turns can become tedious. The SDK includes a dedicated chats service that automatically maintains context, appends turns, formats conversation history, and handles function calling:

Loading...

You can also use chat.sendMessageStream(...) for streaming multi-turn chat responses.

3. Multimodal analysis grounded with Google Search

Gemini's multimodal reasoning is especially effective when combined with external verification. For instance, when analyzing technical, medical, or scientific diagrams, you can attach Google Search Grounding to cross-check factual claims against live web sources.

Loading...

4. Visual generation and conversational editing: The Gemini 3 image family

The SDK provides full support for Google's latest image generation models (popularly known as the Nano Banana series of models on leaderboards).

Generating and Saving an Image

Generated image bytes are delivered directly in the response parts as a Blob:

Loading...

Conversational image-to-image editing

You can pass existing images and conversational edit instructions in the same request:

Loading...

5. Real-time bidirectional interaction with Gemini Live

For low-latency voice, audio, and live multimodal interactions, the SDK supports the Gemini Live API via persistent WebSocket connections using client.live.connect(...):

Loading...

6. Structured tool and function calling

When building agentic workflows or bridging LLMs with backend microservices, developers can pass structured JSON schemas via FunctionDeclaration. The model will intelligently select when to invoke the tool:

Loading...

Additionally, when using the chats service, you can take advantage of Automatic Function Calling (AFC), which means that functions declared in the chat conversation can be invoked automatically and transparently by the SDK on your behalf, as you can see in the following example:

Loading...

What's next?

With the 1.0 release of the Google Gen AI SDK for Kotlin, Kotlin developers across backend server ecosystems (Ktor, Spring Boot, Quarkus, Micronaut) now have a clean, multiplatform foundation for building generative AI applications.

To learn more and get started, check out the following resources:

We look forward to seeing what you build with Kotlin and Gemini!

Posted in