Client
The main entry point for the Google Gen AI SDK.
Note on Mobile Security: While this SDK supports Android targets via Kotlin Multiplatform, it is intended for server-side use or secure backend environments. We strongly discourage embedding API keys or Google Cloud IAM credentials (such as Service Account JSON keys or OAuth tokens) directly into public mobile client applications without protection. For public mobile apps connecting directly from client devices, please use Firebase AI Logic with Firebase App Check enabled.
Usage:
val client = Client(apiKey = "YOUR_API_KEY")
val response = client.models.generateContent("gemini-3.5-flash", "Hello, world!")
println(response.text)Content copied to clipboard
Constructors
Link copied to clipboard
constructor(apiKey: String? = null, project: String? = null, location: String? = null, credentials: GoogleCredentials? = null, enterprise: Boolean? = null, httpOptions: HttpOptions? = null)
Constructs a Client instance for either Gemini API or Gemini Enterprise Agent Platform API.