Gemini

Google Gemini is a family of multimodal AI models developed by Google DeepMind. Gemini models support text generation, vision, structured outputs, embeddings, and tool use, offering powerful capabilities for building AI-powered applications.

The sgcWebSockets library provides a Delphi component TsgcHTTP_API_Gemini to interact with the Gemini API.

Gemini API

The Gemini API provides access to Google Gemini models for building AI-powered applications. The API supports content generation, vision (image understanding), structured JSON outputs, streaming, token counting, embeddings, tool use (function calling), and model listing.

Features

Configuration

The Gemini API uses API keys for authentication. Visit your API Keys page in Google AI Studio to retrieve the API key you'll use in your requests.

Remember that your API key is a secret! Do not share it with others or expose it in any client-side code.

This API Key must be configured in the GeminiOptions.ApiKey property of the component.


Gemini := TsgcHTTP_API_Gemini.Create(nil);
Gemini.GeminiOptions.ApiKey := 'YOUR_API_KEY';

Messages

Send content to a Gemini model and receive generated responses. The model generates the next message based on the provided input.

Vision

Gemini models can understand images passed as base64-encoded content along with text prompts.

Structured Outputs

Generate structured JSON output from a Gemini model by providing a JSON schema that defines the expected response format.

Models

List and retrieve details about available Gemini models.

Token Counting

Count the number of tokens in a message before sending it to a model.

Embeddings

Generate vector embeddings for text content using Gemini models.