Gemini Model¶
agentscope-extensions-model-gemini integrates Google Gemini models through the Gemini API and supports the Vertex AI path through explicit configuration.
Add the dependency¶
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-extensions-model-gemini</artifactId>
<version>${agentscope.version}</version>
</dependency>
ModelRegistry¶
Set GEMINI_API_KEY, then use the gemini:<model> id:
ReActAgent agent = ReActAgent.builder()
.name("assistant")
.model("gemini:gemini-2.0-flash") // Resolved internally by ModelRegistry.resolve(modelId)
.build();
Explicit builder¶
Use the builder when you need custom API settings, Vertex AI credentials, formatter, transport, or generation options:
import io.agentscope.extensions.model.gemini.GeminiChatModel;
GeminiChatModel model = GeminiChatModel.builder()
.apiKey(System.getenv("GEMINI_API_KEY"))
.modelName("gemini-2.0-flash")
.streamEnabled(true)
.build();
Spring Boot¶
Spring Boot applications can use the Gemini starter:
<dependency>
<groupId>io.agentscope</groupId>
<artifactId>agentscope-gemini-spring-boot-starter</artifactId>
<version>${agentscope.version}</version>
</dependency>
Full builder options, formatters, credentials, and registry context details are covered in Model.