Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(gemini): add baseUrl builder support#1174

Merged
LearningGp merged 3 commits into
agentscope-ai:mainfrom
rrrjqy66:rrrjqy/gemini-baseurl-1127
Apr 24, 2026
Merged

feat(gemini): add baseUrl builder support#1174
LearningGp merged 3 commits into
agentscope-ai:mainfrom
rrrjqy66:rrrjqy/gemini-baseurl-1127

Conversation

@rrrjqy66
Copy link
Copy Markdown
Contributor

@rrrjqy66 rrrjqy66 commented Apr 9, 2026

AgentScope-Java Version

1.0.12-SNAPSHOT

Description

Background

Issue #1127 requests a simpler way to configure a custom baseUrl for Gemini.

The underlying Google GenAI SDK already supports endpoint override through HttpOptions, but AgentScope-Java currently exposes that only through the lower-level httpOptions(...) builder method. As a result, Gemini is less ergonomic than the other model builders when users need to target a custom gateway, private endpoint, or mock server.

Purpose

Add a first-class baseUrl builder entrypoint for Gemini so custom endpoints can be configured more easily and consistently.

Changes Made

  • Added GeminiChatModel.Builder.baseUrl(String)
  • Mapped builder-level baseUrl to the effective Google GenAI HttpOptions
  • Preserved existing httpOptions(...) settings when both httpOptions(...) and baseUrl(...) are provided
  • Updated Gemini documentation examples in both English and Chinese docs
  • Added unit coverage for baseUrl(...) and the merge behavior with existing httpOptions(...)

Why this approach

This change is intentionally kept narrow and focused on the builder ergonomics requested in #1127.

The Google GenAI SDK already models endpoint override through HttpOptions, so this PR adds a convenient high-level entrypoint without changing the underlying transport model. Advanced transport or proxy-related configuration remains available through the existing lower-level configuration methods.

How to Test

  • Build a GeminiChatModel with .baseUrl(https://example.test) and verify construction succeeds
  • Build a model with both .httpOptions(...) and .baseUrl(...) and verify the custom base URL is applied without losing the other HTTP settings
  • Run mvn -pl agentscope-core -Dtest=GeminiChatModelTest test
  • Run mvn -pl agentscope-core test
  • Run mvn -pl agentscope-core spotless:check

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test for the affected module)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated
  • Code is ready for review

Closes #1127

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...java/io/agentscope/core/model/GeminiChatModel.java 83.33% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@rrrjqy66 rrrjqy66 marked this pull request as ready for review April 9, 2026 03:59
@rrrjqy66 rrrjqy66 requested review from a team and Copilot April 9, 2026 03:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a higher-level baseUrl(...) builder option to GeminiChatModel so users can override the Gemini API endpoint without needing to construct HttpOptions manually, aligning Gemini’s ergonomics with other model builders in the codebase.

Changes:

  • Added GeminiChatModel.Builder.baseUrl(String) and merged it into effective Google GenAI HttpOptions.
  • Ensured baseUrl(...) overrides only the base URL while preserving other httpOptions(...) settings.
  • Updated English/Chinese docs and added unit tests covering the new builder behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
agentscope-core/src/main/java/io/agentscope/core/model/GeminiChatModel.java Adds baseUrl builder field/method and merges it into effective HttpOptions used by the Google GenAI client.
agentscope-core/src/test/java/io/agentscope/core/model/GeminiChatModelTest.java Adds unit tests validating baseUrl wiring and merge behavior with existing HttpOptions.
docs/en/task/model.md Documents the new baseUrl option and provides an example.
docs/zh/task/model.md Documents the new baseUrl option and provides an example (Chinese docs).
Comments suppressed due to low confidence (1)

agentscope-core/src/main/java/io/agentscope/core/model/GeminiChatModel.java:100

  • Adding baseUrl into the public GeminiChatModel constructor signature is a source/binary breaking change for any callers using new GeminiChatModel(...). To keep backward compatibility, consider keeping the old constructor (without baseUrl) and delegating it to the new one with baseUrl = null (optionally deprecating the old overload).
    public GeminiChatModel(
            String apiKey,
            String baseUrl,
            String modelName,
            boolean streamEnabled,
            String project,
            String location,
            Boolean vertexAI,
            HttpOptions httpOptions,

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread agentscope-core/src/main/java/io/agentscope/core/model/GeminiChatModel.java Outdated
Comment thread agentscope-core/src/main/java/io/agentscope/core/model/GeminiChatModel.java Outdated
Copy link
Copy Markdown
Collaborator

@LearningGp LearningGp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LearningGp LearningGp merged commit f6c15f0 into agentscope-ai:main Apr 24, 2026
5 checks passed
liangxingguang pushed a commit to liangxingguang/agentscope-java that referenced this pull request May 21, 2026
## AgentScope-Java Version

1.0.12-SNAPSHOT

## Description

### Background

Issue agentscope-ai#1127 requests a simpler way to configure a custom `baseUrl` for
Gemini.

The underlying Google GenAI SDK already supports endpoint override
through `HttpOptions`, but AgentScope-Java currently exposes that only
through the lower-level `httpOptions(...)` builder method. As a result,
Gemini is less ergonomic than the other model builders when users need
to target a custom gateway, private endpoint, or mock server.

### Purpose

Add a first-class `baseUrl` builder entrypoint for Gemini so custom
endpoints can be configured more easily and consistently.

### Changes Made

- Added `GeminiChatModel.Builder.baseUrl(String)`
- Mapped builder-level `baseUrl` to the effective Google GenAI
`HttpOptions`
- Preserved existing `httpOptions(...)` settings when both
`httpOptions(...)` and `baseUrl(...)` are provided
- Updated Gemini documentation examples in both English and Chinese docs
- Added unit coverage for `baseUrl(...)` and the merge behavior with
existing `httpOptions(...)`

### Why this approach

This change is intentionally kept narrow and focused on the builder
ergonomics requested in agentscope-ai#1127.

The Google GenAI SDK already models endpoint override through
`HttpOptions`, so this PR adds a convenient high-level entrypoint
without changing the underlying transport model. Advanced transport or
proxy-related configuration remains available through the existing
lower-level configuration methods.

### How to Test

- Build a `GeminiChatModel` with `.baseUrl(https://example.test)` and
verify construction succeeds
- Build a model with both `.httpOptions(...)` and `.baseUrl(...)` and
verify the custom base URL is applied without losing the other HTTP
settings
- Run `mvn -pl agentscope-core -Dtest=GeminiChatModelTest test`
- Run `mvn -pl agentscope-core test`
- Run `mvn -pl agentscope-core spotless:check`

## Checklist

- [x] Code has been formatted with `mvn spotless:apply`
- [x] All tests are passing (`mvn test` for the affected module)
- [x] Javadoc comments are complete and follow project conventions
- [x] Related documentation has been updated
- [x] Code is ready for review

Closes agentscope-ai#1127
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support Custom Base URL Configuration for GeminiChatModel

3 participants