diff --git a/generativeai/build.gradle.kts b/generativeai/build.gradle.kts index 4b93220f..260c0c67 100644 --- a/generativeai/build.gradle.kts +++ b/generativeai/build.gradle.kts @@ -32,11 +32,15 @@ android { namespace = "com.google.ai.client.generativeai" compileSdk = 34 + buildFeatures.buildConfig = true + defaultConfig { minSdk = 21 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") + + buildConfigField("String", "VERSION_NAME", "\"${project.version.toString()}\"") } publishing { diff --git a/generativeai/src/main/java/com/google/ai/client/generativeai/internal/api/APIController.kt b/generativeai/src/main/java/com/google/ai/client/generativeai/internal/api/APIController.kt index de299165..73a8c239 100644 --- a/generativeai/src/main/java/com/google/ai/client/generativeai/internal/api/APIController.kt +++ b/generativeai/src/main/java/com/google/ai/client/generativeai/internal/api/APIController.kt @@ -16,6 +16,7 @@ package com.google.ai.client.generativeai.internal.api +import com.google.ai.client.generativeai.BuildConfig import com.google.ai.client.generativeai.internal.util.decodeToFlow import com.google.ai.client.generativeai.type.ServerException import io.ktor.client.HttpClient @@ -101,6 +102,7 @@ internal class APIController( } contentType(ContentType.Application.Json) header("x-goog-api-key", key) + header("x-goog-api-client", "genai-android/${BuildConfig.VERSION_NAME}") } }