) value;
+ return new LinkedHashMap<>(casted);
+ }
+ if (value == null) {
+ return new LinkedHashMap<>();
+ }
+ return mapper.convertValue(value, MAP_TYPE);
+ }
+}
diff --git a/integrations/chat-models/gemini/src/main/java/org/apache/flink/agents/integrations/chatmodels/gemini/GeminiChatModelSetup.java b/integrations/chat-models/gemini/src/main/java/org/apache/flink/agents/integrations/chatmodels/gemini/GeminiChatModelSetup.java
new file mode 100644
index 000000000..0cb843949
--- /dev/null
+++ b/integrations/chat-models/gemini/src/main/java/org/apache/flink/agents/integrations/chatmodels/gemini/GeminiChatModelSetup.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.flink.agents.integrations.chatmodels.gemini;
+
+import org.apache.flink.agents.api.chat.model.BaseChatModelSetup;
+import org.apache.flink.agents.api.resource.ResourceContext;
+import org.apache.flink.agents.api.resource.ResourceDescriptor;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+/**
+ * Chat model setup for the Google Gemini {@code generateContent} API.
+ *
+ * Responsible for providing per-chat configuration such as model, temperature, max output
+ * tokens, tool bindings, and additional Gemini parameters. The setup delegates execution to {@link
+ * GeminiChatModelConnection}.
+ *
+ *
Supported parameters:
+ *
+ *
+ * - connection (required): Name of the GeminiChatModelConnection resource
+ *
- model (optional): Model name (default: gemini-3.1-pro-preview)
+ *
- temperature (optional): Sampling temperature 0.0-2.0 (default: 0.1)
+ *
- max_output_tokens (optional): Maximum tokens in response (default: 1024)
+ *
- tools (optional): List of tool names available for the model to use
+ *
- additional_kwargs (optional): Additional parameters (e.g. top_k, top_p)
+ *
+ *
+ * Example usage:
+ *
+ *
{@code
+ * public class MyAgent extends Agent {
+ * @ChatModelSetup
+ * public static ResourceDesc gemini() {
+ * return ResourceDescriptor.Builder.newBuilder(GeminiChatModelSetup.class.getName())
+ * .addInitialArgument("connection", "myGeminiConnection")
+ * .addInitialArgument("model", "gemini-3.1-pro-preview")
+ * .addInitialArgument("temperature", 0.3d)
+ * .addInitialArgument("max_output_tokens", 2048)
+ * .addInitialArgument("tools", List.of("getWeather"))
+ * .build();
+ * }
+ * }
+ * }
+ */
+public class GeminiChatModelSetup extends BaseChatModelSetup {
+
+ private static final String DEFAULT_MODEL = "gemini-3.1-pro-preview";
+ private static final double DEFAULT_TEMPERATURE = 0.1d;
+ private static final long DEFAULT_MAX_OUTPUT_TOKENS = 1024L;
+
+ private final Double temperature;
+ private final Long maxOutputTokens;
+ private final Map additionalArguments;
+
+ public GeminiChatModelSetup(ResourceDescriptor descriptor, ResourceContext resourceContext) {
+ super(descriptor, resourceContext);
+ this.temperature =
+ Optional.ofNullable(descriptor.getArgument("temperature"))
+ .map(Number::doubleValue)
+ .orElse(DEFAULT_TEMPERATURE);
+ if (this.temperature < 0.0 || this.temperature > 2.0) {
+ throw new IllegalArgumentException("temperature must be between 0.0 and 2.0");
+ }
+
+ this.maxOutputTokens =
+ Optional.ofNullable(descriptor.getArgument("max_output_tokens"))
+ .map(Number::longValue)
+ .orElse(DEFAULT_MAX_OUTPUT_TOKENS);
+ if (this.maxOutputTokens <= 0) {
+ throw new IllegalArgumentException("max_output_tokens must be greater than 0");
+ }
+
+ this.additionalArguments =
+ Optional.ofNullable(
+ descriptor.