Gemini

class Gemini(apiKey: String)

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

Constructors

Link copied to clipboard
constructor(apiKey: String)

Functions

Link copied to clipboard
fun batchEmbedContents(inputJson: BatchEmbedRequest, model: String = "embedding-001"): BatchEmbedResponse

Embeds contents in batch using the embedding-001 model.

Link copied to clipboard
fun countTokens(inputJson: CountTokensRequest, model: String = "gemini-2.0-flash-lite"): TotalTokens

Counts the number of tokens in the provided text using a specified model.

Link copied to clipboard
fun createCachedContent(inputJson: CachedContent, model: String = "gemini-1.5-flash"): CachedContent

Creates a new cached content entry in the system.

Link copied to clipboard
fun deleteCachedContent(name: String)

Deletes a specific cached content entry by name.

Link copied to clipboard
fun deleteContent(urlStr: String)

Sends a DELETE request to the specified URL to delete content.

Link copied to clipboard
fun embedContent(inputJson: EmbedContentRequest, model: String = "embedding-001"): EmbedResponse

Embeds content using the embedding-001 model.

Link copied to clipboard
fun generateContent(inputJson: GenerateContentRequest, model: String = "gemini-pro"): GenerateContentResponse

Generates content based on the provided input JSON using a specified model.

Link copied to clipboard
fun getCachedContent(name: String): CachedContent

Fetches cached content by name.

Link copied to clipboard
fun getContent(urlStr: String, inputJson: String? = null): String

Performs a POST request to the specified URL string with the given input JSON payload.

Link copied to clipboard

Retrieves a collection of models available in the Gemini API.

Link copied to clipboard
fun listCachedContent(pageSize: Int = 1000, pageToken: String? = null): CachedContentList

Retrieves a list of cached content entries.