From 8a2459036f9179fd4c0b76174458dc43db721b03 Mon Sep 17 00:00:00 2001 From: Tachikoma Date: Tue, 14 Jul 2026 11:49:35 +0800 Subject: [PATCH 1/2] [docs][integration] Document Gemini chat model integration --- docs/content/docs/development/chat_models.md | 94 +++++++++++++++++++- docs/content/docs/faq/faq.md | 1 + 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/docs/content/docs/development/chat_models.md b/docs/content/docs/development/chat_models.md index c7b40ae05..5ce62b504 100644 --- a/docs/content/docs/development/chat_models.md +++ b/docs/content/docs/development/chat_models.md @@ -643,6 +643,98 @@ Some popular options include: Model availability depends on your Azure region and subscription. Always check the official Azure OpenAI documentation for regional availability before implementing in production. {{< /hint >}} +### Gemini + +Google Gemini provides cloud-based chat models through the Gemini Developer API and Vertex AI. The Flink Agents Gemini integration uses the official Google Gen AI SDK and supports text conversations, system instructions, and tool calling. + +{{< hint info >}} +Gemini is only supported in Java currently. To use Gemini from Python agents, see [Using Cross-Language Providers](#using-cross-language-providers). +{{< /hint >}} + +#### Prerequisites + +1. For the Gemini Developer API, create an API key in [Google AI Studio](https://aistudio.google.com/app/apikey) +2. For Vertex AI, enable Vertex AI in your Google Cloud project and configure Google Cloud credentials + +#### GeminiChatModelConnection Parameters + +{{< tabs "GeminiChatModelConnection Parameters" >}} + +{{< tab "Java" >}} + +| Parameter | Type | Default | Description | +|-----------|------|---------|-------------| +| `api_key` | String | Required unless `base_url` is set or `vertex_ai` is `true` | Gemini Developer API key | +| `base_url` | String | None | Custom endpoint, such as a proxy that injects credentials | +| `model` | String | None | Default model name, used when no model is supplied per setup | +| `timeout` | int | None | API request timeout in seconds | +| `vertex_ai` | boolean | `false` | Use Vertex AI instead of the Gemini Developer API | +| `project` | String | None | Vertex AI project id | +| `location` | String | None | Vertex AI location | + +{{< /tab >}} + +{{< /tabs >}} + +#### GeminiChatModelSetup Parameters + +{{< tabs "GeminiChatModelSetup Parameters" >}} + +{{< tab "Java" >}} + +| Parameter | Type | Default | Description | +|-----------|------|---------|-------------| +| `connection` | String | Required | Reference to connection method name | +| `model` | String | `"gemini-3.1-pro-preview"` | Name of the chat model to use | +| `prompt` | Prompt \| String | None | Prompt template or reference to prompt resource | +| `tools` | List | None | List of tool names available to the model | +| `temperature` | double | `0.1` | Sampling temperature (0.0 to 2.0) | +| `max_output_tokens` | long | `1024` | Maximum number of tokens to generate | +| `additional_kwargs` | Map | `{}` | Additional Gemini parameters (`top_k`, `top_p`, `stop_sequences`) | + +{{< /tab >}} + +{{< /tabs >}} + +#### Usage Example + +{{< tabs "Gemini Usage Example" >}} + +{{< tab "Java" >}} +```java +public class MyAgent extends Agent { + @ChatModelConnection + public static ResourceDescriptor geminiConnection() { + return ResourceDescriptor.Builder.newBuilder(ResourceName.ChatModel.GEMINI_CONNECTION) + .addInitialArgument("api_key", System.getenv("GEMINI_API_KEY")) + .build(); + } + + @ChatModelSetup + public static ResourceDescriptor geminiChatModel() { + return ResourceDescriptor.Builder.newBuilder(ResourceName.ChatModel.GEMINI_SETUP) + .addInitialArgument("connection", "geminiConnection") + .addInitialArgument("model", "gemini-3.1-pro-preview") + .addInitialArgument("temperature", 0.1d) + .addInitialArgument("max_output_tokens", 1024) + .build(); + } + + ... +} +``` +{{< /tab >}} + +{{< /tabs >}} + +#### Available Models + +Visit the [Gemini models documentation](https://ai.google.dev/gemini-api/docs/models) for the complete and up-to-date list of available models. + +{{< hint warning >}} +Model availability and names may differ between the Gemini Developer API and Vertex AI. Always check the official Gemini documentation before implementing in production. +{{< /hint >}} + ### Ollama Ollama provides local chat models that run on your machine, offering privacy, control, and no API costs. @@ -1370,4 +1462,4 @@ public class MyChatModelSetup extends BaseChatModelSetup { The built-in `chat_model_action` listens to `ChatRequestEvent` and `ToolResponseEvent`. To request a chat completion, send a `ChatRequestEvent`. If the model returns a final answer, the action sends a `ChatResponseEvent`. -If the model asks to call tools, `chat_model_action` sends a `ToolRequestEvent` instead of a final `ChatResponseEvent`. After the tools finish, it receives the matching `ToolResponseEvent`, appends the tool results to the chat history, and calls the model again. This loop continues until the model returns a final response. For details on how tools are executed, see [Built-in Events and Actions in Tool Use]({{< ref "docs/development/tool_use#built-in-events-and-actions" >}}). \ No newline at end of file +If the model asks to call tools, `chat_model_action` sends a `ToolRequestEvent` instead of a final `ChatResponseEvent`. After the tools finish, it receives the matching `ToolResponseEvent`, appends the tool results to the chat history, and calls the model again. This loop continues until the model returns a final response. For details on how tools are executed, see [Built-in Events and Actions in Tool Use]({{< ref "docs/development/tool_use#built-in-events-and-actions" >}}). diff --git a/docs/content/docs/faq/faq.md b/docs/content/docs/faq/faq.md index bc0cb279c..4b9fd7e7e 100644 --- a/docs/content/docs/faq/faq.md +++ b/docs/content/docs/faq/faq.md @@ -101,6 +101,7 @@ Flink Agents provides built-in integrations for many ecosystem providers. Some i | [Anthropic]({{< ref "docs/development/chat_models#anthropic" >}}) | ✅ | ✅ | | [Azure AI]({{< ref "docs/development/chat_models#azure-ai" >}}) | ❌ | ✅ | | [Azure OpenAI]({{< ref "docs/development/chat_models#azure-openai" >}}) | ✅ | ✅ | +| [Gemini]({{< ref "docs/development/chat_models#gemini" >}}) | ❌ | ✅ | | [Ollama]({{< ref "docs/development/chat_models#ollama" >}}) | ✅ | ✅ | | [OpenAI]({{< ref "docs/development/chat_models#openai" >}}) | ✅ | ✅ | | [Tongyi (DashScope)]({{< ref "docs/development/chat_models#tongyi-dashscope" >}}) | ✅ | ❌ | From 78f8fbb548c74019142c4fef7979cea8b551bb36 Mon Sep 17 00:00:00 2001 From: Tachikoma Date: Wed, 22 Jul 2026 14:03:13 +0800 Subject: [PATCH 2/2] [docs][integration] Mark Vertex AI support as experimental --- docs/content/docs/development/chat_models.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/content/docs/development/chat_models.md b/docs/content/docs/development/chat_models.md index 5ce62b504..1f28ca0c5 100644 --- a/docs/content/docs/development/chat_models.md +++ b/docs/content/docs/development/chat_models.md @@ -647,6 +647,10 @@ Model availability depends on your Azure region and subscription. Always check t Google Gemini provides cloud-based chat models through the Gemini Developer API and Vertex AI. The Flink Agents Gemini integration uses the official Google Gen AI SDK and supports text conversations, system instructions, and tool calling. +{{< hint warning >}} +Vertex AI support is experimental. The connection path has been smoke-tested during construction but has not yet been verified end to end. +{{< /hint >}} + {{< hint info >}} Gemini is only supported in Java currently. To use Gemini from Python agents, see [Using Cross-Language Providers](#using-cross-language-providers). {{< /hint >}} @@ -668,7 +672,7 @@ Gemini is only supported in Java currently. To use Gemini from Python agents, se | `base_url` | String | None | Custom endpoint, such as a proxy that injects credentials | | `model` | String | None | Default model name, used when no model is supplied per setup | | `timeout` | int | None | API request timeout in seconds | -| `vertex_ai` | boolean | `false` | Use Vertex AI instead of the Gemini Developer API | +| `vertex_ai` | boolean | `false` | Use the experimental Vertex AI backend; not yet verified end to end | | `project` | String | None | Vertex AI project id | | `location` | String | None | Vertex AI location |