Problem Description

I am using SpringAI 1.0.1 to call a third-party OpenAI/Doubao model.
I want to add a custom field to the request body:

"thinking": {
    "type": "disabled"
}

so that the model disables its "thinking" feature. However, this does not take effect — the request body sent to the API does not include the field.

Steps to Reproduce / Minimal Example

```@Bean public RestClient.Builder customRestClientBuilder() { ClientHttpRequestFactorySettings settings = ClientHttpRequestFactorySettings.defaults() .withConnectTimeout(Duration.ofMinutes(3)) .withReadTimeout(Duration.ofMinutes(5));

RestClient.Builder builder = RestClient.builder();
builder.requestFactory(ClientHttpRequestFactoryBuilder.reactor().build(settings));
return builder;

}

ChatClient chatClient = ChatClient.builder( OpenAiChatModel.builder() .openAiApi(openAiApi) .defaultOptions(OpenAiChatOptions.builder() .model("doubao-seed-1.6-250615") .build()) .build() ) .defaultSystem("Prompt text here") .defaultAdvisors(new ThinkingAdvisor()) // Custom Advisor .build();

ChatResponse response = chatClient.send(UserMessage.ofText("Test prompt"));


## Custom Advisor tried:

public class ThinkingAdvisor implements BaseAdvisor, Ordered {

@Override
public ChatClientRequest before(ChatClientRequest request, AdvisorChain chain) {
    request.getMetadata().put("thinking", Map.of("type", "disabled"));
    return chain.next(request);
}

@Override
public int getOrder() {
    return 0;
}

@Override
public ChatClientResponse after(ChatClientResponse response, AdvisorChain chain) {
    return response;
}

} ```

What I Tried

  1. Using ChatClient.Builder.apiRequestInterceptor())

  2. Problem: apiRequestInterceptor() does not exist in SpringAI 1.0.1.

  3. Custom Advisor (see above)

  4. Problem: The metadata contains the field, but the actual HTTP request body does not include it. The API ignores it.

  5. Overriding OpenAiChatModel.createRequest()

  6. Problem: The method is package-private and cannot be accessed or overridden from outside its package.

  7. Custom RestClient.Builder / printing request body

  8. Attempted to intercept or log the request body before sending; the thinking field never appears in the actual request.

Current Situation

  • No way to inject a custom field into the request body in SpringAI 1.0.1.

  • Advisor only modifies metadata, which is ignored by the API.

  • apiRequestInterceptor() is unavailable in this version.

  • OpenAiChatModel.createRequest() is inaccessible.

Expected behavior:

A supported mechanism to add arbitrary fields to the request body (e.g., "thinking": {"type":"disabled"}) so that the model can recognize them.

Environment

SpringAI version: 1.0.1

Java version: 17

Spring Boot version: 3.2.x

API: Doubao/OpenAI

Comment From: xqb0407

估计没那么快,最简单是把源码,直接拿下自己重写