GeminiApiEndpoints

class GeminiApiEndpoints(val apiKey: String)

The Gemini HTTP endpoints used to send prompts. It also includes the headers used and details about the HTTP API. Each Endpoint must belong to a Resource, which defines a path for specific functionalities or use-cases. version is used before the resource paths

I decided not to use Ktor's "Type-safe requests" since it requires those annotations and the "parent" property, which comes with many repetitive lines. I also didn't like how calling httpClient.get received a generic T and didn't go well with my KtorClient. So I did this to have more customization

  • For the various REST Resources -> https://ai.google.dev/api/all-methods

  • https://ai.google.dev/api/files

  • https://ai.google.dev/api/generate-content

  • https://ai.google.dev/gemini-api/docs/api-versions#rest

Get your API key here

Constructors

Link copied to clipboard
constructor(apiKey: String)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
abstract class Endpoint(endpointPath: String, val method: HttpMethod)
Link copied to clipboard
Link copied to clipboard
sealed interface Resources

Represents the root path ("/") of the RESTful API resources

Properties

Link copied to clipboard
private val apiKey: String

Functions

Link copied to clipboard

Util method to extract the HTTP URI path and queryParams (which will have the apiKey).