Package-level declarations

Types

Link copied to clipboard
@Serializable
data class AttributionSourceId(val groundingPassage: GroundingPassageId? = null, val semanticRetrieverChunk: SemanticRetrieverChunk? = null)

Identifies the source of an attribution, which can be either a grounding passage or a chunk retrieved by a semantic retriever. This class allows for specifying the origin of content or data used in processing or analysis.

Link copied to clipboard

Represents the attribution source id builder.

Link copied to clipboard
@Serializable
data class BatchEmbedRequest(val requests: List<EmbedContentRequest>)

Represents a batch request for embedding content.

Link copied to clipboard
@Serializable
data class BatchEmbedResponse(val embeddings: List<Values>)

Represents the response for a batch embedding request.

Link copied to clipboard
@Serializable
data class CachedContent(val contents: List<Content>? = null, val tools: List<Tool>? = null, val createTime: String? = null, val updateTime: String? = null, val usageMetadata: UsageMetadata? = null, val expireTime: String? = null, val ttl: String? = null, val name: String? = null, val displayName: String? = null, val model: String? = null, val systemInstruction: Content? = null, val toolConfig: ToolConfig? = null)

Represents the cached content.

Link copied to clipboard
@Serializable
data class CachedContentList(val cachedContents: List<CachedContent>? = null, val nextPageToken: String? = null)

Represents the cached content list.

Link copied to clipboard
@Serializable
data class Candidate(val content: Content, val finishReason: String? = null, val index: Int? = null, val safetyRatings: List<SafetyRating>? = null, val citationMetadata: CitationMetadata? = null, val tokenCount: Int? = null, val avgLogprobs: Double? = null, val logprobsResult: LogprobsResult? = null, val groundingAttributions: List<GroundingAttribution> = emptyList(), val groundingMetadata: GroundingMetadata? = null, val urlContextMetadata: UrlContextMetadata? = null)

Represents a candidate entity with associated content and metadata.

Link copied to clipboard

Represents the candidate builder.

Link copied to clipboard
@Serializable
data class CitationMetadata(val citationSources: List<CitationSource>)

Contains metadata about citations within a document, including references to the sources of these citations.

Link copied to clipboard

Represents the citation metadata builder.

Link copied to clipboard
@Serializable
data class CitationSource(val startIndex: Int, val endIndex: Int, val uri: String, val license: String)

Represents a source of citation, detailing the location within the text and providing reference information such as a URI and license.

Link copied to clipboard

Represents the citation source builder.

Link copied to clipboard
@Serializable
class CodeExecution

Represents the code execution.

Link copied to clipboard
@Serializable
data class CodeExecutionResult(val outcome: String, val output: String)

Represents the code execution result.

Link copied to clipboard

Represents the code execution result builder.

Link copied to clipboard
@Serializable
data class Content(val parts: Array<Part>? = null, val role: String? = null)

Represents the content composed of multiple parts, optionally associated with a specific role.

Link copied to clipboard

Represents the content builder.

Link copied to clipboard
@Serializable
data class CountTokensRequest(val contents: List<Content>)

Represents a request to count the number of tokens in a list of content items. This is typically used to ensure that input does not exceed model or system limits for processing.

Link copied to clipboard
@Serializable
data class EmbedContentRequest(val content: Content, val model: String, val taskType: TaskType? = null, val title: String? = null)

Represents a request to embed content using a specified model, optionally including additional parameters such as task type and title.

Link copied to clipboard
@Serializable
data class EmbedResponse(val embedding: Values)

Represents the response from an embedding operation, containing the computed embedding values.

Link copied to clipboard
@Serializable
data class ExecutableCode(val language: String, val code: String)

Represents the executable code.

Link copied to clipboard

Represents the executable code builder.

Link copied to clipboard
@Serializable
data class FileData(val mimeType: String, val fileUri: String)

Encapsulates data about a file, including its MIME type and a URI pointing to its location.

Link copied to clipboard

Builder class for constructing a FileData object.

Link copied to clipboard
@Serializable
data class FileSearchTool(val fileSearchStoreNames: Array<String>? = null, val metadataFilter: String? = null)

Represents a File Search tool.

Link copied to clipboard

Represents the file search tool builder.

Link copied to clipboard
actual class FileUploadProvider(apiKey: String, client: HttpClient?, json: Json)

Represents the file upload provider.

expect class FileUploadProvider(apiKey: String, client: HttpClient? = null, json: Json = Json { ignoreUnknownKeys = true })

Represents the file upload provider.

actual class FileUploadProvider(apiKey: String, client: HttpClient?, json: Json)

Represents the file upload provider.

actual class FileUploadProvider(apiKey: String, client: HttpClient?, json: Json)

Represents the file upload provider.

actual class FileUploadProvider(apiKey: String, client: HttpClient?, json: Json)

Represents the file upload provider.

Link copied to clipboard
@Serializable
data class FileWrapper(val file: GeminiFile)

Represents the file wrapper.

Link copied to clipboard
@Serializable
data class FunctionCall(val name: String, val args: Map<String, JsonElement>)

Represents a call to a function, specifying the function's name and the arguments to be passed to it.

Link copied to clipboard

Represents the function call builder.

Link copied to clipboard
@Serializable
data class FunctionCallingConfig(val mode: Mode, val allowedFunctionNames: Array<String>)

Configures how function calls are handled within a certain context, specifying the mode of operation and restrictions on which functions can be called.

Link copied to clipboard

Represents the function calling config builder.

Link copied to clipboard
@Serializable
data class FunctionDeclaration(val name: String, val description: String, val parameters: Schema)

Describes a function, including its name, a description of its purpose or behavior, and a schema defining its parameters.

Link copied to clipboard

Represents the function declaration builder.

Link copied to clipboard
@Serializable
data class FunctionResponse(val name: String, val response: JsonObject)

Represents the response from a function call, including the function's name and the arguments or values returned by the function.

Link copied to clipboard
class Gemini(apiKey: String, client: HttpClient? = null, fileUploadProvider: FileUploadProvider? = null)

Represents a client for interacting with the Gemini API, providing methods to extract content, embed content, and retrieve model information.

Link copied to clipboard
@Serializable
data class GeminiError(val code: Int, val message: String, val status: String, val details: List<GeminiErrorDetail>? = null)

Represents the detailed error information.

Link copied to clipboard
@Serializable
data class GeminiErrorDetail(val type: String? = null, val reason: String? = null, val domain: String? = null, val metadata: Map<String, String>? = null, val retryDelay: String? = null, val links: List<GeminiErrorLink>? = null, val violations: List<GeminiErrorViolation>? = null)

Represents a detail object within the error response. Fields are nullable as different error types provide different details.

Link copied to clipboard
@Serializable
data class GeminiErrorLink(val description: String? = null, val url: String? = null)

Represents the gemini error link.

Link copied to clipboard
@Serializable
data class GeminiErrorResponse(val error: GeminiError)

Represents the top-level error response structure from the Gemini API.

Link copied to clipboard
@Serializable
data class GeminiErrorViolation(val quotaMetric: String? = null, val quotaId: String? = null, val quotaDimensions: Map<String, String>? = null, val description: String? = null)

Represents the gemini error violation.

Link copied to clipboard
class GeminiException(val error: GeminiError) : RuntimeException

Exception thrown when the Gemini API returns an error.

Link copied to clipboard
@Serializable
data class GeminiFile(val name: String, val displayName: String, val uri: String, val mimeType: String, val createTime: String, val updateTime: String, val expirationTime: String, val sha256Hash: String, val sizeBytes: Long)

Represents the gemini file.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class GeminiFunction(val description: String)

Represents the gemini function.

Link copied to clipboard
class GeminiJsClient(apiKey: String)

Represents the gemini js client.

Link copied to clipboard
class GeminiJsExport(apiKey: String)

Represents the gemini js export.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.VALUE_PARAMETER])
annotation class GeminiParameter(val description: String)

Represents the gemini parameter.

Link copied to clipboard
@Serializable
data class GenerateContentRequest(val contents: Array<Content>, val tools: Array<Tool> = emptyArray(), val toolConfig: ToolConfig? = null, val safetySettings: Array<SafetySetting> = emptyArray(), val systemInstruction: Content? = null, val generationConfig: GenerationConfig? = null, val cachedContent: String? = null)

Represents a request to generate content, specifying the inputs, tools, and configurations required for content generation.

Link copied to clipboard

Represents the generate content request builder.

Link copied to clipboard
@Serializable
data class GenerateContentResponse(val candidates: List<Candidate>, val promptFeedback: PromptFeedback? = null, val usageMetadata: UsageMetadata? = null, val modelVersion: String = "", val responseId: String = "")

Represents the response structure for a content generation or analysis request.

Link copied to clipboard
@Serializable
data class GenerationConfig(val stopSequences: Array<String>? = null, val temperature: Double? = null, val maxOutputTokens: Int? = null, val topP: Double? = null, val topK: Int? = null, val responseMimeType: String? = null, val responseModalities: Array<Modality>? = null, val thinkingConfig: ThinkingConfig? = null, val imageConfig: ImageConfig? = null, val speechConfig: SpeechConfig? = null)

Configures the parameters for content generation, including conditions for stopping generation, creativity controls, output limits, and the format of the generated content.

Link copied to clipboard

Represents the generation config builder.

Link copied to clipboard
@Serializable
class GoogleSearch

Represents a Google Search tool.

Link copied to clipboard
@Serializable
data class GroundingAttribution(val sourceId: AttributionSourceId, val content: Content)

Represents the attribution of grounding, linking content to its source.

Link copied to clipboard

Represents the grounding attribution builder.

Link copied to clipboard
@Serializable
data class GroundingChunk(val web: Web? = null)

A chunk of content from a grounding source.

Link copied to clipboard
@Serializable
data class GroundingMetadata(val searchEntryPoint: SearchEntryPoint? = null, val webSearchQueries: List<String> = emptyList(), val groundingChunks: List<GroundingChunk> = emptyList(), val groundingSupports: List<GroundingSupport> = emptyList())

Metadata returned to the client when grounding is enabled.

Link copied to clipboard
@Serializable
data class GroundingPassageId(val passageId: String, val partIndex: Int)

Represents an identifier for a grounding passage, including its unique ID and the index of the part within the passage.

Link copied to clipboard

Represents the grounding passage id builder.

Link copied to clipboard
@Serializable
data class GroundingSupport(val segment: Segment? = null, val groundingChunkIndices: List<Int> = emptyList())

Grounding support.

Link copied to clipboard

Enumerates categories of harm that content may be classified under, providing a structured way to identify and categorize potentially harmful or sensitive content.

Link copied to clipboard

Enum class representing different categories of harmful content.

Link copied to clipboard
@Serializable
data class ImageConfig(val aspectRatio: String? = null, val imageSize: String? = null)

Configures the image generation parameters.

Link copied to clipboard

Represents the image config builder.

Link copied to clipboard
@Serializable
data class InlineData(val mimeType: String, val data: String)

Represents inline data that can be included in a request or response, typically for media content.

Link copied to clipboard

Represents the inline data builder.

Link copied to clipboard
class ITTest

Represents the ittest.

Link copied to clipboard
@Serializable
data class LatLng(val latitude: Double, val longitude: Double)

Represents the lat lng.

Link copied to clipboard
@Serializable
data class LogprobsResult(val topCandidates: List<TopCandidates>, val chosenCandidates: List<Candidate>)

Represents the logprobs result.

Link copied to clipboard
enum Modality : Enum<Modality>

Enumerates the modalities that can be returned by the model.

Link copied to clipboard
@Serializable
data class ModalityTokenCount(val modality: Modality, val tokenCount: Int)

Represents the modality token count.

Link copied to clipboard
enum Mode : Enum<Mode>

Enumerates the possible modes of operation or configuration settings, providing predefined options for various functionalities.

Link copied to clipboard
@Serializable
data class Model(val name: String, val baseModelId: String? = null, val version: String, val displayName: String, val description: String? = null, val inputTokenLimit: Int, val outputTokenLimit: Int, val supportedGenerationMethods: List<String>, val temperature: Double? = null, val maxTemperature: Double? = null, val topP: Double? = null, val topK: Int? = null)

Represents a model with its metadata and configuration parameters, providing detailed information about its capabilities and restrictions.

Link copied to clipboard
@Serializable
data class ModelCollection(val models: List<Model>)

Represents a collection of models, encapsulating them in a list structure for easy management and access.

Link copied to clipboard
@Serializable
data class MultiSpeakerVoiceConfig(val speakerVoiceConfigs: Array<SpeakerVoiceConfig>? = null)

Configures the multi-speaker voice parameters.

Link copied to clipboard

Represents the multi speaker voice config builder.

Link copied to clipboard
@Serializable
data class Part(val text: String? = null, val inlineData: InlineData? = null, val functionCall: FunctionCall? = null, val functionResponse: FunctionResponse? = null, val fileData: FileData? = null, val executableCode: ExecutableCode? = null, val codeExecutionResult: CodeExecutionResult? = null)

Represents a part of content, which can be one of several types such as text, inline data, function call, function response, or file data.

Link copied to clipboard

Represents the part builder.

Link copied to clipboard
@Serializable
data class PrebuiltVoiceConfig(val voiceName: String? = null)

Configures the prebuilt voice parameters.

Link copied to clipboard

Represents the prebuilt voice config builder.

Link copied to clipboard
@Serializable
data class PromptFeedback(val safetyRatings: List<SafetyRating>)

Represents feedback on the safety of a prompt, including ratings across various harm categories.

Link copied to clipboard

Represents the prompt feedback builder.

Link copied to clipboard
@Serializable
data class RetrievalConfig(val latLng: LatLng? = null, val languageCode: String? = null)

Represents the retrieval config.

Link copied to clipboard

Represents the retrieval config builder.

Link copied to clipboard
@Serializable
data class SafetyRating(val category: HarmCategory, val probability: HarmProbability, val blocked: Boolean? = null)

Represents a safety assessment for a specific category of potential harm.

Link copied to clipboard

Represents the safety rating builder.

Link copied to clipboard
@Serializable
data class SafetySetting(val category: HarmCategory, val threshold: Threshold)

Defines a safety setting for filtering or evaluating content based on a specific harm category.

Link copied to clipboard

Represents the safety setting builder.

Link copied to clipboard
@Serializable
data class Schema(val type: String, val format: String? = null, val description: String? = null, val nullable: Boolean = false, val enum: List<String> = emptyList(), val properties: Map<String, Schema> = emptyMap(), val required: List<String> = emptyList(), val items: Schema? = null)

Represents the schema definition for a data model, detailing its structure, type, and various constraints.

Link copied to clipboard

Represents the schema builder.

Link copied to clipboard
@Serializable
data class SearchEntryPoint(val renderedContent: String? = null)

Google search entry point.

Link copied to clipboard
@Serializable
data class Segment(val startIndex: Int? = null, val endIndex: Int? = null, val text: String? = null)

Segment of the content.

Link copied to clipboard
@Serializable
data class SemanticRetrieverChunk(val source: String, val chunk: String)

Represents a chunk of data retrieved by a semantic retriever, containing both the source from which the chunk was extracted and the chunk content itself.

Link copied to clipboard
@Serializable
data class SpeakerVoiceConfig(val speaker: String? = null, val voiceConfig: VoiceConfig? = null)

Configures the voice parameters for a specific speaker.

Link copied to clipboard

Represents the speaker voice config builder.

Link copied to clipboard
@Serializable
data class SpeechConfig(val voiceConfig: VoiceConfig? = null, val multiSpeakerVoiceConfig: MultiSpeakerVoiceConfig? = null)

Configures the speech generation parameters.

Link copied to clipboard

Represents the speech config builder.

Link copied to clipboard
enum TaskType : Enum<TaskType>

Enumerates the types of tasks that can be performed.

Link copied to clipboard
@Serializable
data class ThinkingConfig(val thinkingBudget: Int = 1024)

Represents the thinking config.

Link copied to clipboard
enum Threshold : Enum<Threshold>

Enumerates the possible thresholds for content blocking or filtering based on safety assessments.

Link copied to clipboard
@Serializable
data class Tool(val functionDeclarations: Array<FunctionDeclaration>? = null, val googleSearch: GoogleSearch? = null, val codeExecution: CodeExecution? = null, val urlContext: UrlContext? = null, val fileSearch: FileSearchTool? = null)

Represents a tool that encapsulates function declarations, providing a structured way to access the functionalities declared.

Link copied to clipboard

Represents the tool builder.

Link copied to clipboard
@Serializable
data class ToolConfig(val functionCallingConfig: FunctionCallingConfig, val retrievalConfig: RetrievalConfig? = null)

Represents a tool that encapsulates function declarations, providing a structured way to access the functionalities declared.

Link copied to clipboard

Represents the tool config builder.

Link copied to clipboard
@Serializable
data class TopCandidates(val candidates: List<Candidate>)

Represents the top candidates.

Link copied to clipboard
@Serializable
data class TotalTokens(val totalTokens: Int)

Represents the total count of tokens, typically used to summarize the amount of processed or generated content in terms of tokens.

Link copied to clipboard
@Serializable
class UrlContext

Represents the url context.

Link copied to clipboard
@Serializable
data class UrlContextMetadata(val urlMetadata: List<UrlMetadata> = emptyList())

Metadata about the URL context.

Link copied to clipboard
@Serializable
data class UrlMetadata(val retrievedUrl: String, val urlRetrievalStatus: String)

Metadata for a single retrieved URL.

Link copied to clipboard
@Serializable
data class UsageMetadata(val promptTokenCount: Int? = null, val candidatesTokenCount: Int? = null, val totalTokenCount: Int, val promptTokensDetails: List<ModalityTokenCount>? = null, val toolUsePromptTokenCount: Int? = null, val toolUsePromptTokensDetails: List<ModalityTokenCount>? = null, val thoughtsTokenCount: Int? = null)

Represents the usage metadata.

Link copied to clipboard
@Serializable
data class Values(val values: List<Double>)

Represents a container for a list of numeric values.

Link copied to clipboard

Represents the values builder.

Link copied to clipboard
@Serializable
data class VoiceConfig(val prebuiltVoiceConfig: PrebuiltVoiceConfig? = null)

Configures the voice parameters.

Link copied to clipboard

Represents the voice config builder.

Link copied to clipboard
@Serializable
data class Web(val uri: String? = null, val title: String? = null)

Chunk from the web.

Functions

Link copied to clipboard

Handles attribution source id.

Link copied to clipboard
expect fun buildFunctionDeclaration(function: KFunction<*>): FunctionDeclaration

Handles build function declaration.

actual fun buildFunctionDeclaration(function: KFunction<*>): FunctionDeclaration

Handles build function declaration.

actual fun buildFunctionDeclaration(function: KFunction<*>): FunctionDeclaration

Handles build function declaration.

actual fun buildFunctionDeclaration(function: KFunction<*>): FunctionDeclaration

Handles build function declaration.

Link copied to clipboard
fun candidate(init: CandidateBuilder.() -> Unit): Candidate

Handles candidate.

Link copied to clipboard

Handles citation metadata.

Link copied to clipboard

Handles citation source.

Link copied to clipboard

Handles code execution result.

Link copied to clipboard
fun content(init: ContentBuilder.() -> Unit): Content

Handles content.

Link copied to clipboard
actual fun createHttpClient(json: Json): HttpClient

Handles create http client.

expect fun createHttpClient(json: Json): HttpClient

Handles create http client.

actual fun createHttpClient(json: Json): HttpClient

Handles create http client.

actual fun createHttpClient(json: Json): HttpClient

Handles create http client.

actual fun createHttpClient(json: Json): HttpClient

Creates an HTTP client configured for the native platform.

Link copied to clipboard

Handles executable code.

Link copied to clipboard
fun fileData(init: FileDataBuilder.() -> Unit): FileData

DSL function to create a FileData object using a builder pattern.

Link copied to clipboard

Handles function call.

Link copied to clipboard

Handles function calling config.

Link copied to clipboard

Handles function declaration.

Link copied to clipboard

Handles generate content request.

Link copied to clipboard
suspend fun generateText(apiKey: String, prompt: String, model: String = "gemini-pro"): String

Handles generate text.

Link copied to clipboard

Handles generation config.

Link copied to clipboard
fun Gemini.getLiveClient(model: String, config: LiveConnectConfig? = null): GeminiLive

Creates a client for the Live API.

Link copied to clipboard

Handles grounding attribution.

Link copied to clipboard

Handles grounding passage id.

Link copied to clipboard

Handles image config.

Link copied to clipboard
fun inlineData(init: InlineDataBuilder.() -> Unit): InlineData

Handles inline data.

Link copied to clipboard
fun main()

Handles main.

Link copied to clipboard
fun part(init: PartBuilder.() -> Unit): Part

Handles part.

Link copied to clipboard

Handles prompt feedback.

Link copied to clipboard

Handles retrieval config.

Link copied to clipboard
suspend fun runSample1(apiKey: String, prompt: String = "Write a story about a magic backpack.", model: String = "gemini-2.5-flash-lite"): String

Handles run sample1.

Link copied to clipboard

Handles safety rating.

Link copied to clipboard

Handles safety setting.

Link copied to clipboard

Handles speech config.

Link copied to clipboard
fun tool(init: ToolBuilder.() -> Unit): Tool

Handles tool.

Link copied to clipboard
fun toolConfig(init: ToolConfigBuilder.() -> Unit): ToolConfig

Handles tool config.

Link copied to clipboard
fun values(init: ValuesBuilder.() -> Unit): Values

Handles values.