Skip to content

Conversation

@JGoP-L
Copy link
Contributor

@JGoP-L JGoP-L commented Jan 8, 2026

⏺ ## AgentScope-Java Version

1.0.7

Description

Background

Issue #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:

// 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 #431

@JGoP-L JGoP-L requested review from a team and Copilot January 8, 2026 15:17
Copy link
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

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 endpointPath field to GenerateOptions with full builder and merge support
  • Extended OpenAIChatModel.Builder to accept endpoint path configuration
  • Updated OpenAIClient to use custom endpoint paths with fallback to default
  • Added Spring Boot and Micronaut configuration support for endpoint-path property
  • 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
Copy link

codecov bot commented Jan 8, 2026

@AlbumenJ AlbumenJ merged commit d323a6a into agentscope-ai:main Jan 9, 2026
4 checks passed
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
  ```
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.

2 participants