feat: support configurable endpointPath for OpenAI-compatible APIs#488
Merged
AlbumenJ merged 3 commits intoagentscope-ai:mainfrom Jan 9, 2026
Conversation
…penAI-compatible-APIs
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds configurable endpointPath support for OpenAI-compatible APIs to address issue #431. Different API providers may use non-standard endpoint paths (e.g., /v4/chat/completions, /api/v1/llm/chat), and this feature enables flexible configuration at both the model level and per-request level.
Key changes:
- Added
endpointPathfield toGenerateOptionswith full builder and merge support - Extended
OpenAIChatModel.Builderto accept endpoint path configuration - Updated
OpenAIClientto use custom endpoint paths with fallback to default - Added Spring Boot and Micronaut configuration support for
endpoint-pathproperty - Included comprehensive unit tests for custom and default endpoint path behavior
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| agentscope-core/src/main/java/io/agentscope/core/model/GenerateOptions.java | Added endpointPath field with getter, builder method, and merge logic to support per-request endpoint configuration |
| agentscope-core/src/main/java/io/agentscope/core/model/OpenAIChatModel.java | Extended Builder with endpointPath() method for model-level endpoint configuration |
| agentscope-core/src/main/java/io/agentscope/core/model/OpenAIClient.java | Modified call() and stream() methods to use custom endpointPath from options with fallback to default |
| agentscope-extensions/agentscope-spring-boot-starters/agentscope-spring-boot-starter/src/main/java/io/agentscope/spring/boot/properties/OpenAIProperties.java | Added endpointPath property with getter/setter for Spring Boot configuration |
| agentscope-extensions/agentscope-spring-boot-starters/agentscope-spring-boot-starter/src/main/java/io/agentscope/spring/boot/model/ModelProviderType.java | Added logic to pass endpointPath from properties to OpenAIChatModel builder |
| agentscope-extensions/agentscope-micronaut-extensions/agentscope-micronaut-extension/src/main/java/io/agentscope/micronaut/properties/OpenAIProperties.java | Added endpointPath property with getter/setter for Micronaut configuration |
| agentscope-extensions/agentscope-micronaut-extensions/agentscope-micronaut-extension/src/main/java/io/agentscope/micronaut/model/ModelProviderType.java | Added logic to pass endpointPath from properties to OpenAIChatModel builder |
| agentscope-core/src/test/java/io/agentscope/core/model/OpenAIClientTest.java | Added unit tests for custom endpoint path and default endpoint path scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
AlbumenJ
approved these changes
Jan 9, 2026
yaohuitc
pushed a commit
to yaohuitc/agentscope-java
that referenced
this pull request
Jan 10, 2026
…gentscope-ai#488) ⏺ ## AgentScope-Java Version 1.0.7 ## Description ### Background Issue agentscope-ai#431 requests support for configuring the `endpointPath` parameter for OpenAI-compatible APIs. Different providers may use different endpoint paths (e.g., `/v1/chat/completions`, `/v4/chat/completions`, `/api/v1/llm/chat`), but the current code has a hardcoded endpoint path. ### Purpose Enable flexible configuration of the API endpoint path to support various OpenAI-compatible providers with non-standard endpoint structures. ### Changes Made - **GenerateOptions**: Added `endpointPath` field with getter, Builder setter, and merge support - **OpenAIClient**: Modified `call()` and `stream()` methods to use custom endpointPath from options, with fallback to default `/v1/chat/completions` - **OpenAIChatModel.Builder**: Added `endpointPath()` method for model-level configuration - **Properties (Spring Boot & Micronaut)**: Added `endpoint-path` configuration property - **ModelProviderType (Spring Boot & Micronaut)**: Updated to pass `endpointPath` to model builder - **Tests**: Added unit tests for custom and default endpoint path behavior ### How to Test **Java API:** ```java // Via GenerateOptions (per-request) GenerateOptions options = GenerateOptions.builder() .endpointPath("/v4/chat/completions") .build(); model.generate(messages, options); // Via OpenAIChatModel.Builder (model-level) OpenAIChatModel model = OpenAIChatModel.builder() .apiKey("sk-xxx") .modelName("gpt-4") .endpointPath("/v4/chat/completions") .build(); Spring Boot: agentscope: model: provider: openai openai: api-key: ${OPENAI_API_KEY} model-name: gpt-4 endpoint-path: /v4/chat/completions Micronaut: agentscope: model: provider: openai openai: api-key: ${OPENAI_API_KEY} model-name: gpt-4 endpoint-path: /v4/chat/completions Unit Tests: mvn test -Dtest=OpenAIClientTest#testCustomEndpointPathFromOptions mvn test -Dtest=OpenAIClientTest#testDefaultEndpointPathWhenNotSpecified Checklist - Code has been formatted with mvn spotless:apply - All tests are passing (mvn test) - Javadoc comments are complete and follow project conventions - Related documentation has been updated (configuration examples in Properties classes) - Code is ready for review --- Closes agentscope-ai#431 ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
⏺ ## AgentScope-Java Version
1.0.7
Description
Background
Issue #431 requests support for configuring the
endpointPathparameter for OpenAI-compatible APIs. Different providers may use different endpoint paths (e.g.,/v1/chat/completions,/v4/chat/completions,/api/v1/llm/chat), but the current code has a hardcoded endpoint path.Purpose
Enable flexible configuration of the API endpoint path to support various OpenAI-compatible providers with non-standard endpoint structures.
Changes Made
endpointPathfield with getter, Builder setter, and merge supportcall()andstream()methods to use custom endpointPath from options, with fallback to default/v1/chat/completionsendpointPath()method for model-level configurationendpoint-pathconfiguration propertyendpointPathto model builderHow to Test
Java API: